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]; }
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; }
protected function assertPredictedBySuffix() { $this->assertEquals(phpMorphy::PREDICT_BY_DB, $this->morphy->getLastPredictionType(), "Expect for prediction by suffix"); }
/** * @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; }