Add util for querying on-disk pt

This commit is contained in:
Hieu Hoang 2012-05-15 16:03:40 +01:00
parent 1ef0d6b7f6
commit d924a709ea
3 changed files with 19 additions and 4 deletions

View File

@ -196,6 +196,12 @@ void TargetPhraseCollection::SetDebugStr(const std::string &str)
m_debugStr = str;
}
const TargetPhrase &TargetPhraseCollection::GetTargetPhrase(size_t ind) const
{
assert(ind < GetSize());
return *m_coll[ind];
}
}

View File

@ -64,6 +64,9 @@ public:
size_t GetSize() const {
return m_coll.size();
}
const TargetPhrase &GetTargetPhrase(size_t ind) const;
UINT64 GetFilePos() const;
Moses::TargetPhraseCollection *ConvertToMoses(const std::vector<Moses::FactorType> &inputFactors

View File

@ -41,9 +41,7 @@ void Tokenize(OnDiskPt::Phrase &phrase
if (splitPos == string::npos) {
// lhs - only 1 word
Word *word = new Word();
cerr << "WORD " << *word << " ";
word->CreateFromString(wordStr, onDiskWrapper.GetVocab());
cerr << *word << endl;
phrase.AddWord(word);
} else {
// source & target non-terms
@ -103,8 +101,10 @@ int main(int argc, char **argv)
std::string line;
while(getline(std::cin, line)) {
std::vector<std::string> tokens;
tokens = Moses::Tokenize(line);
tokens = Moses::Tokenize(line, " ");
cerr << "line: " << line << endl;
// create source phrase
SourcePhrase sourcePhrase;
@ -144,7 +144,13 @@ int main(int argc, char **argv)
{ // source phrase points to something
const TargetPhraseCollection *coll = node->GetTargetPhraseCollection(TABLE_LIMIT, onDiskWrapper);
string str = coll->GetDebugStr();
cout << "Found" << str << endl;
cout << "Found" << coll->GetSize() << endl;
for (size_t ind = 0; ind < coll->GetSize(); ++ind)
{
const TargetPhrase &targetPhrase = coll->GetTargetPhrase(ind);
cerr << " ** " << targetPhrase << endl;
}
}
else
{