summaryrefslogtreecommitdiff
path: root/extractor/phrase.cc
diff options
context:
space:
mode:
authorPaul Baltescu <pauldb89@gmail.com>2013-02-01 16:11:10 +0000
committerPaul Baltescu <pauldb89@gmail.com>2013-02-01 16:11:10 +0000
commit0a53f7eca74c165b5ce1c238f1999ddf1febea55 (patch)
tree5a5231767bc2f92203711ab4aee75336b8bc2175 /extractor/phrase.cc
parent5530575ae0ad939e17f08d6bd49978acea388ab7 (diff)
Second working commit.
Diffstat (limited to 'extractor/phrase.cc')
-rw-r--r--extractor/phrase.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/extractor/phrase.cc b/extractor/phrase.cc
index f9bd9908..6dc242db 100644
--- a/extractor/phrase.cc
+++ b/extractor/phrase.cc
@@ -23,3 +23,32 @@ vector<int> Phrase::Get() const {
int Phrase::GetSymbol(int position) const {
return symbols[position];
}
+
+int Phrase::GetNumSymbols() const {
+ return symbols.size();
+}
+
+vector<string> Phrase::GetWords() const {
+ return words;
+}
+
+int Phrase::operator<(const Phrase& other) const {
+ return symbols < other.symbols;
+}
+
+ostream& operator<<(ostream& os, const Phrase& phrase) {
+ int current_word = 0;
+ for (size_t i = 0; i < phrase.symbols.size(); ++i) {
+ if (phrase.symbols[i] < 0) {
+ os << "[X," << -phrase.symbols[i] << "]";
+ } else {
+ os << phrase.words[current_word];
+ ++current_word;
+ }
+
+ if (i + 1 < phrase.symbols.size()) {
+ os << " ";
+ }
+ }
+ return os;
+}