예제 #1
0
 static function instance(phpMorphy_MorphyInterface $morphy)
 {
     $key = $morphy->getEncoding();
     if (!isset(self::$instances[$key])) {
         $class = __CLASS__;
         self::$instances[$key] = new $class($key);
     }
     return self::$instances[$key];
 }
예제 #2
0
 static function create(phpMorphy_MorphyInterface $morphy)
 {
     $locale = strtolower($morphy->getLocale());
     if (!isset(self::$included[$locale])) {
         $class = "phpMorphy_GrammemsProvider_{$locale}";
         if (!class_exists($class)) {
             self::$included[$locale] = call_user_func(array($class, 'instance'), $morphy);
         } else {
             self::$included[$locale] = new phpMorphy_GrammemsProvider_Empty($morphy);
         }
     }
     return self::$included[$locale];
 }
 /**
  * @param string $word
  * @return phpMorphy_Paradigm_ParadigmInterface[]
  */
 protected function findWordMorphy($word)
 {
     if (false !== ($paradigms = $this->morphy->findWord($this->toMorphyEncoding($word), phpMorphy::IGNORE_PREDICT))) {
         $result = array();
         foreach ($paradigms as $paradigm) {
             $result[] = $this->normalizeMorphyParadigmEncoding($paradigm);
         }
         return $result;
     }
     return false;
 }
예제 #4
0
 protected function assertPredictedBySuffix()
 {
     $this->assertEquals(phpMorphy::PREDICT_BY_DB, $this->morphy->getLastPredictionType(), "Expect for prediction by suffix");
 }
예제 #5
0
 /**
  * @param phpMorphy_MorphyInterface $morphy
  * @return phpMorphy_Dict_Source_Mutable
  */
 protected function createMutableSource(phpMorphy_MorphyInterface $morphy)
 {
     $source = new phpMorphy_Dict_Source_Mutable();
     $source->setLanguage($morphy->getLocale());
     return $source;
 }