Morfeusz.cpp
1.19 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
/*
* File: Morfeusz.cpp
* Author: mlenart
*
* Created on November 13, 2013, 5:21 PM
*/
#include <string>
#include "utils.hpp"
#include "Morfeusz.hpp"
#include "MorphDeserializer.hpp"
#include "encoding/CharsetConverter.hpp"
using namespace std;
static FSA<vector<EncodedInterpretation>>* initializeFSA(const string& filename) {
static Deserializer<vector<EncodedInterpretation>>* deserializer
= new MorphDeserializer();
return FSA<vector<EncodedInterpretation>>::getFSA(filename, *deserializer);
}
static CharsetConverter* initializeCharsetConverter() {
static CharsetConverter* converter = new UTF8CharsetConverter();
return converter;
}
Morfeusz::Morfeusz(const string& filename)
: fsa(initializeFSA(filename)), charsetConverter(initializeCharsetConverter()) {
}
//Morfeusz::Morfeusz(const Morfeusz& orig) {
//}
Morfeusz::~Morfeusz() {
delete &this->fsa;
}
AnalyzeResult Morfeusz::analyze(const std::string& text) {
const char* textStart = text.c_str();
const char* textEnd = text.c_str() + text.length();
AnalyzeResult res = {
ResultsIterator(textStart, textEnd, *this),
ResultsIterator(textEnd, textEnd, *this)};
return res;
}