2017 © Pedro Peláez
 

library textstatistics

Get statistics from a given text

image

org_heigl/textstatistics

Get statistics from a given text

  • Monday, June 4, 2018
  • by heiglandreas
  • Repository
  • 2 Watchers
  • 3 Stars
  • 1,701 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Text-Statistics

Calculate text-statistics including Sylables, Flesch-Reading-Ease (english and german) and such things., (*1)

Build Status Scrutinizer Code Quality Code Climate StyleCI Coverage Status, (*2)

Latest Stable Version Total Downloads License composer.lock, (*3)

Why

The one other implementation davechild/textstatistics sadly only implements statistics for english texts. That sadly didn't work for texts with f.e. german umlauts. So I decided to implement some of the algorithms again using work I already did for a hyphenator., (*4)

That's why f.e. the syllable-calculation differs., (*5)

Installation

TextStatistics is best installed using composer, (*6)

$ composer require org_heigl/textstatistics

Usage

The different Calculators all implement a common CalculatorInterface and therefore all provide a calculate-Method that expects a Text-Object containing the Text to be calculated., (*7)

Currently these Statistics are avalable:, (*8)

  • Average Sentence Length
  • Average Syllables per word
  • Character-Count (including Whitespace)
  • Character-Count (excluding whitespace)
  • Flesch-Kincaid Grade Level
  • Flesch-Reading-Ease for English texts
  • Flesch-Reading-Ease for German texts
  • Flesch-Reading-Ease School-Grade measurement
  • Sentence-Count
  • Max Syllables in Sentence
  • Max Words in Sentence
  • Syllable-Count
  • Wiener Sachtext-Formel 1, 2, 3 and 4
  • Word-Count
  • Max Syllables in Word
  • Number of words with minimum N characters
  • Percentage of Words with minimum N characters
  • Number of words with minimum N syllables
  • Percentage of words with minimum N syllables
  • Number of words with only N syllables
  • Percentage of words with only N syllables

There are Factory-Methods for each statistic available, so getting one of the statistics requires the following line of code:, (*9)

$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);

You can also add multiple Calculators to the TextStatisticsGenerator and retrieve multiple Statistics in one go like this:, (*10)

$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,
// )

The Versions

04/06 2018

dev-master

9999999-dev

Get statistics from a given text

  Sources   Download

MIT

The Requires

 

The Development Requires

04/06 2018

dev-fixWordCounter

dev-fixWordCounter

Get statistics from a given text

  Sources   Download

MIT

The Requires

 

The Development Requires

16/02 2018

0.2.1

0.2.1.0

Get statistics from a given text

  Sources   Download

MIT

The Requires

 

The Development Requires

16/02 2018

0.2.0

0.2.0.0

Get statistics from a given text

  Sources   Download

MIT

The Requires

 

The Development Requires

21/03 2017

0.1.1

0.1.1.0

Get statistics from a given text

  Sources   Download

MIT

The Requires

 

The Development Requires

21/03 2017

dev-addPhpcs

dev-addPhpcs

Get statistics from a given text

  Sources   Download

MIT

The Requires

 

The Development Requires

21/03 2017

dev-fix/3

dev-fix/3

Get statistics from a given text

  Sources   Download

MIT

The Requires

 

The Development Requires

20/03 2017

0.1.0

0.1.0.0

Get statistics from a given text

  Sources   Download

MIT

The Requires

 

The Development Requires