ivarsli Posted March 29, 2008 Report Share Posted March 29, 2008 Esmu nejeega, par ko atvainojos no galvas liidz kaajaam. Ljoti ceru izraisiit sportisku interesi un iekustinaat paliidziigu roku. Runa ir par wodrpress plaginiem "similar_posts" un "headspace". Man vajag aizvietot (smart-matching Porter algorithm ) skriptu, kas der anglju valodai attieciibaa uz vaardu formaam - galotneem utt. - latvieshu valodai un papildus veel aizvietot atsleegvaardu sinoniimus. Labi vismaz, ka tematika un atsleegvaardu skaits manaa gadiijumaa ir ierobezots. Citeeju aprakstu: "HeadSpace will automatically suggest tags for posts based upon previous tags. A smart-matching algorithm is used so that matches will be made when words have the same root. For example, if you previously defined the tag 'elevate' then the smart-matching algorithm will detect 'elevator', 'elevated', 'elevating', and 'elevates'." Esmu sagraabstiijis shaadu, bet naspeeju ne noveerteet, ne paarbaudiit. --------------------------------------------------------------------- <?php /*Shii buus vaardniica, no kuras kaa key jādabuu normalizeeti atsleegvaardi, kas atbilst to sinoniimiem visaas formaas. Piemeers trim atsleegvaardiem:*/ $keysynonyms = array( "spēks" => array("spēk*", “spēc*”,"spar*",”stipr*”), "drosme" => array("drosm*", "bezbail*"), "nejēga"=> array("āmur*", "nepraš*")); /*Headspace funkciju Stem izmanto auto_suggest.php:*/ function Stem($word) { /*vaardus paarveido uz mazajiem burtiem*/ $word =strtoupper($word); /*ja ieejas vaarda garums ir mazaaks kaa iisaakajam atsleegvaardu sinoniimam, atgriezh neizmainiitu ieejas vaardu*/ if (strlen($word) <= 5) { return $word; } /*kaa key jaaizguust atbilstoshs normalizeets atsleegvaards (returning their keys)*/ if (($word = array_search($word, $keysynonyms)) !== FALSE) return $word; } ?> --------------------------------------------------------------------- Luudzu ieteikumus! Ivars Link to comment Share on other sites More sharing options...
Val Posted March 29, 2008 Report Share Posted March 29, 2008 komentārs ar mazajiem burtiem neiet kopā ar nākamo rindu :) => http://lv2.php.net/mb_strtolower Link to comment Share on other sites More sharing options...
none Posted March 29, 2008 Report Share Posted March 29, 2008 Kā arī šito strlen aizstāj ar šito mb_strlen. Citādi precīzu garumu nedabūsi. Link to comment Share on other sites More sharing options...
Recommended Posts