| @@ 34-51 (lines=18) @@ | ||
| 31 | use Org_Heigl\TextStatistics\Calculator\CachingSyllableCounter; |
|
| 32 | use Org_Heigl\TextStatistics\Util\SyllableFilter; |
|
| 33 | ||
| 34 | class SyllableCounterFactory |
|
| 35 | { |
|
| 36 | public static function getCalculator($locale = 'de_DE') |
|
| 37 | { |
|
| 38 | $o = new Options(); |
|
| 39 | $o->setDefaultLocale($locale) |
|
| 40 | ->setRightMin(2) |
|
| 41 | ->setLeftMin(2) |
|
| 42 | ->setWordMin(4) |
|
| 43 | ->setTokenizers('Whitespace, Punctuation'); |
|
| 44 | ||
| 45 | $hyphenator = new Hyphenator(); |
|
| 46 | $hyphenator->setOptions($o); |
|
| 47 | $hyphenator->addFilter(new SyllableFilter()); |
|
| 48 | ||
| 49 | return new CachingSyllableCounter($hyphenator); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| @@ 35-52 (lines=18) @@ | ||
| 32 | use Org_Heigl\TextStatistics\Calculator\CachingWordsWithNSyllablesOnlyCounter; |
|
| 33 | use Org_Heigl\TextStatistics\Util\WordsWithNSyllablesFilter; |
|
| 34 | ||
| 35 | class WordsWithNSyllablesCounterFactory |
|
| 36 | { |
|
| 37 | public static function getCalculator($locale = 'de_DE', $minSyllables = 3) |
|
| 38 | { |
|
| 39 | $o = new Options(); |
|
| 40 | $o->setDefaultLocale($locale) |
|
| 41 | ->setRightMin(2) |
|
| 42 | ->setLeftMin(2) |
|
| 43 | ->setWordMin(4) |
|
| 44 | ->setTokenizers('Whitespace, Punctuation'); |
|
| 45 | ||
| 46 | $hyphenator = new Hyphenator(); |
|
| 47 | $hyphenator->setOptions($o); |
|
| 48 | $hyphenator->addFilter(new WordsWithNSyllablesFilter($minSyllables)); |
|
| 49 | ||
| 50 | return new CachingWordsWithNSyllablesCounter($hyphenator); |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| @@ 34-51 (lines=18) @@ | ||
| 31 | use Org_Heigl\TextStatistics\Calculator\CachingWordsWithNSyllablesOnlyCounter; |
|
| 32 | use Org_Heigl\TextStatistics\Util\WordsWithNSyllablesOnlyFilter; |
|
| 33 | ||
| 34 | class WordsWithNSyllablesOnlyCounterFactory |
|
| 35 | { |
|
| 36 | public static function getCalculator($locale = 'de_DE', $syllables = 1) |
|
| 37 | { |
|
| 38 | $o = new Options(); |
|
| 39 | $o->setDefaultLocale($locale) |
|
| 40 | ->setRightMin(2) |
|
| 41 | ->setLeftMin(2) |
|
| 42 | ->setWordMin(4) |
|
| 43 | ->setTokenizers('Whitespace, Punctuation'); |
|
| 44 | ||
| 45 | $hyphenator = new Hyphenator(); |
|
| 46 | $hyphenator->setOptions($o); |
|
| 47 | $hyphenator->addFilter(new WordsWithNSyllablesOnlyFilter($syllables)); |
|
| 48 | ||
| 49 | return new CachingWordsWithNSyllablesOnlyCounter($hyphenator); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||