/** * @expectedException \Bigwhoop\SentenceBreaker\Rules\ConfigurationException * @expectedExceptionMessage Pattern T_WORD AA <T_EOF>: Token AA must exceed 2 characters. */ public function testInvalidTokenLength() { $ini = <<<INI [rules] T_WORD AA <T_EOF> = 100 INI; $config = new IniConfiguration($ini); $config->getRules(); }
/** * @param string $input * @param array $expectedResult * @param array $abbreviations */ private function runCalculateTest($input, array $expectedResult, array $abbreviations) { $lexer = new Lexer(); $tokens = $lexer->run($input); $rules = IniConfiguration::loadFile(__DIR__ . '/../../rules/rules.ini')->getRules(); $calc = new ProbabilityCalculator($rules); $calc->setAbbreviations(new Abbreviations($abbreviations)); $probabilities = $calc->calculate($tokens); $actual = []; foreach ($probabilities as $probability) { $token = $probability->getToken(); if ($token instanceof WordToken || $token instanceof CapitalizedWordToken || $token instanceof WhitespaceToken || $token instanceof EOFToken) { continue; } $actual[] = $token->getName() . ' ' . $probability->getProbability(); } $this->assertEquals($expectedResult, $actual); }
/** * @return Rules */ private function loadDefaultRules() { return IniConfiguration::loadFile(__DIR__ . '/../rules/rules.ini')->getRules(); }