42 lines
976 B
C++
42 lines
976 B
C++
#ifndef TOKEN_H
|
|
#define TOKEN_H
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <map>
|
|
|
|
class Tokenizer {
|
|
public:
|
|
std::map<std::string, int> wordToId;
|
|
std::map<int, std::string> idToWord;
|
|
|
|
Tokenizer() {
|
|
add("<EOS>"); // 0
|
|
add("[SYS]"); // 1
|
|
add("[USER]"); // 2
|
|
add("[AI]"); // 3
|
|
add(" "); // 4
|
|
add("\n"); // 5
|
|
add("привет"); // 6
|
|
add("как"); // 7
|
|
add("дела"); // 8
|
|
add("?"); // 9
|
|
add("я"); // 10
|
|
add("робот"); // 11
|
|
add("хорошо"); // 12
|
|
}
|
|
|
|
void add(std::string word);
|
|
int getID(std::string word);
|
|
std::string getWord(int id);
|
|
std::vector<int> textToTokens(const std::string& text);
|
|
};
|
|
|
|
class Embedder {
|
|
public:
|
|
std::vector<std::vector<double>> matrix;
|
|
Embedder(int vSize, int dim);
|
|
std::vector<double> get(int id);
|
|
};
|
|
|
|
#endif |