chaine 3.13.1__cp311-cp311-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of chaine might be problematic. Click here for more details.
- chaine/__init__.py +2 -0
- chaine/_core/crf.cpp +19854 -0
- chaine/_core/crf.cpython-311-darwin.so +0 -0
- chaine/_core/crf.pyx +271 -0
- chaine/_core/crfsuite/COPYING +27 -0
- chaine/_core/crfsuite/README +183 -0
- chaine/_core/crfsuite/include/crfsuite.h +1077 -0
- chaine/_core/crfsuite/include/crfsuite.hpp +649 -0
- chaine/_core/crfsuite/include/crfsuite_api.hpp +406 -0
- chaine/_core/crfsuite/include/os.h +65 -0
- chaine/_core/crfsuite/lib/cqdb/COPYING +28 -0
- chaine/_core/crfsuite/lib/cqdb/include/cqdb.h +518 -0
- chaine/_core/crfsuite/lib/cqdb/src/cqdb.c +639 -0
- chaine/_core/crfsuite/lib/cqdb/src/lookup3.c +1271 -0
- chaine/_core/crfsuite/lib/cqdb/src/main.c +184 -0
- chaine/_core/crfsuite/lib/crf/src/crf1d.h +354 -0
- chaine/_core/crfsuite/lib/crf/src/crf1d_context.c +788 -0
- chaine/_core/crfsuite/lib/crf/src/crf1d_encode.c +1020 -0
- chaine/_core/crfsuite/lib/crf/src/crf1d_feature.c +382 -0
- chaine/_core/crfsuite/lib/crf/src/crf1d_model.c +1085 -0
- chaine/_core/crfsuite/lib/crf/src/crf1d_tag.c +582 -0
- chaine/_core/crfsuite/lib/crf/src/crfsuite.c +500 -0
- chaine/_core/crfsuite/lib/crf/src/crfsuite_internal.h +233 -0
- chaine/_core/crfsuite/lib/crf/src/crfsuite_train.c +302 -0
- chaine/_core/crfsuite/lib/crf/src/dataset.c +115 -0
- chaine/_core/crfsuite/lib/crf/src/dictionary.c +127 -0
- chaine/_core/crfsuite/lib/crf/src/holdout.c +83 -0
- chaine/_core/crfsuite/lib/crf/src/json.c +1497 -0
- chaine/_core/crfsuite/lib/crf/src/json.h +120 -0
- chaine/_core/crfsuite/lib/crf/src/logging.c +85 -0
- chaine/_core/crfsuite/lib/crf/src/logging.h +49 -0
- chaine/_core/crfsuite/lib/crf/src/params.c +370 -0
- chaine/_core/crfsuite/lib/crf/src/params.h +84 -0
- chaine/_core/crfsuite/lib/crf/src/quark.c +180 -0
- chaine/_core/crfsuite/lib/crf/src/quark.h +46 -0
- chaine/_core/crfsuite/lib/crf/src/rumavl.c +1178 -0
- chaine/_core/crfsuite/lib/crf/src/rumavl.h +144 -0
- chaine/_core/crfsuite/lib/crf/src/train_arow.c +409 -0
- chaine/_core/crfsuite/lib/crf/src/train_averaged_perceptron.c +237 -0
- chaine/_core/crfsuite/lib/crf/src/train_l2sgd.c +491 -0
- chaine/_core/crfsuite/lib/crf/src/train_lbfgs.c +323 -0
- chaine/_core/crfsuite/lib/crf/src/train_passive_aggressive.c +442 -0
- chaine/_core/crfsuite/lib/crf/src/vecmath.h +360 -0
- chaine/_core/crfsuite/swig/crfsuite.cpp +1 -0
- chaine/_core/crfsuite_api.pxd +67 -0
- chaine/_core/liblbfgs/COPYING +22 -0
- chaine/_core/liblbfgs/README +71 -0
- chaine/_core/liblbfgs/include/lbfgs.h +745 -0
- chaine/_core/liblbfgs/lib/arithmetic_ansi.h +142 -0
- chaine/_core/liblbfgs/lib/arithmetic_sse_double.h +303 -0
- chaine/_core/liblbfgs/lib/arithmetic_sse_float.h +312 -0
- chaine/_core/liblbfgs/lib/lbfgs.c +1531 -0
- chaine/_core/tagger_wrapper.hpp +58 -0
- chaine/_core/trainer_wrapper.cpp +32 -0
- chaine/_core/trainer_wrapper.hpp +26 -0
- chaine/crf.py +505 -0
- chaine/logging.py +214 -0
- chaine/optimization/__init__.py +10 -0
- chaine/optimization/metrics.py +129 -0
- chaine/optimization/spaces.py +394 -0
- chaine/optimization/trial.py +103 -0
- chaine/optimization/utils.py +119 -0
- chaine/training.py +184 -0
- chaine/typing.py +18 -0
- chaine/validation.py +43 -0
- chaine-3.13.1.dist-info/METADATA +348 -0
- chaine-3.13.1.dist-info/RECORD +68 -0
- chaine-3.13.1.dist-info/WHEEL +5 -0
|
@@ -0,0 +1,406 @@
|
|
|
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
|
+
#include <cstdarg>
|
|
38
|
+
|
|
39
|
+
#ifndef __CRFSUITE_H__
|
|
40
|
+
|
|
41
|
+
#ifdef __cplusplus
|
|
42
|
+
extern "C"
|
|
43
|
+
{
|
|
44
|
+
#endif /*__cplusplus*/
|
|
45
|
+
|
|
46
|
+
struct tag_crfsuite_model;
|
|
47
|
+
typedef struct tag_crfsuite_model crfsuite_model_t;
|
|
48
|
+
|
|
49
|
+
struct tag_crfsuite_data;
|
|
50
|
+
typedef struct tag_crfsuite_data crfsuite_data_t;
|
|
51
|
+
|
|
52
|
+
struct tag_crfsuite_trainer;
|
|
53
|
+
typedef struct tag_crfsuite_trainer crfsuite_trainer_t;
|
|
54
|
+
|
|
55
|
+
struct tag_crfsuite_tagger;
|
|
56
|
+
typedef struct tag_crfsuite_tagger crfsuite_tagger_t;
|
|
57
|
+
|
|
58
|
+
struct tag_crfsuite_dictionary;
|
|
59
|
+
typedef struct tag_crfsuite_dictionary crfsuite_dictionary_t;
|
|
60
|
+
|
|
61
|
+
struct tag_crfsuite_params;
|
|
62
|
+
typedef struct tag_crfsuite_params crfsuite_params_t;
|
|
63
|
+
|
|
64
|
+
#ifdef __cplusplus
|
|
65
|
+
}
|
|
66
|
+
#endif /*__cplusplus*/
|
|
67
|
+
|
|
68
|
+
#endif /*__CRFSUITE_H__*/
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
\page crfsuite_hpp_api CRFSuite C++/SWIG API
|
|
72
|
+
|
|
73
|
+
@section crfsuite_hpp_api_intro Introduction
|
|
74
|
+
|
|
75
|
+
The CRFSuite C++/SWIG API provides a high-level and easy-to-use library module
|
|
76
|
+
for a number of programming languages. The C++/SWIG API is a wrapper for the
|
|
77
|
+
CRFSuite C API.
|
|
78
|
+
- @link crfsuite_hpp_api_doc API documentation @endlink
|
|
79
|
+
|
|
80
|
+
@section crfsuite_hpp_api_cpp C++ API
|
|
81
|
+
|
|
82
|
+
The C++ library is implemented in two header files, crfsuite_api.hpp and
|
|
83
|
+
crfsuite.hpp. One can use the C++ API only by including crfsuite.hpp. The C++
|
|
84
|
+
library has a dependency to the CRFSuite C library, which means that the
|
|
85
|
+
C header file (crfsuite.h) and libcrfsuite library are necessary.
|
|
86
|
+
|
|
87
|
+
@section crfsuite_hpp_api_swig SWIG API
|
|
88
|
+
|
|
89
|
+
The SWIG API is identical to the C++ API. Currently, the CRFsuite distribution
|
|
90
|
+
includes a Python module for CRFsuite. Please read README under swig/python
|
|
91
|
+
directory for the information to build the Python module.
|
|
92
|
+
|
|
93
|
+
@subsection crfsuite_hpp_api_sample Sample code
|
|
94
|
+
|
|
95
|
+
This code demonstrates how to use the crfsuite.Trainer object. The script
|
|
96
|
+
reads a training data from STDIN, trains a model using 'l2sgd' algorithm,
|
|
97
|
+
and stores the model to a file (the first argument of the commend line).
|
|
98
|
+
|
|
99
|
+
@include swig/python/sample_train.py
|
|
100
|
+
|
|
101
|
+
This code demonstrates how to use the crfsuite.Tagger object. The script
|
|
102
|
+
loads a model from a file (the first argument of the commend line), reads
|
|
103
|
+
a data from STDIN, predicts label sequences.
|
|
104
|
+
|
|
105
|
+
@include swig/python/sample_tag.py
|
|
106
|
+
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
namespace CRFSuite
|
|
110
|
+
{
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* \addtogroup crfsuite_hpp_api_doc Data structures
|
|
114
|
+
* @{
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Tuple of attribute and its value.
|
|
119
|
+
*/
|
|
120
|
+
class Attribute
|
|
121
|
+
{
|
|
122
|
+
public:
|
|
123
|
+
/// Attribute.
|
|
124
|
+
std::string attr;
|
|
125
|
+
/// Attribute value (weight).
|
|
126
|
+
double value;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Construct an attribute with the default name and value.
|
|
130
|
+
*/
|
|
131
|
+
Attribute() : value(1.)
|
|
132
|
+
{
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Construct an attribute with the default value.
|
|
137
|
+
* @param name The attribute name.
|
|
138
|
+
*/
|
|
139
|
+
Attribute(const std::string &name) : attr(name), value(1.)
|
|
140
|
+
{
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Construct an attribute.
|
|
145
|
+
* @param name The attribute name.
|
|
146
|
+
* @param val The attribute value.
|
|
147
|
+
*/
|
|
148
|
+
Attribute(const std::string &name, double val) : attr(name), value(val)
|
|
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
|
+
* The trainer class.
|
|
170
|
+
* This class maintains a data set for training, and provides an interface
|
|
171
|
+
* to various graphical models and training algorithms. The standard
|
|
172
|
+
* procedure for implementing a trainer is:
|
|
173
|
+
* - create a class by inheriting this class
|
|
174
|
+
* - overwrite message() function to receive messages of training progress
|
|
175
|
+
* - call append() to append item/label sequences to the training set
|
|
176
|
+
* - call select() to specify a graphical model and an algorithm
|
|
177
|
+
* - call set() to configure parameters specific to the model and algorithm
|
|
178
|
+
* - call train() to start a training process with the current setting
|
|
179
|
+
*/
|
|
180
|
+
class Trainer
|
|
181
|
+
{
|
|
182
|
+
protected:
|
|
183
|
+
crfsuite_data_t *data;
|
|
184
|
+
crfsuite_trainer_t *tr;
|
|
185
|
+
|
|
186
|
+
public:
|
|
187
|
+
/**
|
|
188
|
+
* Construct a trainer.
|
|
189
|
+
*/
|
|
190
|
+
Trainer();
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Destruct a trainer.
|
|
194
|
+
*/
|
|
195
|
+
virtual ~Trainer();
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Remove all instances in the data set.
|
|
199
|
+
*/
|
|
200
|
+
void clear();
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Append an instance (item/label sequence) to the data set.
|
|
204
|
+
* @param xseq The item sequence of the instance.
|
|
205
|
+
* @param yseq The label sequence of the instance. The number
|
|
206
|
+
* of elements in yseq must be identical to that
|
|
207
|
+
* in xseq.
|
|
208
|
+
* @param group The group number of the instance.
|
|
209
|
+
* @throw std::invalid_argument Arguments xseq and yseq are invalid.
|
|
210
|
+
* @throw std::runtime_error Out of memory.
|
|
211
|
+
*/
|
|
212
|
+
void append(const ItemSequence &xseq, const StringList &yseq, int group);
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Initialize the training algorithm.
|
|
216
|
+
* @param algorithm The name of the training algorithm.
|
|
217
|
+
* @param type The name of the graphical model.
|
|
218
|
+
* @return bool \c true if the training algorithm is successfully
|
|
219
|
+
* initialized, \c false otherwise.
|
|
220
|
+
*/
|
|
221
|
+
bool select(const std::string &algorithm, const std::string &type);
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Run the training algorithm.
|
|
225
|
+
* This function starts the training algorithm with the data set given
|
|
226
|
+
* by append() function. After starting the training process, the
|
|
227
|
+
* training algorithm invokes the virtual function message() to report
|
|
228
|
+
* the progress of the training process.
|
|
229
|
+
* @param model The filename to which the trained model is stored.
|
|
230
|
+
* If this value is empty, this function does not
|
|
231
|
+
* write out a model file.
|
|
232
|
+
* @param holdout The group number of holdout evaluation. The
|
|
233
|
+
* instances with this group number will not be used
|
|
234
|
+
* for training, but for holdout evaluation. Specify
|
|
235
|
+
* \c -1 to use all instances for training.
|
|
236
|
+
* @return int The status code.
|
|
237
|
+
*/
|
|
238
|
+
int train(const std::string &model, int holdout);
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Obtain the list of parameters.
|
|
242
|
+
* This function returns the list of parameter names available for the
|
|
243
|
+
* graphical model and training algorithm specified by select() function.
|
|
244
|
+
* @return StringList The list of parameters available for the current
|
|
245
|
+
* graphical model and training algorithm.
|
|
246
|
+
*/
|
|
247
|
+
StringList params();
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Set a training parameter.
|
|
251
|
+
* This function sets a parameter value for the graphical model and
|
|
252
|
+
* training algorithm specified by select() function.
|
|
253
|
+
* @param name The parameter name.
|
|
254
|
+
* @param value The value of the parameter.
|
|
255
|
+
* @throw std::invalid_argument The parameter is not found.
|
|
256
|
+
*/
|
|
257
|
+
void set(const std::string &name, const std::string &value);
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Get the value of a training parameter.
|
|
261
|
+
* This function gets a parameter value for the graphical model and
|
|
262
|
+
* training algorithm specified by select() function.
|
|
263
|
+
* @param name The parameter name.
|
|
264
|
+
* @return std::string The value of the parameter.
|
|
265
|
+
* @throw std::invalid_argument The parameter is not found.
|
|
266
|
+
*/
|
|
267
|
+
std::string get(const std::string &name);
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Get the description of a training parameter.
|
|
271
|
+
* This function obtains the help message for the parameter specified
|
|
272
|
+
* by the name. The graphical model and training algorithm must be
|
|
273
|
+
* selected by select() function before calling this function.
|
|
274
|
+
* @param name The parameter name.
|
|
275
|
+
* @return std::string The description (help message) of the parameter.
|
|
276
|
+
*/
|
|
277
|
+
std::string help(const std::string &name);
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Receive messages from the training algorithm.
|
|
281
|
+
* Override this member function to receive messages of the training
|
|
282
|
+
* process.
|
|
283
|
+
* @param msg The message
|
|
284
|
+
*/
|
|
285
|
+
virtual void message(const std::string &msg);
|
|
286
|
+
|
|
287
|
+
protected:
|
|
288
|
+
void init();
|
|
289
|
+
static int __logging_callback(void *userdata, const char *format, va_list args);
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* The tagger class.
|
|
294
|
+
* This class provides the functionality for predicting label sequences for
|
|
295
|
+
* input sequences using a model.
|
|
296
|
+
*/
|
|
297
|
+
class Tagger
|
|
298
|
+
{
|
|
299
|
+
protected:
|
|
300
|
+
crfsuite_model_t *model;
|
|
301
|
+
crfsuite_tagger_t *tagger;
|
|
302
|
+
|
|
303
|
+
public:
|
|
304
|
+
/**
|
|
305
|
+
* Construct a tagger.
|
|
306
|
+
*/
|
|
307
|
+
Tagger();
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Destruct a tagger.
|
|
311
|
+
*/
|
|
312
|
+
virtual ~Tagger();
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Open a model file.
|
|
316
|
+
* @param name The file name of the model file.
|
|
317
|
+
* @return bool \c true if the model file is successfully opened,
|
|
318
|
+
* \c false otherwise (e.g., when the model file is
|
|
319
|
+
* not found).
|
|
320
|
+
* @throw std::runtime_error An internal error in the model.
|
|
321
|
+
*/
|
|
322
|
+
bool open(const std::string &name);
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Open a model from memory.
|
|
326
|
+
* @param data A pointer to the model data.
|
|
327
|
+
* Must be 16-byte aligned.
|
|
328
|
+
* @param size A size (in bytes) of the model data.
|
|
329
|
+
* @return bool \c true if the model file is successfully opened,
|
|
330
|
+
* \c false otherwise (e.g., when the mode file is
|
|
331
|
+
* not found).
|
|
332
|
+
* @throw std::runtime_error An internal error in the model.
|
|
333
|
+
*/
|
|
334
|
+
bool open(const void *data, std::size_t size);
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Close the model.
|
|
338
|
+
*/
|
|
339
|
+
void close();
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Obtain the list of labels.
|
|
343
|
+
* @return StringList The list of labels in the model.
|
|
344
|
+
* @throw std::invalid_argument A model is not opened.
|
|
345
|
+
* @throw std::runtime_error An internal error.
|
|
346
|
+
*/
|
|
347
|
+
StringList labels();
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Predict the label sequence for the item sequence.
|
|
351
|
+
* This function calls set() and viterbi() functions to obtain the
|
|
352
|
+
* label sequence predicted for the item sequence.
|
|
353
|
+
* @param xseq The item sequence to be tagged.
|
|
354
|
+
* @return StringList The label sequence predicted.
|
|
355
|
+
* @throw std::invalid_argument A model is not opened.
|
|
356
|
+
* @throw std::runtime_error An internal error.
|
|
357
|
+
*/
|
|
358
|
+
StringList tag(const ItemSequence &xseq);
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Set an item sequence.
|
|
362
|
+
* This function sets an item sequence for future calls for
|
|
363
|
+
* viterbi(), probability(), and marginal() functions.
|
|
364
|
+
* @param xseq The item sequence to be tagged
|
|
365
|
+
* @throw std::invalid_argument A model is not opened.
|
|
366
|
+
* @throw std::runtime_error An internal error.
|
|
367
|
+
*/
|
|
368
|
+
void set(const ItemSequence &xseq);
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Find the Viterbi label sequence for the item sequence.
|
|
372
|
+
* @return StringList The label sequence predicted.
|
|
373
|
+
* @throw std::invalid_argument A model is not opened.
|
|
374
|
+
* @throw std::runtime_error An internal error.
|
|
375
|
+
*/
|
|
376
|
+
StringList viterbi();
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Compute the probability of the label sequence.
|
|
380
|
+
* @param yseq The label sequence.
|
|
381
|
+
* @throw std::invalid_argument A model is not opened.
|
|
382
|
+
* @throw std::runtime_error An internal error.
|
|
383
|
+
*/
|
|
384
|
+
double probability(const StringList &yseq);
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Compute the marginal probability of the label.
|
|
388
|
+
* @param y The label.
|
|
389
|
+
* @param t The position of the label.
|
|
390
|
+
* @throw std::invalid_argument A model is not opened.
|
|
391
|
+
* @throw std::runtime_error An internal error.
|
|
392
|
+
*/
|
|
393
|
+
double marginal(const std::string &y, const int t);
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Obtain the version number of the library.
|
|
398
|
+
* @return std::string The version string.
|
|
399
|
+
*/
|
|
400
|
+
std::string version();
|
|
401
|
+
|
|
402
|
+
/**@} */
|
|
403
|
+
|
|
404
|
+
} // namespace CRFSuite
|
|
405
|
+
|
|
406
|
+
#endif /*__CRFSUITE_API_HPP__*/
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
//#define __SSE__ 1
|
|
37
|
+
#define LBFGS_FLOAT 64
|
|
38
|
+
|
|
39
|
+
#ifdef _MSC_VER
|
|
40
|
+
/* Microsoft Visual C/C++ specific */
|
|
41
|
+
|
|
42
|
+
#define _CRT_SECURE_NO_WARNINGS 1
|
|
43
|
+
#pragma warning(disable : 4996)
|
|
44
|
+
|
|
45
|
+
#define alloca _alloca
|
|
46
|
+
#define strdup _strdup
|
|
47
|
+
#define open _open
|
|
48
|
+
|
|
49
|
+
#if _MSC_VER < 1900
|
|
50
|
+
/* Pre Microsoft Visual C 2015 */
|
|
51
|
+
|
|
52
|
+
#define isfinite _finite
|
|
53
|
+
#define snprintf _snprintf
|
|
54
|
+
#endif /*_MSC_VER < 1900 */
|
|
55
|
+
|
|
56
|
+
#ifndef __cplusplus
|
|
57
|
+
/* Microsoft Visual C specific */
|
|
58
|
+
|
|
59
|
+
#define inline __forceinline
|
|
60
|
+
|
|
61
|
+
#endif /*__cplusplus*/
|
|
62
|
+
|
|
63
|
+
#endif /*_MSC_VER*/
|
|
64
|
+
|
|
65
|
+
#endif /*__OS_H__*/
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
The BSD license.
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2007, Naoaki Okazaki
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
* Redistributions of source code must retain the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
|
10
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
11
|
+
notice, this list of conditions and the following disclaimer in the
|
|
12
|
+
documentation and/or other materials provided with the distribution.
|
|
13
|
+
* Neither the name of the Northwestern University, University of Tokyo,
|
|
14
|
+
nor the names of its contributors may be used to endorse or promote
|
|
15
|
+
products derived from this software without specific prior written
|
|
16
|
+
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.
|