/** * Get properties for current token. * * @param POSRegistry $registry * @param LimelightWord|bool $previousWord * @param array $previous * @param array $current * @param array $next * * @return array */ private function getProperties(POSRegistry $registry, $previousWord, $previous, $current, $next) { $className = ucfirst($current['partOfSpeech1']); $POSClass = $registry->getClass($className); $properties = $POSClass->handle($this->defaults, $previousWord, $previous, $current, $next); return $properties; }
/** * @test */ public function it_sets_a_class_in_the_registry_and_gets_same() { $registry = POSRegistry::getInstance(); $class1 = $registry->getClass('Meishi'); $hash1 = spl_object_hash($class1); $class2 = $registry->getClass('Meishi'); $hash2 = spl_object_hash($class1); $this->AssertEquals($hash1, $hash2); }
/** * Handle the parsing request. * * @param array $properties * @param array $previousWord [previous word] * @param array $previous [previous token] * @param array $current [current token] * @param array $next [next token] * * @return array */ public function handle(array $properties, $previousWord, $previous, array $current, $next) { $properties['partOfSpeech'] = 'noun'; $registry = POSRegistry::getInstance(); if (array_key_exists($current['partOfSpeech2'], $this->overrides)) { $className = 'Meishi' . ucfirst($this->overrides[$current['partOfSpeech2']]); } else { $className = 'Meishi' . ucfirst($current['partOfSpeech2']); } if (class_exists('Limelight\\Parse\\PartOfSpeech\\Classes\\' . $className)) { $POSClass = $registry->getClass($className); $properties = $POSClass->handle($properties, $previousWord, $previous, $current, $next); } return $properties; }