34 lines
		
	
	
	
		
			924 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
	
		
			924 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #pragma once
 | |
| 
 | |
| #include <string>
 | |
| #include <vector>
 | |
| 
 | |
| /*
 | |
|  * Contains a word and its triagrams
 | |
|  */
 | |
| class Word {
 | |
|   public:
 | |
|     /** Creates a word w with the sorted trigrams t */
 | |
|     Word(const std::string &w, const std::vector<std::string> &t);
 | |
| 
 | |
|     /** Creates a word w and derives the triagrams internally */
 | |
|     Word(const std::string &w);
 | |
| 
 | |
|     /** Returns the word */
 | |
|     std::string get_word() const;
 | |
| 
 | |
|     /** Returns triagrams */
 | |
|     std::vector<std::string> get_triagrams() const;
 | |
| 
 | |
|     /** Returns how many of the trigrams in t that are present
 | |
|      in this word's trigram vector */
 | |
|     unsigned int get_matches(const std::vector<std::string> &t) const;
 | |
| 
 | |
|   private:
 | |
|     const std::string word;
 | |
|     std::vector<std::string> triagrams;
 | |
|     friend std::ostream &operator<<(std::ostream &out, const Word &o);
 | |
|     friend bool operator==(const Word &lhs, const Word &rhs);
 | |
| };
 | |
| 
 | |
| bool operator==(const Word &lhs, const Word &rhs);
 | 
