-
Notifications
You must be signed in to change notification settings - Fork 10
/
LinearSegmentor.h
81 lines (54 loc) · 1.67 KB
/
LinearSegmentor.h
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* Segmentor.h
*
* Created on: Jan 25, 2016
* Author: mszhang
*/
#ifndef SRC_PARSER_H_
#define SRC_PARSER_H_
#include "N3L.h"
#include "LinearBeamSearcher.h"
#include "Options.h"
#include "Pipe.h"
#include "Utf.h"
using namespace nr;
using namespace std;
class Segmentor {
public:
std::string nullkey;
std::string rootdepkey;
std::string unknownkey;
std::string paddingtag;
std::string seperateKey;
public:
Segmentor();
virtual ~Segmentor();
public:
#if USE_CUDA==1
LinearBeamSearcher<gpu> m_classifier;
#else
LinearBeamSearcher<cpu> m_classifier;
#endif
Options m_options;
Pipe m_pipe;
public:
void readWordEmbeddings(const string& inFile, NRMat<dtype>& wordEmb);
void readWordClusters(const string& inFile);
int createAlphabet(const vector<Instance>& vecInsts);
int addTestWordAlpha(const vector<Instance>& vecInsts);
public:
void train(const string& trainFile, const string& devFile, const string& testFile, const string& modelFile, const string& optionFile,
const string& wordEmbFile);
void predict(const Instance& input, vector<string>& output);
void test(const string& testFile, const string& outputFile, const string& modelFile);
// static training
void getGoldActions(const vector<Instance>& vecInsts, vector<vector<CAction> >& vecActions);
public:
void proceedOneStepForDecode(const Instance& inputTree, CStateItem& state, int& outlab); //may be merged with train in the future
void writeModelFile(const string& outputModelFile);
void loadModelFile(const string& inputModelFile);
public:
inline void getCandidateActions(const CStateItem &item, vector<CAction>& actions) {
}
};
#endif /* SRC_PARSER_H_ */