ChartRuleLookupManagerMemory::ChartRuleLookupManagerMemory( const ChartParser &parser, const ChartCellCollectionBase &cellColl, const PhraseDictionaryMemory &ruleTable) : ChartRuleLookupManagerCYKPlus(parser, cellColl) , m_ruleTable(ruleTable) { UTIL_THROW_IF2(m_dottedRuleColls.size() != 0, "Dotted rule collection not correctly initialized"); size_t sourceSize = parser.GetSize(); m_dottedRuleColls.resize(sourceSize); const PhraseDictionaryNodeMemory &rootNode = m_ruleTable.GetRootNode(); for (size_t ind = 0; ind < m_dottedRuleColls.size(); ++ind) { #ifdef USE_BOOST_POOL DottedRuleInMemory *initDottedRule = m_dottedRulePool.malloc(); new (initDottedRule) DottedRuleInMemory(rootNode); #else DottedRuleInMemory *initDottedRule = new DottedRuleInMemory(rootNode); #endif DottedRuleColl *dottedRuleColl = new DottedRuleColl(sourceSize - ind + 1); dottedRuleColl->Add(0, initDottedRule); // init rule. stores the top node in tree m_dottedRuleColls[ind] = dottedRuleColl; } }
ChartRuleLookupManagerOnDisk::ChartRuleLookupManagerOnDisk( const ChartParser &parser, const ChartCellCollectionBase &cellColl, const PhraseDictionaryOnDisk &dictionary, OnDiskPt::OnDiskWrapper &dbWrapper, const std::vector<FactorType> &inputFactorsVec, const std::vector<FactorType> &outputFactorsVec) : ChartRuleLookupManagerCYKPlus(parser, cellColl) , m_dictionary(dictionary) , m_dbWrapper(dbWrapper) , m_inputFactorsVec(inputFactorsVec) , m_outputFactorsVec(outputFactorsVec) { UTIL_THROW_IF2(m_expandableDottedRuleListVec.size() != 0, "Dotted rule collection not correctly initialized"); size_t sourceSize = parser.GetSize(); m_expandableDottedRuleListVec.resize(sourceSize); for (size_t ind = 0; ind < m_expandableDottedRuleListVec.size(); ++ind) { DottedRuleOnDisk *initDottedRule = new DottedRuleOnDisk(m_dbWrapper.GetRootSourceNode()); DottedRuleStackOnDisk *processedStack = new DottedRuleStackOnDisk(sourceSize - ind + 1); processedStack->Add(0, initDottedRule); // init rule. stores the top node in tree m_expandableDottedRuleListVec[ind] = processedStack; } }
ChartRuleLookupManagerMemoryPerSentence::ChartRuleLookupManagerMemoryPerSentence( const ChartParser &parser, const ChartCellCollectionBase &cellColl, const PhraseDictionaryFuzzyMatch &ruleTable) : ChartRuleLookupManagerCYKPlus(parser, cellColl) , m_ruleTable(ruleTable) , m_softMatchingMap(StaticData::Instance().GetSoftMatches()) { size_t sourceSize = parser.GetSize(); size_t ruleLimit = parser.options()->syntax.rule_limit; m_completedRules.resize(sourceSize, CompletedRuleCollection(ruleLimit)); m_isSoftMatching = !m_softMatchingMap.empty(); }