diff options
Diffstat (limited to 'extractor/data_array.cc')
-rw-r--r-- | extractor/data_array.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/extractor/data_array.cc b/extractor/data_array.cc index ac0493fd..9612aa8a 100644 --- a/extractor/data_array.cc +++ b/extractor/data_array.cc @@ -90,6 +90,18 @@ string DataArray::GetWordAtIndex(int index) const { return id2word[data[index]]; } +vector<int> DataArray::GetWordIds(int index, int size) const { + return vector<int>(data.begin() + index, data.begin() + index + size); +} + +vector<string> DataArray::GetWords(int start_index, int size) const { + vector<string> words; + for (int word_id: GetWordIds(start_index, size)) { + words.push_back(id2word[word_id]); + } + return words; +} + int DataArray::GetSize() const { return data.size(); } |