-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.cpp
More file actions
54 lines (42 loc) · 1.3 KB
/
main.cpp
File metadata and controls
54 lines (42 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* @file main.cpp
* @brief The example of MAnalyzer using.
*/
#include <vector>
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdlib>
#include "analyzer/word_infos.h"
#include "analyzer/analyzer.h"
int main()
{
Analyzer * analyzer = analyzer_new("dics_ru");
WordInfos * wi = infos_new(1024);
std::ifstream input("dics_ru/gramtab");
std::vector <std::string> gramtab;
int num;
std::string id, info;
while(input >> num >> id >> info)
gramtab.push_back(info);
std::string word;
char * buffer = (char *) malloc(sizeof(char) * 1024);
while(std::cin >> word)
{
strcpy(buffer, word.c_str());
analyzer_get_word_info(analyzer, buffer, word.size(), wi);
#ifndef MANALYZER_DEBUG
std::cout << infos_get_size(wi) << " (prediction = " << infos_is_prediction(wi) << "):\n";
for(int i = 0; i < infos_get_size(wi); i++)
std::cout << "\t" << buffer <<
" " << gramtab[infos_get_form_id(wi, i) - 1] << " -> " <<
infos_get_normal_form(wi, i) <<
" " << gramtab[infos_get_normal_form_id(wi, i) - 1] << "\n";
#endif
infos_erase(wi);
}
free(buffer);
infos_free(wi);
analyzer_free(analyzer);
return 0;
}