main.cpp
1.37 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
55
/*
* File: main.cc
* Author: mlenart
*
* Created on October 8, 2013, 12:41 PM
*/
#include <cstdlib>
#include <iostream>
#include <vector>
#include "fsa/fsa.hpp"
#include "Tagset.hpp"
#include "Morfeusz.hpp"
#include "const.hpp"
using namespace std;
int main(int argc, char** argv) {
Morfeusz morfeusz;
#ifdef _WIN32
morfeusz.setEncoding(CP852);
#endif
#ifdef _WIN64
morfeusz.setEncoding(CP852);
#endif
string line;
while (getline(cin, line)) {
// printf("%s\n", line.c_str());
vector<MorphInterpretation> res;
morfeusz.analyze(line, res);
int prevStart = -1;
int prevEnd = -1;
printf("[");
for (unsigned int i = 0; i < res.size(); i++) {
MorphInterpretation& mi = res[i];
if (prevStart != -1
&& (prevStart != mi.getStartNode() || prevEnd != mi.getEndNode())) {
printf("]\n[");
} else if (prevStart != -1) {
printf("; ");
}
printf("%d,%d,%s,%s,%s,%s",
mi.getStartNode(), mi.getEndNode(),
mi.getOrth().c_str(), mi.getLemma().c_str(),
mi.getTag().c_str(), mi.getName().c_str());
prevStart = mi.getStartNode();
prevEnd = mi.getEndNode();
}
printf("]\n");
}
printf("\n");
return 0;
}