PHP code example of tokimikichika / text-analysis

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

    

tokimikichika / text-analysis example snippets


use Tokimikichika\TextAnalysis\TextAnalyzer;
use Tokimikichika\TextAnalysis\ResultFormatter;

$analyzer = new TextAnalyzer();
$text = "Hello world.\n\nAnother paragraph!";

$stats = [
    'words' => $analyzer->countWords($text),
    'characters' => $analyzer->countCharacters($text, true),
    'sentences' => $analyzer->countSentences($text),
    'paragraphs' => $analyzer->countParagraphs($text),
];

$formatter = new ResultFormatter();
$output = $formatter->format($stats);