wordID_t Vocab::GetWordID(const std::string& word_str) { FactorList factors; factors.push_back(0); Word word; word.CreateFromString(Input, factors, word_str, false); return GetWordID(word); }
std::string Word::GetString(const FactorList &factorTypes) const { assert(factorTypes.size()); std::stringstream ret; ret << m_factors[factorTypes[0]]->GetString(); for (size_t i = 1; i < factorTypes.size(); ++i) { FactorType factorType = factorTypes[i]; ret << "|" << m_factors[factorType]; } return ret.str(); }
const Word Vocab::InitSpecialWord( const std::string& word_str) { FactorList factors; factors.push_back(0); // store the special word string as the first factor Word word; // define special word as Input word with one factor and isNonTerminal=false word.CreateFromString( Input, factors, word_str, false ); // Input is enum defined in ../typedef.h // TODO not sure if this will work properly: // - word comparison can fail because the last parameter (isNonTerminal) // in function CreateFromString may not match properly created words // - special word is Input word but what about Output words? // - currently Input/Output variable is not stored in class Word, but in the future??? return word; }
void PhraseBoundaryFeature::AddFeatures( const Word* leftWord, const Word* rightWord, const FactorList& factors, const string& side, ScoreComponentCollection* scores) const { for (size_t i = 0; i < factors.size(); ++i) { ostringstream name; name << side << ":"; name << factors[i]; name << ":"; if (leftWord) { name << leftWord->GetFactor(factors[i])->GetString(); } else { name << BOS_; } name << ":"; if (rightWord) { name << rightWord->GetFactor(factors[i])->GetString(); } else { name << EOS_; } scores->PlusEquals(this,name.str(),1); } }
bool Vocab::Load(FileHandler* vcbin) { FactorList factors; factors.push_back(0); return Load(vcbin, Input, factors); }