AotMorphology::AotMorphology() { setupRml(); try { std::string strError; lemmatizer = new CLemmatizerRussian(); lemmatizer->m_bAllowRussianJo = true; lemmatizer->m_bMaximalPrediction = true; lemmatizer->m_bUseStatistic = true; #ifdef MSVC if (!lemmatizer->LoadDictionariesRegistry(strError)) throw MorphologyInitException( strError, __FILE__, 0 ); agramtab = new CRusGramTab(); if (!agramtab->LoadFromRegistry()) throw MorphologyInitException( "Couldn't load gramtab", __FILE__, 0 ); #else if (!lemmatizer->LoadDictionariesRegistry(strError)) throw MorphologyInitException( strError, __FILE__, __LINE__ ); agramtab = new CRusGramTab(); if (!agramtab->LoadFromRegistry()) throw MorphologyInitException( "Couldn't load gramtab", __FILE__, __LINE__ ); #endif } catch ( const MorphologyInitException & e ) { throw e; } catch ( const CExpc & e ) { throw MorphologyInitException( "Couldn't init morphology: " + e.m_strCause, __FILE__, 0 ); } catch (...) { throw MorphologyInitException( "Couldn't init morphology due to unknown error", __FILE__, 0 ); } }
void AotGraphan::analyzeString( const std::string & str, boost::ptr_vector<Unit> & units ) { setupRml(); try { CGraphmatFile file; if( !file.LoadDicts() ) { // Загружаем словари throw std::logic_error( file.GetLastError() ); } if( !file.LoadStringToGraphan( str ) ) { // Загружаем файл throw std::logic_error( file.GetLastError() ); } for( const CGraLine & line : file.GetUnits() ) { units.push_back( new Unit( line.GetToken(), line.GetTokenLength(), line.GetInputOffset(), line.IsWordOrNumberOrAbbr() ? Unit::WORD : line.IsPunct() ? Unit::PUNCT : Unit::UNKNOWN ) ); } } catch ( const std::exception & e ) { throw e; } catch ( const CExpc & e ) { throw std::logic_error( "Couldn't init morphology: " + e.m_strCause ); } catch (...) { throw std::logic_error( "Couldn't init morphology due to unknown error" ); } }