test_morfeusz.cpp
1.24 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
/*
* File: test_morfeusz.cpp
* Author: mlenart
*
* Created on 14 listopad 2013, 15:50
*/
#include <cstdlib>
#include <cstdio>
#include <sstream>
#include <iostream>
#include "Morfeusz.hpp"
using namespace std;
void debug(const MorphInterpretation& interp) {
fprintf(stderr,
"%d %d %s %s %s %s\n",
interp.getStartNode(), interp.getEndNode(),
interp.getOrth(), interp.getLemma(),
interp.getTag(), interp.getName());
}
void doTest(
const Morfeusz& morfeusz,
const string& inputFilename) {
ifstream ifs;
// ifs.exceptions(std::ifstream::failbit | std::ifstream::badbit);
ifs.open(inputFilename, ios::binary);
string line;
while (getline(ifs, line)) {
AnalyzeResult res(morfeusz.analyze(line));
while (res.iterator != res.end) {
debug(*res);
res++;
}
}
validate(ifs.eof(), "Failed to read the input file to the end");
}
int main(int argc, char** argv) {
validate(argc == 3, "Must provide exactly two arguments - FSA filename, and input filename.");
string fsaFilename = argv[1];
string inputFilename = argv[2];
Morfeusz morfeusz(fsaFilename);
doTest(morfeusz, inputFilename);
return 0;
}