labs-edaf30/lab2/dictionary.h

30 lines
816 B
C
Raw Normal View History

2024-11-21 08:50:09 +01:00
#pragma once
2021-10-27 15:15:47 +02:00
2024-11-20 17:46:21 +01:00
#include "word.h"
#include <filesystem>
2021-10-27 15:15:47 +02:00
#include <string>
#include <vector>
2024-11-20 19:11:48 +01:00
#define MAXLEN 30
2024-11-21 08:50:09 +01:00
// using std::vector;
2024-11-20 17:46:21 +01:00
using std::filesystem::path;
2021-10-27 15:15:47 +02:00
class Dictionary {
2024-11-20 17:46:21 +01:00
public:
Dictionary();
2024-11-21 08:50:09 +01:00
void add_trigram_suggestions(std::vector<std::string> &suggestions,
const std::string &word) const;
void rank_suggestions(std::vector<std::string> &suggestions,
const std::string &word) const;
void trim_suggestions(std::vector<std::string> &suggestions,
const std::string &word) const;
2024-11-20 17:46:21 +01:00
bool contains(const std::string &word) const;
std::vector<std::string> get_suggestions(const std::string &word) const;
int slurp(path p);
int spit(path p);
private:
2024-11-21 08:50:09 +01:00
std::vector<Word> words[MAXLEN];
2021-10-27 15:15:47 +02:00
};