Добавил:
itan_hunt
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:lab6 / main
.cpp#include "Aho_Corasick.h"
#include "unit_testing.h"
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <string.h>
#include <locale>
using namespace std;
int main(int argc, char const *argv[]) {
locale::global(locale(""));
if (argc == 2) {
if (!strcmp("-ac", argv[1])) {
wstring text, buffer;
set<wstring> patterns;
wcin >> text;
for(lli i = (wcin >> i, i); i > 0; i--) {
patterns.emplace((wcin >> buffer, buffer));
}
Trie trie(patterns);
map<wstring, set<lli>> solutions = AhoCorasick(text, trie);
for(auto &solution:solutions) {
wcout << solution.first << L" ";
for(auto &patternIndex: solution.second) {
wcout << patternIndex << L" ";
}
wcout << endl;
}
} else if (!strcmp("-joker", argv[1])) {
wstring text, myTemplate;
wchar_t joker;
wcin >> text;
wcin >> myTemplate;
wcin >> joker;
set<lli> templateEntries = AhoCorasickWithJoker(text, myTemplate, joker);
for(auto &entry: templateEntries)
wcout << entry << endl;
} else if (!strcmp("-test", argv[1])) {
runUnitTestingLabAhoCorasick();
}
} else {
wcout << L"You forgot a flag or input more than one flag or your flag is incorrect.\n"
"Don't worry.\nRead README.txt and try again." << endl;
}
return 0;
}
Соседние файлы в папке lab6