#include "word.h" #include #include #include using std::string; using std::vector; Word::Word(const string &w, const vector &t) : word(w), triagrams(t) { std::sort(triagrams.begin(), triagrams.end()); } string Word::get_word() const { return string(); } unsigned int Word::get_matches(const vector &t) const { unsigned int matches = 0; for (const auto &triagram : t) { if (std::binary_search(triagrams.begin(), triagrams.end(), triagram)) { ++matches; } } return matches; } std::ostream &operator<<(std::ostream &out, const Word &w) { auto space = string(" "); out << w.word; out << space; for (const auto &tria : w.triagrams) { out << space << tria; } return out; }