PHP code example of org_heigl / textstatistics

1. Go to this page and download the library: Download org_heigl/textstatistics 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/ */

    

org_heigl / textstatistics example snippets


$text = new \Org_Heigl\TextStatistics\Text($theText);
$wordCount =\Org_Heigl\TextStatistics\Service\WordCounterFactory::getCalculator()->calculate($text);
$fleschReadingEase = /Org_Heigl\TextStatistics\Service\FleschReadingEaseCalculatorFactory::getCalculator()->calculate($text);

$text = new \Org_Heigl\TextStatistics\Text($theText);

$statGenerator = new \Org_Heigl\TextStatistics\TextSTatisticsGenerator();
$statGenerator->add('wordCount', \Org_Heigl\TextStatistics\Service\WordCounterFactory::getCalculator());
$statGenerator->add('flesch', \Org_Heigl\TextStatistics\Service\FleschReadingEaseCalculatorFactory::getCalculator());

print_R($statGenerator->calculate($text));

// array(
//    'wordCount' => xx,
//    'flesch' => yy,
// )