labs-edaf30/lab2/word.h

35 lines
922 B
C
Raw Normal View History

2024-11-20 17:46:21 +01:00
#pragma once
2021-10-27 15:15:47 +02:00
#include <string>
#include <vector>
2024-11-20 17:46:21 +01:00
/*
* Contains a word and its triagrams
*/
2021-10-27 15:15:47 +02:00
class Word {
2024-11-20 17:46:21 +01:00
public:
/** Creates a word w with the sorted trigrams t */
Word(const std::string &w, const std::vector<std::string> &t);
2024-11-21 07:48:45 +01:00
/** Creates a word w and derives the triagrams internally */
Word(const std::string &w);
2024-11-20 17:46:21 +01:00
/** Returns the word */
std::string get_word() const;
2021-10-27 15:15:47 +02:00
2024-11-21 08:47:45 +01:00
/** Returns triagrams */
std::vector<std::string> get_triagrams() const;
2024-11-20 17:46:21 +01:00
/** 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;
2024-11-20 19:11:48 +01:00
std::vector<std::string> triagrams;
2024-11-20 17:46:21 +01:00
friend std::ostream &operator<<(std::ostream &out, const Word &o);
2024-11-21 07:48:45 +01:00
friend bool operator==(const Word &lhs, const Word &rhs);
2024-11-20 17:46:21 +01:00
};
2024-11-21 07:48:45 +01:00
bool operator==(const Word &lhs, const Word &rhs);