Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

getMeaningfulContent() [PHP] - Search Engine

Name: Anonymous 2007-09-27 6:43 ID:x5s6Nq2a

i Have just written this function in php. It is a small part of a search engine, the function searches through a string (in this case it's the content field of a page) and attempts to pick chunks of text out of the string and join them using ...

This is similar to how google works although i'm sure their algorithm is more advanced than this 5 minute job.

NOTES: getMeaningfulContent($s = string, $k = keywords (string|array), $n = int (number of characters to seek))

<?php
function getMeaningfulContent($s, $p, $n = 250) {
    if (strlen($s) > $n) {
        $buffer = '';
        $t_end = strlen($s)-1;
        if (is_array($p)) {
            foreach ($p as $k=>$v) {
                $t_poz_start = strpos(strtoupper($s), strtoupper($v), 0);
                if ($t_poz_start !== false) { // we've found an occurence
                    $t_percentage_to_read = ($t_end - $t_poz_start) / count($p);
                    if (($t_poz_start + $t_percentage_to_read) >= $t_end) {
                        $buffer .= '...' . substr($s, $t_poz_start, $t_end-$t_poz_start);
                    }
                    else {
                        $buffer .= '...' . substr($s, $t_poz_start, $t_end);
                    }
                }
            }
        }
        else {
            $t_poz_start = strpos(strtoupper($s), strtoupper($p), 0);
            if ($t_poz_start !== false) { // we've found an occurence
                if ($t_end - $t_poz_start > 150) {
                    $buffer = substr($s, $t_poz_start, $t_end-$t_poz_start);
                }
                else { $buffer = substr($s, $t_poz_start, $t_end); }
            }
        }
        return $buffer;
    }
    else { return $s; }
   }
?>

Name: Anonymous 2007-09-27 6:49 ID:Heaven

shit.

Name: Anonymous 2007-09-27 6:50 ID:x5s6Nq2a

go burn your fairy wings, fag

Name: Anonymous 2007-09-27 6:52 ID:QqGZ54Oe

Why the fuck does /prog/ need to see this?

It's like walking into a room full of attractive members of the opposite sex and shouting "Hey, check out this genital abscess!"

Name: Anonymous 2007-09-27 6:53 ID:Heaven

This is similar to how google works
Yeah, sure it is.

Name: Anonymous 2007-09-27 7:01 ID:x5s6Nq2a

Yeah because we all know /prog/ is a shining beacon of enlightened collaboration and this post beggars belief in comparison to such gems as 'FAX IS A DICK', 'lol @ Lisp faggot'.

Name: Anonymous 2007-09-27 7:06 ID:Heaven

PHP ← most ugly language ever.  EVER.

Name: Anonymous 2007-09-27 7:12 ID:Heaven

>>6
fax?

Name: Anonymous 2007-09-27 7:13 ID:QqGZ54Oe

>>6
lol @ PHP faggot

Name: Anonymous 2007-09-27 7:15 ID:x5s6Nq2a

PHP isn't ugly, i'm sorry but you FAIL.

Beauty is in the eye of the beholder, and combining PHP's syntax with it's feature richness and rapid development makes it a TOP BOWLER!

I would use it over lisp|python|prolog|haskell for it's major purpose.

And that is web development, and web development alone. If you want to create gtk apps or command line applications you can, but it's intended use is still web development, and at that task it excels.

Don't believe me? Well then you had better have a stacked deck or a couple of pairs up your sleeve because no amount of superficial ah hominen's (in b4 incorrect usage) will result in it's image as anything less than savior of modern day web development.

We all know that perl was infested with bloat and fail long before php came and kicked it's ass

Name: Anonymous 2007-09-27 7:19 ID:Heaven

Perl isn't ugly, i'm sorry but you FAIL.

Beauty is in the eye of the beholder, and combining PHP's syntax with it's feature richness and rapid development makes it a TOP BOWLER!

I would use it over lisp|python|prolog|haskell for it's major purpose.

And that is web development, and web development alone. If you want to create gtk apps or command line applications you can, but it's intended use is still web development, and at that task it excels.

Don't believe me? Well then you had better have a stacked deck or a couple of pairs up your sleeve because no amount of superficial ah hominen's (in b4 incorrect usage) will result in it's image as anything less than savior of modern day web development.

We all know that PHP was infested with bloat and fail long before perl came and kicked it's ass

Name: Anonymous 2007-09-27 7:21 ID:RtQ4TNV7

>>10
PHP has ugly syntax and teaches bad programming habits. Code some C#, J# or VB then talk about whats ugly and whats not, faggot.

Name: Anonymous 2007-09-27 7:26 ID:x5s6Nq2a

>>10

"I am the light of the world. Whoever follows me will never walk in darkness, but will have the light of life." - John 8:12

I think this can equally be applied to the PHP programming language as well as God, consider this.

o    Both God and PHP comprise of 3 letters.
o    Even PHP HATERS still think PHP is a TOP BOWLER >>11 (much like god)
o    PHP returns 2,160,000,000 results on google. This is greater than God, however as God is all knowing this affirms that God loves PHP.
o    There are only 50 people on this board who don't like PHP, the rest do but don't want you to know it because of the lulz

Remember, salvation lies within

Name: Anonymous 2007-09-27 7:29 ID:x5s6Nq2a

>>12 BAD programmers use BAD programming habits.
     VB teaches bad programming habits and VB is better than Perl

Name: Anonymous 2007-09-27 8:23 ID:QqGZ54Oe

>>14
YHBT YHL HAND

/TO

Name: Anonymous 2007-09-27 10:30 ID:1K0b+YN8

Woah! That was horrible.

Name: Anonymous 2007-09-27 10:35 ID:Heaven

>>14
Seeing you are the OP, I don't think you should be flinging around the term ``bad programming habits'' like that.

Name: Anonymous 2007-09-27 20:38 ID:DFt56Zk7

>>17 FAIL @ Keyboard criticism.

OP clearly shows his superior understanding of getting meaningful content.

And he totally owned you at the insults.

In b4 faggots who sit on their high horse whining like a baby

Name: Anonymous 2007-09-27 20:49 ID:TP5yGCJa

>>1
die

Name: Sergey Brin 2007-09-27 23:02 ID:FNK+QwF0

>>1
Hello, I am from Google and we would like to hire you. Your algorithm is superior to ours.

Name: Anonymous 2009-03-06 7:33


Want to hear it   I throw up   IN REAL LIFE   that are into   the void thinking   about math and   algorithms I do   however want it   to just keep   snapshots of the   beholder and combining.

Name: Anonymous 2009-03-06 11:25


80 bind fd struct sockaddr si sizeof   si listen fd.

Name: Anonymous 2012-06-25 23:07

ࢄ䈈❁∷砘Ɖ҃䕑〄霒㢓᎓⑙禕ផ晧十鍃灐饰捹䁲褥͵朓ᎄ噣咅礡煳荕捨㠑ᘸ㥰嘐䔳㊗㉧茥♱Ɩᖄᖁ蕓斒脇䚐鐰㤩ቆࠔ咒桗ᄈ杖΀禔ͱ灒鍰㙘ᜢ頸Զ儒❑♹԰琀䁴™ㅁ☇䞇祐䉨䅆ᐥ蜒攔瞘ঐ舀〆ᐹ蚒恢⊁①怅啉千朅霩鐷睱䝃鍨ぇ㘃喕ቘ危椙ᘗц䍒⥷础㦘礷坖閘偈ᘢ閑蠓噥薄䘲d襆ဧ䐗㢑ॆȀ腥褓ᐲঅ⊀聴⡗⤠䐓ᄆ〢ေ⁗䉇ذ戠呗╡達䕘捰᝖䕴恡▖㄁㤨‰晷傉ቑ䁉ጉ嚁虃㜷⁀ㄒ奥昕酔慣允耄荐ͤ⠇e瘩䢘䥲梃ࠦ唗兇᠈卤⑃⤂㖔え荷舡͗㝕摲祠ţ芖斗≗阀⡶䉇聆留Ѱ呤䘧㖔萵Ѩ㝤途ጆ脰㒇䑵餗皓暔憀耴㔱瀹舓薔䉸鎁᎙ᔈ锩批瞆冗ࠧ錅ᥩ噹䆕㌰䝸ᑙ㘅蠐зↆ遂附ā㉐妁㘘逈⊘呰̳ؗ眸ᑁ࢑㌖䅣⑕ɖⅠ砶饉䤴瑨儘瘓⅐⤐挃鍁∙ठԵ┳㎑€ተ䜡ز联ͱ睰ᄃ〘萀〔㠆ㅈ唄㎀ɲц街ѓ玂ᖄ

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List