opener-opinion-detector-basic 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/ext/hack/Rakefile +0 -2
- data/lib/opener/opinion_detector_basic/version.rb +1 -1
- data/opener-opinion-detector-basic.gemspec +0 -1
- data/task/compile.rake +1 -1
- data/task/requirements.rake +0 -1
- metadata +2 -142
- data/core/vendor/src/crfsuite/AUTHORS +0 -1
- data/core/vendor/src/crfsuite/COPYING +0 -27
- data/core/vendor/src/crfsuite/ChangeLog +0 -103
- data/core/vendor/src/crfsuite/INSTALL +0 -236
- data/core/vendor/src/crfsuite/Makefile.am +0 -19
- data/core/vendor/src/crfsuite/Makefile.in +0 -783
- data/core/vendor/src/crfsuite/README +0 -183
- data/core/vendor/src/crfsuite/aclocal.m4 +0 -9018
- data/core/vendor/src/crfsuite/autogen.sh +0 -38
- data/core/vendor/src/crfsuite/compile +0 -143
- data/core/vendor/src/crfsuite/config.guess +0 -1502
- data/core/vendor/src/crfsuite/config.h.in +0 -198
- data/core/vendor/src/crfsuite/config.sub +0 -1714
- data/core/vendor/src/crfsuite/configure +0 -14273
- data/core/vendor/src/crfsuite/configure.in +0 -149
- data/core/vendor/src/crfsuite/crfsuite.sln +0 -42
- data/core/vendor/src/crfsuite/depcomp +0 -630
- data/core/vendor/src/crfsuite/example/chunking.py +0 -49
- data/core/vendor/src/crfsuite/example/crfutils.py +0 -179
- data/core/vendor/src/crfsuite/example/ner.py +0 -270
- data/core/vendor/src/crfsuite/example/pos.py +0 -78
- data/core/vendor/src/crfsuite/example/template.py +0 -88
- data/core/vendor/src/crfsuite/frontend/Makefile.am +0 -29
- data/core/vendor/src/crfsuite/frontend/Makefile.in +0 -640
- data/core/vendor/src/crfsuite/frontend/dump.c +0 -116
- data/core/vendor/src/crfsuite/frontend/frontend.vcxproj +0 -129
- data/core/vendor/src/crfsuite/frontend/iwa.c +0 -273
- data/core/vendor/src/crfsuite/frontend/iwa.h +0 -65
- data/core/vendor/src/crfsuite/frontend/learn.c +0 -439
- data/core/vendor/src/crfsuite/frontend/main.c +0 -137
- data/core/vendor/src/crfsuite/frontend/option.c +0 -93
- data/core/vendor/src/crfsuite/frontend/option.h +0 -86
- data/core/vendor/src/crfsuite/frontend/readdata.h +0 -38
- data/core/vendor/src/crfsuite/frontend/reader.c +0 -136
- data/core/vendor/src/crfsuite/frontend/tag.c +0 -427
- data/core/vendor/src/crfsuite/genbinary.sh.in +0 -15
- data/core/vendor/src/crfsuite/include/Makefile.am +0 -11
- data/core/vendor/src/crfsuite/include/Makefile.in +0 -461
- data/core/vendor/src/crfsuite/include/crfsuite.h +0 -1063
- data/core/vendor/src/crfsuite/include/crfsuite.hpp +0 -555
- data/core/vendor/src/crfsuite/include/crfsuite_api.hpp +0 -400
- data/core/vendor/src/crfsuite/include/os.h +0 -61
- data/core/vendor/src/crfsuite/install-sh +0 -520
- data/core/vendor/src/crfsuite/lib/cqdb/COPYING +0 -28
- data/core/vendor/src/crfsuite/lib/cqdb/Makefile.am +0 -21
- data/core/vendor/src/crfsuite/lib/cqdb/Makefile.in +0 -549
- data/core/vendor/src/crfsuite/lib/cqdb/cqdb.vcxproj +0 -86
- data/core/vendor/src/crfsuite/lib/cqdb/include/cqdb.h +0 -524
- data/core/vendor/src/crfsuite/lib/cqdb/src/cqdb.c +0 -587
- data/core/vendor/src/crfsuite/lib/cqdb/src/lookup3.c +0 -976
- data/core/vendor/src/crfsuite/lib/crf/Makefile.am +0 -46
- data/core/vendor/src/crfsuite/lib/crf/Makefile.in +0 -721
- data/core/vendor/src/crfsuite/lib/crf/crf.vcxproj +0 -216
- data/core/vendor/src/crfsuite/lib/crf/src/crf1d.h +0 -353
- data/core/vendor/src/crfsuite/lib/crf/src/crf1d_context.c +0 -705
- data/core/vendor/src/crfsuite/lib/crf/src/crf1d_encode.c +0 -943
- data/core/vendor/src/crfsuite/lib/crf/src/crf1d_feature.c +0 -352
- data/core/vendor/src/crfsuite/lib/crf/src/crf1d_model.c +0 -994
- data/core/vendor/src/crfsuite/lib/crf/src/crf1d_tag.c +0 -550
- data/core/vendor/src/crfsuite/lib/crf/src/crfsuite.c +0 -492
- data/core/vendor/src/crfsuite/lib/crf/src/crfsuite_internal.h +0 -236
- data/core/vendor/src/crfsuite/lib/crf/src/crfsuite_train.c +0 -272
- data/core/vendor/src/crfsuite/lib/crf/src/dataset.c +0 -106
- data/core/vendor/src/crfsuite/lib/crf/src/dictionary.c +0 -118
- data/core/vendor/src/crfsuite/lib/crf/src/holdout.c +0 -80
- data/core/vendor/src/crfsuite/lib/crf/src/logging.c +0 -91
- data/core/vendor/src/crfsuite/lib/crf/src/logging.h +0 -48
- data/core/vendor/src/crfsuite/lib/crf/src/params.c +0 -335
- data/core/vendor/src/crfsuite/lib/crf/src/params.h +0 -80
- data/core/vendor/src/crfsuite/lib/crf/src/quark.c +0 -172
- data/core/vendor/src/crfsuite/lib/crf/src/quark.h +0 -46
- data/core/vendor/src/crfsuite/lib/crf/src/rumavl.c +0 -1107
- data/core/vendor/src/crfsuite/lib/crf/src/rumavl.h +0 -160
- data/core/vendor/src/crfsuite/lib/crf/src/train_arow.c +0 -408
- data/core/vendor/src/crfsuite/lib/crf/src/train_averaged_perceptron.c +0 -242
- data/core/vendor/src/crfsuite/lib/crf/src/train_l2sgd.c +0 -507
- data/core/vendor/src/crfsuite/lib/crf/src/train_lbfgs.c +0 -338
- data/core/vendor/src/crfsuite/lib/crf/src/train_passive_aggressive.c +0 -435
- data/core/vendor/src/crfsuite/lib/crf/src/vecmath.h +0 -341
- data/core/vendor/src/crfsuite/ltmain.sh +0 -8413
- data/core/vendor/src/crfsuite/missing +0 -376
- data/core/vendor/src/crfsuite/swig/Makefile.am +0 -13
- data/core/vendor/src/crfsuite/swig/Makefile.in +0 -365
- data/core/vendor/src/crfsuite/swig/crfsuite.cpp +0 -2
- data/core/vendor/src/crfsuite/swig/export.i +0 -32
- data/core/vendor/src/crfsuite/swig/python/README +0 -92
- data/core/vendor/src/crfsuite/swig/python/crfsuite.py +0 -329
- data/core/vendor/src/crfsuite/swig/python/export_wrap.cpp +0 -14355
- data/core/vendor/src/crfsuite/swig/python/export_wrap.h +0 -63
- data/core/vendor/src/crfsuite/swig/python/prepare.sh +0 -9
- data/core/vendor/src/crfsuite/swig/python/sample_tag.py +0 -52
- data/core/vendor/src/crfsuite/swig/python/sample_train.py +0 -68
- data/core/vendor/src/crfsuite/swig/python/setup.py +0 -44
- data/core/vendor/src/crfsuite/win32/stdint.h +0 -679
- data/core/vendor/src/liblbfgs/AUTHORS +0 -1
- data/core/vendor/src/liblbfgs/COPYING +0 -22
- data/core/vendor/src/liblbfgs/ChangeLog +0 -120
- data/core/vendor/src/liblbfgs/INSTALL +0 -231
- data/core/vendor/src/liblbfgs/Makefile.am +0 -10
- data/core/vendor/src/liblbfgs/Makefile.in +0 -638
- data/core/vendor/src/liblbfgs/NEWS +0 -0
- data/core/vendor/src/liblbfgs/README +0 -71
- data/core/vendor/src/liblbfgs/aclocal.m4 +0 -6985
- data/core/vendor/src/liblbfgs/autogen.sh +0 -38
- data/core/vendor/src/liblbfgs/config.guess +0 -1411
- data/core/vendor/src/liblbfgs/config.h.in +0 -64
- data/core/vendor/src/liblbfgs/config.sub +0 -1500
- data/core/vendor/src/liblbfgs/configure +0 -21146
- data/core/vendor/src/liblbfgs/configure.in +0 -107
- data/core/vendor/src/liblbfgs/depcomp +0 -522
- data/core/vendor/src/liblbfgs/include/lbfgs.h +0 -745
- data/core/vendor/src/liblbfgs/install-sh +0 -322
- data/core/vendor/src/liblbfgs/lbfgs.sln +0 -26
- data/core/vendor/src/liblbfgs/lib/Makefile.am +0 -24
- data/core/vendor/src/liblbfgs/lib/Makefile.in +0 -499
- data/core/vendor/src/liblbfgs/lib/arithmetic_ansi.h +0 -133
- data/core/vendor/src/liblbfgs/lib/arithmetic_sse_double.h +0 -294
- data/core/vendor/src/liblbfgs/lib/arithmetic_sse_float.h +0 -298
- data/core/vendor/src/liblbfgs/lib/lbfgs.c +0 -1371
- data/core/vendor/src/liblbfgs/lib/lib.vcxproj +0 -95
- data/core/vendor/src/liblbfgs/ltmain.sh +0 -6426
- data/core/vendor/src/liblbfgs/missing +0 -353
- data/core/vendor/src/liblbfgs/sample/Makefile.am +0 -15
- data/core/vendor/src/liblbfgs/sample/Makefile.in +0 -433
- data/core/vendor/src/liblbfgs/sample/sample.c +0 -81
- data/core/vendor/src/liblbfgs/sample/sample.cpp +0 -126
- data/core/vendor/src/liblbfgs/sample/sample.vcxproj +0 -105
- data/core/vendor/src/svm_light/LICENSE.txt +0 -59
- data/core/vendor/src/svm_light/Makefile +0 -105
- data/core/vendor/src/svm_light/kernel.h +0 -40
- data/core/vendor/src/svm_light/svm_classify.c +0 -197
- data/core/vendor/src/svm_light/svm_common.c +0 -985
- data/core/vendor/src/svm_light/svm_common.h +0 -301
- data/core/vendor/src/svm_light/svm_hideo.c +0 -1062
- data/core/vendor/src/svm_light/svm_learn.c +0 -4147
- data/core/vendor/src/svm_light/svm_learn.h +0 -169
- data/core/vendor/src/svm_light/svm_learn_main.c +0 -397
- data/core/vendor/src/svm_light/svm_loqo.c +0 -211
- data/task/c.rake +0 -36
- data/task/submodules.rake +0 -5
@@ -1,400 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* CRFsuite C++/SWIG API.
|
3
|
-
*
|
4
|
-
* Copyright (c) 2007-2010, Naoaki Okazaki
|
5
|
-
* All rights reserved.
|
6
|
-
*
|
7
|
-
* Redistribution and use in source and binary forms, with or without
|
8
|
-
* modification, are permitted provided that the following conditions are met:
|
9
|
-
* * Redistributions of source code must retain the above copyright
|
10
|
-
* notice, this list of conditions and the following disclaimer.
|
11
|
-
* * Redistributions in binary form must reproduce the above copyright
|
12
|
-
* notice, this list of conditions and the following disclaimer in the
|
13
|
-
* documentation and/or other materials provided with the distribution.
|
14
|
-
* * Neither the names of the authors nor the names of its contributors
|
15
|
-
* may be used to endorse or promote products derived from this
|
16
|
-
* software without specific prior written permission.
|
17
|
-
*
|
18
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
19
|
-
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
20
|
-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
21
|
-
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
22
|
-
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
23
|
-
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
24
|
-
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
25
|
-
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
26
|
-
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
27
|
-
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
28
|
-
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
-
*/
|
30
|
-
|
31
|
-
#ifndef __CRFSUITE_API_HPP__
|
32
|
-
#define __CRFSUITE_API_HPP__
|
33
|
-
|
34
|
-
#include <string>
|
35
|
-
#include <stdexcept>
|
36
|
-
#include <vector>
|
37
|
-
|
38
|
-
#ifndef __CRFSUITE_H__
|
39
|
-
|
40
|
-
#ifdef __cplusplus
|
41
|
-
extern "C" {
|
42
|
-
#endif/*__cplusplus*/
|
43
|
-
|
44
|
-
struct tag_crfsuite_model;
|
45
|
-
typedef struct tag_crfsuite_model crfsuite_model_t;
|
46
|
-
|
47
|
-
struct tag_crfsuite_data;
|
48
|
-
typedef struct tag_crfsuite_data crfsuite_data_t;
|
49
|
-
|
50
|
-
struct tag_crfsuite_trainer;
|
51
|
-
typedef struct tag_crfsuite_trainer crfsuite_trainer_t;
|
52
|
-
|
53
|
-
struct tag_crfsuite_tagger;
|
54
|
-
typedef struct tag_crfsuite_tagger crfsuite_tagger_t;
|
55
|
-
|
56
|
-
struct tag_crfsuite_dictionary;
|
57
|
-
typedef struct tag_crfsuite_dictionary crfsuite_dictionary_t;
|
58
|
-
|
59
|
-
struct tag_crfsuite_params;
|
60
|
-
typedef struct tag_crfsuite_params crfsuite_params_t;
|
61
|
-
|
62
|
-
#ifdef __cplusplus
|
63
|
-
}
|
64
|
-
#endif/*__cplusplus*/
|
65
|
-
|
66
|
-
#endif/*__CRFSUITE_H__*/
|
67
|
-
|
68
|
-
/**
|
69
|
-
\page crfsuite_hpp_api CRFSuite C++/SWIG API
|
70
|
-
|
71
|
-
@section crfsuite_hpp_api_intro Introduction
|
72
|
-
|
73
|
-
The CRFSuite C++/SWIG API provides a high-level and easy-to-use library module
|
74
|
-
for a number of programming languages. The C++/SWIG API is a wrapper for the
|
75
|
-
CRFSuite C API.
|
76
|
-
- @link crfsuite_hpp_api_doc API documentation @endlink
|
77
|
-
|
78
|
-
@section crfsuite_hpp_api_cpp C++ API
|
79
|
-
|
80
|
-
The C++ library is implemented in two header files, crfsuite_api.hpp and
|
81
|
-
crfsuite.hpp. One can use the C++ API only by including crfsuite.hpp. The C++
|
82
|
-
library has a dependency to the CRFSuite C library, which means that the
|
83
|
-
C header file (crfsuite.h) and libcrfsuite library are necessary.
|
84
|
-
|
85
|
-
@section crfsuite_hpp_api_swig SWIG API
|
86
|
-
|
87
|
-
The SWIG API is identical to the C++ API. Currently, the CRFsuite distribution
|
88
|
-
includes a Python module for CRFsuite. Please read README under swig/python
|
89
|
-
directory for the information to build the Python module.
|
90
|
-
|
91
|
-
@subsection crfsuite_hpp_api_sample Sample code
|
92
|
-
|
93
|
-
This code demonstrates how to use the crfsuite.Trainer object. The script
|
94
|
-
reads a training data from STDIN, trains a model using 'l2sgd' algorithm,
|
95
|
-
and stores the model to a file (the first argument of the commend line).
|
96
|
-
|
97
|
-
@include swig/python/sample_train.py
|
98
|
-
|
99
|
-
This code demonstrates how to use the crfsuite.Tagger object. The script
|
100
|
-
loads a model from a file (the first argument of the commend line), reads
|
101
|
-
a data from STDIN, predicts label sequences.
|
102
|
-
|
103
|
-
@include swig/python/sample_tag.py
|
104
|
-
|
105
|
-
*/
|
106
|
-
|
107
|
-
namespace CRFSuite
|
108
|
-
{
|
109
|
-
|
110
|
-
/**
|
111
|
-
* \addtogroup crfsuite_hpp_api_doc Data structures
|
112
|
-
* @{
|
113
|
-
*/
|
114
|
-
|
115
|
-
/**
|
116
|
-
* Tuple of attribute and its value.
|
117
|
-
*/
|
118
|
-
class Attribute
|
119
|
-
{
|
120
|
-
public:
|
121
|
-
/// Attribute.
|
122
|
-
std::string attr;
|
123
|
-
/// Attribute value (weight).
|
124
|
-
double value;
|
125
|
-
|
126
|
-
/**
|
127
|
-
* Construct an attribute with the default name and value.
|
128
|
-
*/
|
129
|
-
Attribute() : value(1.)
|
130
|
-
{
|
131
|
-
}
|
132
|
-
|
133
|
-
/**
|
134
|
-
* Construct an attribute with the default value.
|
135
|
-
* @param name The attribute name.
|
136
|
-
*/
|
137
|
-
Attribute(const std::string& name) : attr(name), value(1.)
|
138
|
-
{
|
139
|
-
}
|
140
|
-
|
141
|
-
/**
|
142
|
-
* Construct an attribute.
|
143
|
-
* @param name The attribute name.
|
144
|
-
* @param val The attribute value.
|
145
|
-
*/
|
146
|
-
Attribute(const std::string& name, double val) : attr(name), value(val)
|
147
|
-
{
|
148
|
-
}
|
149
|
-
};
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
/**
|
154
|
-
* Type of an item (equivalent to an attribute vector) in a sequence.
|
155
|
-
*/
|
156
|
-
typedef std::vector<Attribute> Item;
|
157
|
-
|
158
|
-
/**
|
159
|
-
* Type of an item sequence (equivalent to item vector).
|
160
|
-
*/
|
161
|
-
typedef std::vector<Item> ItemSequence;
|
162
|
-
|
163
|
-
/**
|
164
|
-
* Type of a string list.
|
165
|
-
*/
|
166
|
-
typedef std::vector<std::string> StringList;
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
/**
|
172
|
-
* The trainer class.
|
173
|
-
* This class maintains a data set for training, and provides an interface
|
174
|
-
* to various graphical models and training algorithms. The standard
|
175
|
-
* procedure for implementing a trainer is:
|
176
|
-
* - create a class by inheriting this class
|
177
|
-
* - overwrite message() function to receive messages of training progress
|
178
|
-
* - call append() to append item/label sequences to the training set
|
179
|
-
* - call select() to specify a graphical model and an algorithm
|
180
|
-
* - call set() to configure parameters specific to the model and algorithm
|
181
|
-
* - call train() to start a training process with the current setting
|
182
|
-
*/
|
183
|
-
class Trainer {
|
184
|
-
protected:
|
185
|
-
crfsuite_data_t *data;
|
186
|
-
crfsuite_trainer_t *tr;
|
187
|
-
|
188
|
-
public:
|
189
|
-
/**
|
190
|
-
* Construct a trainer.
|
191
|
-
*/
|
192
|
-
Trainer();
|
193
|
-
|
194
|
-
/**
|
195
|
-
* Destruct a trainer.
|
196
|
-
*/
|
197
|
-
virtual ~Trainer();
|
198
|
-
|
199
|
-
/**
|
200
|
-
* Remove all instances in the data set.
|
201
|
-
*/
|
202
|
-
void clear();
|
203
|
-
|
204
|
-
/**
|
205
|
-
* Append an instance (item/label sequence) to the data set.
|
206
|
-
* @param xseq The item sequence of the instance.
|
207
|
-
* @param yseq The label sequence of the instance. The number
|
208
|
-
* of elements in yseq must be identical to that
|
209
|
-
* in xseq.
|
210
|
-
* @param group The group number of the instance.
|
211
|
-
* @throw std::invalid_argument Arguments xseq and yseq are invalid.
|
212
|
-
* @throw std::runtime_error Out of memory.
|
213
|
-
*/
|
214
|
-
void append(const ItemSequence& xseq, const StringList& yseq, int group);
|
215
|
-
|
216
|
-
/**
|
217
|
-
* Initialize the training algorithm.
|
218
|
-
* @param algorithm The name of the training algorithm.
|
219
|
-
* @param type The name of the graphical model.
|
220
|
-
* @return bool \c true if the training algorithm is successfully
|
221
|
-
* initialized, \c false otherwise.
|
222
|
-
*/
|
223
|
-
bool select(const std::string& algorithm, const std::string& type);
|
224
|
-
|
225
|
-
/**
|
226
|
-
* Run the training algorithm.
|
227
|
-
* This function starts the training algorithm with the data set given
|
228
|
-
* by append() function. After starting the training process, the
|
229
|
-
* training algorithm invokes the virtual function message() to report
|
230
|
-
* the progress of the training process.
|
231
|
-
* @param model The filename to which the trained model is stored.
|
232
|
-
* If this value is empty, this function does not
|
233
|
-
* write out a model file.
|
234
|
-
* @param holdout The group number of holdout evaluation. The
|
235
|
-
* instances with this group number will not be used
|
236
|
-
* for training, but for holdout evaluation. Specify
|
237
|
-
* \c -1 to use all instances for training.
|
238
|
-
* @return int The status code.
|
239
|
-
*/
|
240
|
-
int train(const std::string& model, int holdout);
|
241
|
-
|
242
|
-
/**
|
243
|
-
* Obtain the list of parameters.
|
244
|
-
* This function returns the list of parameter names available for the
|
245
|
-
* graphical model and training algorithm specified by select() function.
|
246
|
-
* @return StringList The list of parameters available for the current
|
247
|
-
* graphical model and training algorithm.
|
248
|
-
*/
|
249
|
-
StringList params();
|
250
|
-
|
251
|
-
/**
|
252
|
-
* Set a training parameter.
|
253
|
-
* This function sets a parameter value for the graphical model and
|
254
|
-
* training algorithm specified by select() function.
|
255
|
-
* @param name The parameter name.
|
256
|
-
* @param value The value of the parameter.
|
257
|
-
* @throw std::invalid_argument The parameter is not found.
|
258
|
-
*/
|
259
|
-
void set(const std::string& name, const std::string& value);
|
260
|
-
|
261
|
-
/**
|
262
|
-
* Get the value of a training parameter.
|
263
|
-
* This function gets a parameter value for the graphical model and
|
264
|
-
* training algorithm specified by select() function.
|
265
|
-
* @param name The parameter name.
|
266
|
-
* @return std::string The value of the parameter.
|
267
|
-
* @throw std::invalid_argument The parameter is not found.
|
268
|
-
*/
|
269
|
-
std::string get(const std::string& name);
|
270
|
-
|
271
|
-
/**
|
272
|
-
* Get the description of a training parameter.
|
273
|
-
* This function obtains the help message for the parameter specified
|
274
|
-
* by the name. The graphical model and training algorithm must be
|
275
|
-
* selected by select() function before calling this function.
|
276
|
-
* @param name The parameter name.
|
277
|
-
* @return std::string The description (help message) of the parameter.
|
278
|
-
*/
|
279
|
-
std::string help(const std::string& name);
|
280
|
-
|
281
|
-
/**
|
282
|
-
* Receive messages from the training algorithm.
|
283
|
-
* Override this member function to receive messages of the training
|
284
|
-
* process.
|
285
|
-
* @param msg The message
|
286
|
-
*/
|
287
|
-
virtual void message(const std::string& msg);
|
288
|
-
|
289
|
-
protected:
|
290
|
-
void init();
|
291
|
-
static int __logging_callback(void *userdata, const char *format, va_list args);
|
292
|
-
};
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
/**
|
297
|
-
* The tagger class.
|
298
|
-
* This class provides the functionality for predicting label sequences for
|
299
|
-
* input sequences using a model.
|
300
|
-
*/
|
301
|
-
class Tagger
|
302
|
-
{
|
303
|
-
protected:
|
304
|
-
crfsuite_model_t *model;
|
305
|
-
crfsuite_tagger_t *tagger;
|
306
|
-
|
307
|
-
public:
|
308
|
-
/**
|
309
|
-
* Construct a tagger.
|
310
|
-
*/
|
311
|
-
Tagger();
|
312
|
-
|
313
|
-
/**
|
314
|
-
* Destruct a tagger.
|
315
|
-
*/
|
316
|
-
virtual ~Tagger();
|
317
|
-
|
318
|
-
/**
|
319
|
-
* Open a model file.
|
320
|
-
* @param name The file name of the model file.
|
321
|
-
* @return bool \c true if the model file is successfully opened,
|
322
|
-
* \c false otherwise (e.g., when the mode file is
|
323
|
-
* not found).
|
324
|
-
* @throw std::runtime_error An internal error in the model.
|
325
|
-
*/
|
326
|
-
bool open(const std::string& name);
|
327
|
-
|
328
|
-
/**
|
329
|
-
* Close the model.
|
330
|
-
*/
|
331
|
-
void close();
|
332
|
-
|
333
|
-
/**
|
334
|
-
* Obtain the list of labels.
|
335
|
-
* @return StringList The list of labels in the model.
|
336
|
-
* @throw std::invalid_argument A model is not opened.
|
337
|
-
* @throw std::runtime_error An internal error.
|
338
|
-
*/
|
339
|
-
StringList labels();
|
340
|
-
|
341
|
-
/**
|
342
|
-
* Predict the label sequence for the item sequence.
|
343
|
-
* This function calls set() and viterbi() functions to obtain the
|
344
|
-
* label sequence predicted for the item sequence.
|
345
|
-
* @param xseq The item sequence to be tagged.
|
346
|
-
* @return StringList The label sequence predicted.
|
347
|
-
* @throw std::invalid_argument A model is not opened.
|
348
|
-
* @throw std::runtime_error An internal error.
|
349
|
-
*/
|
350
|
-
StringList tag(const ItemSequence& xseq);
|
351
|
-
|
352
|
-
/**
|
353
|
-
* Set an item sequence.
|
354
|
-
* This function sets an item sequence for future calls for
|
355
|
-
* viterbi(), probability(), and marginal() functions.
|
356
|
-
* @param xseq The item sequence to be tagged
|
357
|
-
* @throw std::invalid_argument A model is not opened.
|
358
|
-
* @throw std::runtime_error An internal error.
|
359
|
-
*/
|
360
|
-
void set(const ItemSequence& xseq);
|
361
|
-
|
362
|
-
/**
|
363
|
-
* Find the Viterbi label sequence for the item sequence.
|
364
|
-
* @return StringList The label sequence predicted.
|
365
|
-
* @throw std::invalid_argument A model is not opened.
|
366
|
-
* @throw std::runtime_error An internal error.
|
367
|
-
*/
|
368
|
-
StringList viterbi();
|
369
|
-
|
370
|
-
/**
|
371
|
-
* Compute the probability of the label sequence.
|
372
|
-
* @param yseq The label sequence.
|
373
|
-
* @throw std::invalid_argument A model is not opened.
|
374
|
-
* @throw std::runtime_error An internal error.
|
375
|
-
*/
|
376
|
-
double probability(const StringList& yseq);
|
377
|
-
|
378
|
-
/**
|
379
|
-
* Compute the marginal probability of the label.
|
380
|
-
* @param y The label.
|
381
|
-
* @param t The position of the label.
|
382
|
-
* @throw std::invalid_argument A model is not opened.
|
383
|
-
* @throw std::runtime_error An internal error.
|
384
|
-
*/
|
385
|
-
double marginal(const std::string& y, const int t);
|
386
|
-
};
|
387
|
-
|
388
|
-
/**
|
389
|
-
* Obtain the version number of the library.
|
390
|
-
* @return std::string The version string.
|
391
|
-
*/
|
392
|
-
std::string version();
|
393
|
-
|
394
|
-
/**@} */
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
};
|
399
|
-
|
400
|
-
#endif/*__CRFSUITE_API_HPP__*/
|
@@ -1,61 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Compatibility stuff among operating systems and compilers.
|
3
|
-
*
|
4
|
-
* Copyright (c) 2007-2010, Naoaki Okazaki
|
5
|
-
* All rights reserved.
|
6
|
-
*
|
7
|
-
* Redistribution and use in source and binary forms, with or without
|
8
|
-
* modification, are permitted provided that the following conditions are met:
|
9
|
-
* * Redistributions of source code must retain the above copyright
|
10
|
-
* notice, this list of conditions and the following disclaimer.
|
11
|
-
* * Redistributions in binary form must reproduce the above copyright
|
12
|
-
* notice, this list of conditions and the following disclaimer in the
|
13
|
-
* documentation and/or other materials provided with the distribution.
|
14
|
-
* * Neither the names of the authors nor the names of its contributors
|
15
|
-
* may be used to endorse or promote products derived from this
|
16
|
-
* software without specific prior written permission.
|
17
|
-
*
|
18
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
19
|
-
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
20
|
-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
21
|
-
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
22
|
-
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
23
|
-
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
24
|
-
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
25
|
-
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
26
|
-
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
27
|
-
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
28
|
-
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
-
*/
|
30
|
-
|
31
|
-
/* $Id$ */
|
32
|
-
|
33
|
-
#ifndef __OS_H__
|
34
|
-
#define __OS_H__
|
35
|
-
|
36
|
-
|
37
|
-
//#define __SSE__ 1
|
38
|
-
#define LBFGS_FLOAT 64
|
39
|
-
|
40
|
-
#ifdef _MSC_VER
|
41
|
-
/* Microsoft Visual C/C++ specific */
|
42
|
-
|
43
|
-
#define _CRT_SECURE_NO_WARNINGS 1
|
44
|
-
#pragma warning(disable : 4996)
|
45
|
-
|
46
|
-
#define alloca _alloca
|
47
|
-
#define strdup _strdup
|
48
|
-
#define open _open
|
49
|
-
#define isfinite _finite
|
50
|
-
#define snprintf _snprintf
|
51
|
-
|
52
|
-
#ifndef __cplusplus
|
53
|
-
/* Microsoft Visual C specific */
|
54
|
-
|
55
|
-
#define inline __forceinline
|
56
|
-
|
57
|
-
#endif/*__cplusplus*/
|
58
|
-
|
59
|
-
#endif/*_MSC_VER*/
|
60
|
-
|
61
|
-
#endif/*__OS_H__*/
|