PHP code example of gribanov / analyzer-text

1. Go to this page and download the library: Download gribanov/analyzer-text library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gribanov / analyzer-text example snippets


$text = '...'; // некоторый текст
$text_obj = new \AnalyzeText\Text($text);
// @var $word \AnalyzeText\Text\Word
$word = $text_obj->current();

$frequency = new Frequency();
$frequency->setText(new Text($text));

// анализируем весь список слов
$graph = array_slice(array_merge_recursive($frequency->getFrequency(), $frequency->getPercent()), 0, 20);

// фильтруем и получаем только информационные слова
$frequency->applyFilters()->Informative();
$graph_filter = array_slice(array_merge_recursive($frequency->getFrequency(), $frequency->getPercent()), 0, 20);

$i = $ii = 1000;
$start = microtime(1);
while ($i--) {
    $frequency = new Frequency();
    $frequency->setText(new Text($text))->applyFilters()->Informative();
    $frequency->getFrequency();
    $frequency->getPercent();
}
echo (microtime(1) - $start) / $ii;