Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

lab6 / Aho_Corasick

.h
Скачиваний:
5
Добавлен:
05.02.2020
Размер:
731 б
Скачать
#ifndef AHO_CORASICK_H
#define AHO_CORASICK_H

#include <string>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>

using namespace std;
using lli = long long int;

struct Node {
	wstring pattern;
	pair<char, Node*> inEdge;
	map<char, Node*> outEdges;
	Node *failure, *output;

	Node(pair<char, Node*> inEdge): inEdge(inEdge), failure(nullptr), output(nullptr) {}
};

struct Trie {
	Node* root;

	Trie(set<wstring> patterns);

private:
	void makeLinks(Node* &node);
};


map<wstring, set<lli>> AhoCorasick(wstring &text, Trie &trie);
set<lli> AhoCorasickWithJoker(wstring &text, wstring &myTemplate, wchar_t joker);
set<wstring> split(wstring &myTemplate, char delim);

#endif
Соседние файлы в папке lab6