mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-30 23:42:30 +03:00
add GetVocabIds()
This commit is contained in:
parent
73ac4e43cb
commit
30bd411e17
@ -8,6 +8,7 @@
|
||||
#include <string>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include "../OutputFileStream.h"
|
||||
#include "../Util2.h"
|
||||
|
||||
namespace Moses2
|
||||
{
|
||||
@ -41,6 +42,20 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<VOCABID> GetVocabIds(const std::string &line)
|
||||
{
|
||||
std::vector<std::string> toks = Moses2::Tokenize(line, " ");
|
||||
std::vector<VOCABID> ret(toks.size());
|
||||
|
||||
for (size_t i = 0; i < toks.size(); ++i) {
|
||||
const std::string &tok = toks[i];
|
||||
VOCABID id = GetVocabId(tok);
|
||||
ret[i] = id;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Save()
|
||||
{
|
||||
OutputFileStream strme(m_path);
|
||||
|
Loading…
Reference in New Issue
Block a user