Czy ktoś widział/posiada klasę bądź ma pomysł jak generować słowa kluczowe na podstawie tekstu?
Sam napisałem taką metodę:
function generateKeywords($txt, $num=10) { //It works soooo bad $lngSpec = array("œ", "´", "", "ó", "π", "ŕ", "Ę", "∂", "ƒ", "˙", "˚", "∏", "˝", "ę", "ç", "∫", "ƒ", "ľ", "ë", "˙", "ü", "ď", "ä", "ę"); $latin = array("q", "e", "t", "o", "l", "a", "s", "d", "n", "k", "z", "l", "˝", "z", "c", "l", "n", "k", "d", "o", "u", "e", "a", "z"); //Put here 50-100 most freq. words for your language (use frequency dictionary) $frqWrds = array("si´", "i", "w", "nie", "na", "z", "do", "to", "˝e", "a", "o", "jak", "ale", "po", "co", "tak", "jest", "za", "od", "go", "ju˝", "jego", "jej", "tym", "mnie", "czy", "przez", "tylko", "by∏", "by∏o", "tego", "mi", "mu", "sobie", "jeszcze", "mo˝e", "ze", "kiedy", "pan", "ich", "dla", "by", "gdy", "teraz", "ja", "ten", "jŕ", "ma", "by∏a", "który", "nawet", "bardzo", "przed", "tu", "jednak", "pod", "coĘ", "tam", "wszystko", "przy", "wi´c", "nic", "bo", "nim", "powiedzia∏", "˝eby", "mia∏", "on", "byç", "tej", "b´dzie", "potem", "te˝", "które", "jeĘli", "ci", "bez", "sŕ", "niego", "nad", "gdzie", "pani", "lecz", "nas", "siebie", "nich", "je", "nigdy", "ani", "w∏aĘnie", "sam", "u", "mam", "te", "dobrze", "ni˝", "jestem", "jakby", "aby", "ty"); //Example for polish //$frqWrds = array("a", "able", "about", "about", "across", "act", "action", "activity", "actually", "add", "after", "after", "again", "against", "age", "agree", "all", "all", "allow", "almost", "already", "also", "although", "always", "among", "an", "and", "another", "any", "anything", "appear", "area", "around", "around", "as", "as", "as", "ask", "at", "authority", "available", "away", "back", "back", "bad", "bank", "be", "because", "become", "before", "before", "begin", "behind", "believe", "between", "big", "bit", "body", "book", "both", "both", "boy", "bring", "build", "building", "business", "but", "buy", "by", "call", "can", "car", "carry", "case", "centre", "century", "certain", "change", "change", "child", "church", "city", "class", "clear", "come", "committee", "community", "company", "condition", "consider", "continue", "control", "cost", "could", "council", "country", "course", "court", "create", "day", "death", "decide", "decision", "department", "describe", "develop", "development", "die", "different", "difficult", "do", "door", "down", "draw"); //Example for english $txt = str_ireplace($lngSpec, $latin, $txt); $txt = @str_ireplace($frqWrds, "", $txt); //Mute notice about no $frqWrds $i=0; foreach($kwds as $val) { $out[] = $val; $i++; if($i==$num)return $out; } }
Ale zgodnie z komentarzem działa no ... źle
