/** * Возвращает ключевые слова для заданного текста * @param string $text * @return string */ public static function getKeywords($text) { self::includeFile('includes/keywords.inc.php'); $params['content'] = $text; //page content $params['min_word_length'] = 5; //minimum length of single words $params['min_word_occur'] = 2; //minimum occur of single words $params['min_2words_length'] = 5; //minimum length of words for 2 word phrases $params['min_2words_phrase_length'] = 10; //minimum length of 2 word phrases $params['min_2words_phrase_occur'] = 2; //minimum occur of 2 words phrase $params['min_3words_length'] = 5; //minimum length of words for 3 word phrases $params['min_3words_phrase_length'] = 10; //minimum length of 3 word phrases $params['min_3words_phrase_occur'] = 2; //minimum occur of 3 words phrase $keyword = new autokeyword($params, "UTF-8"); return $keyword->get_keywords(); }
$righe = $db->conta($query); // Se la sezione esiste la prelevo if ($righe > 0) { while ($riga = $db->estrai($query)) { $titolo = $func->rescape($riga->titolo); $contenuto = bbcode($func->rescape($riga->contenuto)); } $description = autodescription($contenuto, 120); // Descrizione di 120 caratteri $setkeyword['content'] = $contenuto; // Testo $setkeyword['min_word_length'] = 5; // Caratteri minimi singola keyword $setkeyword['min_word_occur'] = 2; // Presenza delle parole nel testo perchè diventino keyword $setkeyword = new autokeyword($setkeyword, "iso-8859-1"); $keyword = $setkeyword->parse_words(); // Visualizzo la pagina $smarty->assign("titolo", $titolo . ' » ' . $cms->nomesito()); // Titolo della pagina $smarty->assign("contenuto", $contenuto); // Il contenuto della sezione $smarty->assign("description", $description); // La descrizione $smarty->assign("keywords", $keyword); // Le keywords $smarty->assign("numsezioni", $db->numsezioni()); // Numero sezioni $smarty->assign("numnews", $db->numnews()); // Numero news $smarty->assign("numutenti", $db->numutenti());
function keywords($input, $minimo, $fonte, $class) { $params['content'] = $input; //page content $params['font'] = $fonte; $params['class'] = $class; //set the length of keywords you like $params['min_word_length'] = 3; //minimum length of single words $params['min_word_occur'] = $minimo; //minimum occur of single words $params['min_2words_length'] = 5; //minimum length of words for 2 word phrases $params['min_2words_phrase_length'] = 30; //minimum length of 2 word phrases $params['min_2words_phrase_occur'] = 20; //minimum occur of 2 words phrase $params['min_3words_length'] = 5; //minimum length of words for 3 word phrases $params['min_3words_phrase_length'] = 30; //minimum length of 3 word phrases $params['min_3words_phrase_occur'] = 20; //minimum occur of 3 words phrase $keyword = new autokeyword($params, "UTF-8"); echo $keyword->parse_words(); }
function runUpdate($id) { echo "Updating Keywords For Product ID: " . $id; //echo ("Updating for $id" . $this->lineBreak); $hop = "http://" . $this->clickbankID . "." . $id . ".hop.clickbank.net"; $hop = $this->get_final_url($hop); //$hop = "http://chrisqueen.com/CB/" . $id; //set the length of keywords you like $params['min_word_length'] = 5; //minimum length of single words $params['min_word_occur'] = 2; //minimum occur of single words $params['min_2words_length'] = 3; //minimum length of words for 2 word phrases $params['min_2words_phrase_length'] = 10; //minimum length of 2 word phrases $params['min_2words_phrase_occur'] = 2; //minimum occur of 2 words phrase $params['min_3words_length'] = 3; //minimum length of words for 3 word phrases $params['min_3words_phrase_length'] = 10; //minimum length of 3 word phrases $params['min_3words_phrase_occur'] = 2; //minimum occur of 3 words phrase $autokeyword = new autokeyword($hop, $params); $words = array(); // add meta keywords from page $metaKeywordsArray = explode(",", $autokeyword->getMetaKeywords()); array_splice($words, count($words), 0, $metaKeywordsArray); array_splice($words, count($words), 0, $autokeyword->parse_words()); array_splice($words, count($words), 0, $autokeyword->parse_2words()); array_splice($words, count($words), 0, $autokeyword->parse_3words()); $words = array_unique($words); $finalWords = array(); // Remove Numbers foreach ($words as $word) { $word = trim($word); if (!is_numeric($word) && strlen($word) > 2) { $finalWords[] = $word; } } if (count($finalWords) > 0 && strlen($id) > 0) { //$keywordQuery = "REPLACE INTO keywords (id,words) VALUES ('$id','" . json_encode ( $finalWords ) . "');"; $keywordQuery = "'{$id}','" . json_encode($finalWords) . "'"; $this->waitForLockAndWrite($this->updateDBQueryFilename, $keywordQuery); //$this->getLogger ()->logInfo ( "Query for $id: Added!" ); } else { echo "No content for {$id} <br>"; $query = "Insert into BadIDs (id) values ('{$id}') on duplicate key update count=count+1;"; $this->runQuery($query, $this->getDBConnection()->getDBConnection()); } }