crfsuite_sys/bindings.rs
1/* automatically generated by rust-bindgen */
2#![allow(unknown_lints)]
3#![allow(clippy::all)]
4use libc::{self, FILE};
5
6pub const CRFSUITE_VERSION: &'static [u8; 7usize] = b"0.12.2\0";
7pub const CRFSUITE_COPYRIGHT: &'static [u8; 39usize] = b"Copyright (c) 2007-2013 Naoaki Okazaki\0";
8
9/// Type of a float value.
10pub type floatval_t = f64;
11
12pub const CRFSUITE_SUCCESS: _bindgen_ty_1 = 0;
13pub const CRFSUITEERR_UNKNOWN: _bindgen_ty_1 = -2147483648;
14pub const CRFSUITEERR_OUTOFMEMORY: _bindgen_ty_1 = -2147483647;
15pub const CRFSUITEERR_NOTSUPPORTED: _bindgen_ty_1 = -2147483646;
16pub const CRFSUITEERR_INCOMPATIBLE: _bindgen_ty_1 = -2147483645;
17pub const CRFSUITEERR_INTERNAL_LOGIC: _bindgen_ty_1 = -2147483644;
18pub const CRFSUITEERR_OVERFLOW: _bindgen_ty_1 = -2147483643;
19pub const CRFSUITEERR_NOTIMPLEMENTED: _bindgen_ty_1 = -2147483642;
20pub type _bindgen_ty_1 = libc::c_int;
21
22/// CRFSuite model interface.
23pub type crfsuite_model_t = tag_crfsuite_model;
24/// CRFSuite trainer interface.
25pub type crfsuite_trainer_t = tag_crfsuite_trainer;
26/// CRFSuite tagger interface.
27pub type crfsuite_tagger_t = tag_crfsuite_tagger;
28/// CRFSuite dictionary interface.
29pub type crfsuite_dictionary_t = tag_crfsuite_dictionary;
30/// CRFSuite parameter interface.
31pub type crfsuite_params_t = tag_crfsuite_params;
32/// An attribute.
33/// An attribute consists of an attribute id with its value.
34#[repr(C)]
35#[derive(Debug, Copy, Clone)]
36pub struct crfsuite_attribute_t {
37 /// < Attribute id.
38 pub aid: libc::c_int,
39 /// < Value of the attribute.
40 pub value: floatval_t,
41}
42/// An item.
43/// An item consists of an array of attributes.
44#[repr(C)]
45#[derive(Debug, Copy, Clone)]
46pub struct crfsuite_item_t {
47 /// Number of contents associated with the item.
48 pub num_contents: libc::c_int,
49 /// Maximum number of contents (internal use).
50 pub cap_contents: libc::c_int,
51 /// Array of the attributes.
52 pub contents: *mut crfsuite_attribute_t,
53}
54/// An instance (sequence of items and labels).
55/// An instance consists of a sequence of items and labels.
56#[repr(C)]
57#[derive(Debug, Copy, Clone)]
58pub struct crfsuite_instance_t {
59 /// Number of items/labels in the sequence.
60 pub num_items: libc::c_int,
61 /// Maximum number of items/labels (internal use).
62 pub cap_items: libc::c_int,
63 /// Array of the item sequence.
64 pub items: *mut crfsuite_item_t,
65 /// Array of the label sequence.
66 pub labels: *mut libc::c_int,
67 /// Instance weight.
68 pub weight: floatval_t,
69 /// Group ID of the instance.
70 pub group: libc::c_int,
71}
72/// A data set.
73/// A data set consists of an array of instances and dictionary objects
74/// for attributes and labels.
75#[repr(C)]
76#[derive(Debug, Copy, Clone)]
77pub struct crfsuite_data_t {
78 /// Number of instances.
79 pub num_instances: libc::c_int,
80 /// Maximum number of instances (internal use).
81 pub cap_instances: libc::c_int,
82 /// Array of instances.
83 pub instances: *mut crfsuite_instance_t,
84 /// Dictionary object for attributes.
85 pub attrs: *mut crfsuite_dictionary_t,
86 /// Dictionary object for labels.
87 pub labels: *mut crfsuite_dictionary_t,
88}
89/// Label-wise performance values.
90#[repr(C)]
91#[derive(Debug, Copy, Clone)]
92pub struct crfsuite_label_evaluation_t {
93 /// Number of correct predictions.
94 pub num_correct: libc::c_int,
95 /// Number of occurrences of the label in the gold-standard data.
96 pub num_observation: libc::c_int,
97 /// Number of predictions.
98 pub num_model: libc::c_int,
99 /// Precision.
100 pub precision: floatval_t,
101 /// Recall.
102 pub recall: floatval_t,
103 /// F1 score.
104 pub fmeasure: floatval_t,
105}
106/// An overall performance values.
107#[repr(C)]
108#[derive(Debug, Copy, Clone)]
109pub struct crfsuite_evaluation_t {
110 /// Number of labels.
111 pub num_labels: libc::c_int,
112 /// Array of label-wise evaluations.
113 pub tbl: *mut crfsuite_label_evaluation_t,
114 /// Number of correctly predicted items.
115 pub item_total_correct: libc::c_int,
116 /// Total number of items.
117 pub item_total_num: libc::c_int,
118 /// Total number of occurrences of labels in the gold-standard data.
119 pub item_total_observation: libc::c_int,
120 /// Total number of predictions.
121 pub item_total_model: libc::c_int,
122 /// Item-level accuracy.
123 pub item_accuracy: floatval_t,
124 /// Number of correctly predicted instances.
125 pub inst_total_correct: libc::c_int,
126 /// Total number of instances.
127 pub inst_total_num: libc::c_int,
128 /// Instance-level accuracy.
129 pub inst_accuracy: floatval_t,
130 /// Macro-averaged precision.
131 pub macro_precision: floatval_t,
132 /// Macro-averaged recall.
133 pub macro_recall: floatval_t,
134 /// Macro-averaged F1 score.
135 pub macro_fmeasure: floatval_t,
136}
137/// Type of callback function for logging.
138///
139/// * `user` Pointer to the user-defined data.
140/// * `format` Format string (compatible with prinf()).
141/// * `args` Optional arguments for the format string.
142///
143/// Returns int \c 0 to continue; non-zero to cancel the training.
144pub type crfsuite_logging_callback = ::std::option::Option<
145 unsafe extern "C" fn(
146 user: *mut libc::c_void,
147 format: *const libc::c_char,
148 args: *mut __va_list_tag,
149 ) -> libc::c_int,
150>;
151
152#[repr(C)]
153#[derive(Debug, Copy, Clone)]
154pub struct tag_crfsuite_model {
155 /// Pointer to the internal data (internal use only).
156 pub internal: *mut libc::c_void,
157 /// Reference counter (internal use only).
158 pub nref: libc::c_int,
159 /// Increment the reference counter.
160 ///
161 /// `model` The pointer to this model instance.
162 ///
163 /// Returns the reference count after this increment.
164 pub addref:
165 ::std::option::Option<unsafe extern "C" fn(model: *mut crfsuite_model_t) -> libc::c_int>,
166 /// Decrement the reference counter.
167 ///
168 /// `model` The pointer to this model instance.
169 ///
170 /// Returns the reference count after this operation.
171 pub release:
172 ::std::option::Option<unsafe extern "C" fn(model: *mut crfsuite_model_t) -> libc::c_int>,
173 /// Obtain the pointer to crfsuite_tagger_t interface.
174 ///
175 /// * `model` The pointer to this model instance.
176 /// * `ptr_tagger` The pointer that receives a `crfsuite_tagger_t` pointer.
177 ///
178 /// Returns the status code.
179 pub get_tagger: ::std::option::Option<
180 unsafe extern "C" fn(
181 model: *mut crfsuite_model_t,
182 ptr_tagger: *mut *mut crfsuite_tagger_t,
183 ) -> libc::c_int,
184 >,
185 /// Obtain the pointer to crfsuite_dictionary_t interface for labels.
186 ///
187 /// * `model` The pointer to this model instance.
188 /// * `ptr_labels` The pointer that receives a crfsuite_dictionary_t pointer.
189 ///
190 /// Returns the status code.
191 pub get_labels: ::std::option::Option<
192 unsafe extern "C" fn(
193 model: *mut crfsuite_model_t,
194 ptr_labels: *mut *mut crfsuite_dictionary_t,
195 ) -> libc::c_int,
196 >,
197 /// Obtain the pointer to crfsuite_dictionary_t interface for attributes.
198 ///
199 /// * `model` The pointer to this model instance.
200 /// * `ptr_attrs` The pointer that receives a crfsuite_dictionary_t pointer.
201 ///
202 /// Returns the status code.
203 pub get_attrs: ::std::option::Option<
204 unsafe extern "C" fn(
205 model: *mut crfsuite_model_t,
206 ptr_attrs: *mut *mut crfsuite_dictionary_t,
207 ) -> libc::c_int,
208 >,
209 /// Print the model in human-readable format.
210 ///
211 /// * `model` The pointer to this model instance.
212 /// * `fpo` The FILE* pointer.
213 ///
214 /// Returns the status code.
215 pub dump: ::std::option::Option<
216 unsafe extern "C" fn(model: *mut crfsuite_model_t, fpo: *mut FILE) -> libc::c_int,
217 >,
218}
219/// CRFSuite trainer interface.
220#[repr(C)]
221#[derive(Debug, Copy, Clone)]
222pub struct tag_crfsuite_trainer {
223 /// Pointer to the internal data (internal use only).
224 pub internal: *mut libc::c_void,
225 /// Reference counter (internal use only).
226 pub nref: libc::c_int,
227 /// Increment the reference counter.
228 ///
229 /// `trainer` The pointer to this trainer instance.
230 ///
231 /// Returns the reference count after this increment.
232 pub addref: ::std::option::Option<
233 unsafe extern "C" fn(trainer: *mut crfsuite_trainer_t) -> libc::c_int,
234 >,
235 /// Decrement the reference counter.
236 ///
237 /// `trainer` The pointer to this trainer instance.
238 ///
239 /// Returns the reference count after this operation.
240 pub release: ::std::option::Option<
241 unsafe extern "C" fn(trainer: *mut crfsuite_trainer_t) -> libc::c_int,
242 >,
243 /// Obtain the pointer to crfsuite_params_t interface.
244 ///
245 /// `trainer` The pointer to this trainer instance.
246 ///
247 /// Returns crfsuite_params_t* The pointer to crfsuite_params_t.
248 pub params: ::std::option::Option<
249 unsafe extern "C" fn(trainer: *mut crfsuite_trainer_t) -> *mut crfsuite_params_t,
250 >,
251 /// Set the callback function and user-defined data.
252 ///
253 /// * `trainer` The pointer to this trainer instance.
254 /// * `user` The pointer to the user-defined data.
255 /// * `cbm` The pointer to the callback function.
256 pub set_message_callback: ::std::option::Option<
257 unsafe extern "C" fn(
258 trainer: *mut crfsuite_trainer_t,
259 user: *mut libc::c_void,
260 cbm: crfsuite_logging_callback,
261 ),
262 >,
263 /// Start a training process.
264 ///
265 /// * `trainer` The pointer to this trainer instance.
266 /// * `data` The poiinter to the data set.
267 /// * `filename` The filename to which the trainer stores the model.
268 /// If an empty string is specified, this function
269 /// does not sture the model to a file.
270 /// * `holdout` The holdout group.
271 ///
272 /// Returns the status code.
273 pub train: ::std::option::Option<
274 unsafe extern "C" fn(
275 trainer: *mut crfsuite_trainer_t,
276 data: *const crfsuite_data_t,
277 filename: *const libc::c_char,
278 holdout: libc::c_int,
279 ) -> libc::c_int,
280 >,
281}
282/// CRFSuite tagger interface.
283#[repr(C)]
284#[derive(Debug, Copy, Clone)]
285pub struct tag_crfsuite_tagger {
286 /// Pointer to the internal data (internal use only).
287 pub internal: *mut libc::c_void,
288 /// Reference counter (internal use only).
289 pub nref: libc::c_int,
290 /// Increment the reference counter.
291 ///
292 /// `tagger` The pointer to this tagger instance.
293 ///
294 /// Returns the reference count after this increment.
295 pub addref:
296 ::std::option::Option<unsafe extern "C" fn(tagger: *mut crfsuite_tagger_t) -> libc::c_int>,
297 /// Decrement the reference counter.
298 ///
299 /// `tagger` The pointer to this tagger instance.
300 ///
301 /// Returns the reference count after this operation.
302 pub release:
303 ::std::option::Option<unsafe extern "C" fn(tagger: *mut crfsuite_tagger_t) -> libc::c_int>,
304 /// Set an instance to the tagger.
305 ///
306 /// * `tagger` The pointer to this tagger instance.
307 /// * `inst` The item sequence to be tagged.
308 ///
309 /// Returns the status code.
310 pub set: ::std::option::Option<
311 unsafe extern "C" fn(
312 tagger: *mut crfsuite_tagger_t,
313 inst: *mut crfsuite_instance_t,
314 ) -> libc::c_int,
315 >,
316 /// Obtain the number of items in the current instance.
317 ///
318 /// `tagger` The pointer to this tagger instance.
319 ///
320 /// Returns the number of items of the instance set by
321 /// set() function.
322 ///
323 /// Returns the status code.
324 pub length:
325 ::std::option::Option<unsafe extern "C" fn(tagger: *mut crfsuite_tagger_t) -> libc::c_int>,
326 /// Find the Viterbi label sequence.
327 ///
328 /// * `tagger` The pointer to this tagger instance.
329 /// * `labels` The label array that receives the Viterbi label
330 /// * `sequence` The number of elements in the array must
331 // be no smaller than the number of item.
332 /// * `ptr_score` The pointer to a float variable that receives the
333 /// score of the Viterbi label sequence.
334 ///
335 /// Returns the status code.
336 pub viterbi: ::std::option::Option<
337 unsafe extern "C" fn(
338 tagger: *mut crfsuite_tagger_t,
339 labels: *mut libc::c_int,
340 ptr_score: *mut floatval_t,
341 ) -> libc::c_int,
342 >,
343 /// Compute the score of a label sequence.
344 ///
345 /// * `tagger` The pointer to this tagger instance.
346 /// * `path` The label sequence.
347 /// * `ptr_score` The pointer to a float variable that receives the
348 /// score of the label sequence.
349 ///
350 /// Returns the status code.
351 pub score: ::std::option::Option<
352 unsafe extern "C" fn(
353 tagger: *mut crfsuite_tagger_t,
354 path: *mut libc::c_int,
355 ptr_score: *mut floatval_t,
356 ) -> libc::c_int,
357 >,
358 /// Compute the log of the partition factor (normalization constant).
359 ///
360 /// * `tagger` The pointer to this tagger instance.
361 /// * `ptr_score` The pointer to a float variable that receives the
362 /// logarithm of the partition factor.
363 ///
364 /// Returns the status code.
365 pub lognorm: ::std::option::Option<
366 unsafe extern "C" fn(
367 tagger: *mut crfsuite_tagger_t,
368 ptr_norm: *mut floatval_t,
369 ) -> libc::c_int,
370 >,
371 /// Compute the marginal probability of a label at a position.
372 ///
373 /// This function computes P(y_t = l | x), the probability when
374 /// y_t is the label (l).
375 ///
376 /// * `tagger` The pointer to this tagger instance.
377 /// * `l` The label.
378 /// * `t` The position.
379 /// * `ptr_prob` The pointer to a float variable that receives the
380 /// marginal probability.
381 ///
382 /// Returns the status code.
383 pub marginal_point: ::std::option::Option<
384 unsafe extern "C" fn(
385 tagger: *mut crfsuite_tagger_t,
386 l: libc::c_int,
387 t: libc::c_int,
388 ptr_prob: *mut floatval_t,
389 ) -> libc::c_int,
390 >,
391 /// Compute the marginal probability of a partial label sequence.
392 ///
393 /// * `tagger` The pointer to this tagger instance.
394 /// * `path` The partial label sequence.
395 /// * `begin` The start position of the partial label sequence.
396 /// * `end` The last+1 position of the partial label sequence.
397 /// * `ptr_prob` The pointer to a float variable that receives the
398 /// marginal probability.
399 ///
400 /// Returns the status code.
401 pub marginal_path: ::std::option::Option<
402 unsafe extern "C" fn(
403 tagger: *mut crfsuite_tagger_t,
404 path: *const libc::c_int,
405 begin: libc::c_int,
406 end: libc::c_int,
407 ptr_prob: *mut floatval_t,
408 ) -> libc::c_int,
409 >,
410}
411/// CRFSuite dictionary interface.
412#[repr(C)]
413#[derive(Debug, Copy, Clone)]
414pub struct tag_crfsuite_dictionary {
415 /// Pointer to the internal data (internal use only).
416 pub internal: *mut libc::c_void,
417 /// Reference counter (internal use only).
418 pub nref: libc::c_int,
419 /// Increment the reference counter.
420 ///
421 /// `dic` The pointer to this dictionary instance.
422 ///
423 /// Returns the reference count after this increment.
424 pub addref:
425 ::std::option::Option<unsafe extern "C" fn(dic: *mut crfsuite_dictionary_t) -> libc::c_int>,
426 /// Decrement the reference counter.
427 ///
428 /// `dic` The pointer to this dictionary instance.
429 ///
430 /// Returns the reference count after this operation.
431 pub release:
432 ::std::option::Option<unsafe extern "C" fn(dic: *mut crfsuite_dictionary_t) -> libc::c_int>,
433 /// Assign and obtain the integer ID for the string.
434 ///
435 /// * `dic` The pointer to this dictionary instance.
436 /// * `str` The string.
437 ///
438 /// Returns the ID associated with the string if any,
439 /// the new ID otherwise.
440 pub get: ::std::option::Option<
441 unsafe extern "C" fn(
442 dic: *mut crfsuite_dictionary_t,
443 str: *const libc::c_char,
444 ) -> libc::c_int,
445 >,
446 /// Obtain the integer ID for the string.
447 ///
448 /// * `dic` The pointer to this dictionary instance.
449 /// * `str` The string.
450 ///
451 /// Returns the ID associated with the string if any,
452 /// \c -1 otherwise.
453 pub to_id: ::std::option::Option<
454 unsafe extern "C" fn(
455 dic: *mut crfsuite_dictionary_t,
456 str: *const libc::c_char,
457 ) -> libc::c_int,
458 >,
459 /// Obtain the string for the ID.
460 ///
461 /// * `dic` The pointer to this dictionary instance.
462 /// * `id` the string ID.
463 /// * `pstr` \c *pstr points to the string associated with
464 /// the ID if any, \c NULL otherwise.
465 ///
466 /// Returns int \c 0 if the string ID is associated with a string,
467 /// \c 1 otherwise.
468 pub to_string: ::std::option::Option<
469 unsafe extern "C" fn(
470 dic: *mut crfsuite_dictionary_t,
471 id: libc::c_int,
472 pstr: *mut *const libc::c_char,
473 ) -> libc::c_int,
474 >,
475 /// Obtain the number of strings in the dictionary.
476 ///
477 /// `dic` The pointer to this dictionary instance.
478 ///
479 /// Returns the number of strings stored in the dictionary.
480 pub num:
481 ::std::option::Option<unsafe extern "C" fn(dic: *mut crfsuite_dictionary_t) -> libc::c_int>,
482 /// Free the memory block allocated by to_string() function.
483 ///
484 /// * `dic` The pointer to this dictionary instance.
485 /// * `str` The pointer to the string whose memory block is
486 /// freed.
487 pub free: ::std::option::Option<
488 unsafe extern "C" fn(dic: *mut crfsuite_dictionary_t, str: *const libc::c_char),
489 >,
490}
491/// CRFSuite parameter interface.
492#[repr(C)]
493#[derive(Debug, Copy, Clone)]
494pub struct tag_crfsuite_params {
495 /// Pointer to the instance data (internal use only).
496 pub internal: *mut libc::c_void,
497 /// Reference counter (internal use only).
498 pub nref: libc::c_int,
499 /// Increment the reference counter.
500 ///
501 /// `params` The pointer to this parameter instance.
502 ///
503 /// Returns the reference count after this increment.
504 pub addref:
505 ::std::option::Option<unsafe extern "C" fn(params: *mut crfsuite_params_t) -> libc::c_int>,
506 /// Decrement the reference counter.
507 ///
508 /// `params` The pointer to this parameter instance.
509 ///
510 /// Returns the reference count after this operation.
511 pub release:
512 ::std::option::Option<unsafe extern "C" fn(params: *mut crfsuite_params_t) -> libc::c_int>,
513 /// Obtain the number of available parameters.
514 ///
515 /// `params` The pointer to this parameter instance.
516 ///
517 /// Returns the number of parameters maintained by this object.
518 pub num:
519 ::std::option::Option<unsafe extern "C" fn(params: *mut crfsuite_params_t) -> libc::c_int>,
520 /// Obtain the name of a parameter.
521 ///
522 /// * `params` The pointer to this parameter instance.
523 /// * `i` The parameter index.
524 /// * `ptr_name` *ptr_name points to the parameter name.
525 ///
526 /// Returns int \c 0 always.
527 pub name: ::std::option::Option<
528 unsafe extern "C" fn(
529 params: *mut crfsuite_params_t,
530 i: libc::c_int,
531 ptr_name: *mut *mut libc::c_char,
532 ) -> libc::c_int,
533 >,
534 /// Set a parameter value.
535 ///
536 /// * `params` The pointer to this parameter instance.
537 /// * `name` The parameter name.
538 /// * `value` The parameter value in string format.
539 ///
540 /// Returns int \c 0 if the parameter is found, \c -1 otherwise.
541 pub set: ::std::option::Option<
542 unsafe extern "C" fn(
543 params: *mut crfsuite_params_t,
544 name: *const libc::c_char,
545 value: *const libc::c_char,
546 ) -> libc::c_int,
547 >,
548 /// Get a parameter value.
549 ///
550 /// * `params` The pointer to this parameter instance.
551 /// * `name` The parameter name.
552 /// * `ptr_value` *ptr_value presents the parameter value in string
553 /// format.
554 ///
555 /// Returns int \c 0 if the parameter is found, \c -1 otherwise.
556 pub get: ::std::option::Option<
557 unsafe extern "C" fn(
558 params: *mut crfsuite_params_t,
559 name: *const libc::c_char,
560 ptr_value: *mut *mut libc::c_char,
561 ) -> libc::c_int,
562 >,
563 /// Set an integer value of a parameter.
564 ///
565 /// * `params` The pointer to this parameter instance.
566 /// * `name` The parameter name.
567 /// * `value` The parameter value.
568 ///
569 /// Returns int \c 0 if the parameter value is set successfully,
570 /// \c -1 otherwise (unknown parameter or incompatible
571 /// type).
572 pub set_int: ::std::option::Option<
573 unsafe extern "C" fn(
574 params: *mut crfsuite_params_t,
575 name: *const libc::c_char,
576 value: libc::c_int,
577 ) -> libc::c_int,
578 >,
579 /// Set a float value of a parameter.
580 ///
581 /// * `params` The pointer to this parameter instance.
582 /// * `name` The parameter name.
583 /// * `value` The parameter value.
584 ///
585 /// Returns int \c 0 if the parameter value is set successfully,
586 /// \c -1 otherwise (unknown parameter or incompatible
587 /// type).
588 pub set_float: ::std::option::Option<
589 unsafe extern "C" fn(
590 params: *mut crfsuite_params_t,
591 name: *const libc::c_char,
592 value: floatval_t,
593 ) -> libc::c_int,
594 >,
595 /// Set a string value of a parameter.
596 ///
597 /// * `params` The pointer to this parameter instance.
598 /// * `name` The parameter name.
599 /// * `value` The parameter value.
600 ///
601 /// Returns int \c 0 if the parameter value is set successfully,
602 /// \c -1 otherwise (unknown parameter or incompatible
603 /// type).
604 pub set_string: ::std::option::Option<
605 unsafe extern "C" fn(
606 params: *mut crfsuite_params_t,
607 name: *const libc::c_char,
608 value: *const libc::c_char,
609 ) -> libc::c_int,
610 >,
611 /// Get an integer value of a parameter.
612 ///
613 /// * `params` The pointer to this parameter instance.
614 /// * `name` The parameter name.
615 /// * `ptr_value` The pointer to a variable that receives the
616 /// integer value.
617 ///
618 /// Returns int \c 0 if the parameter value is obtained
619 /// successfully, \c -1 otherwise (unknown parameter
620 /// or incompatible type).
621 pub get_int: ::std::option::Option<
622 unsafe extern "C" fn(
623 params: *mut crfsuite_params_t,
624 name: *const libc::c_char,
625 ptr_value: *mut libc::c_int,
626 ) -> libc::c_int,
627 >,
628 /// Get a float value of a parameter.
629 ///
630 /// * `params` The pointer to this parameter instance.
631 /// * `name` The parameter name.
632 /// * `ptr_value` The pointer to a variable that receives the
633 /// float value.
634 ///
635 /// Returns int \c 0 if the parameter value is obtained
636 /// successfully, \c -1 otherwise (unknown parameter
637 /// or incompatible type).
638 pub get_float: ::std::option::Option<
639 unsafe extern "C" fn(
640 params: *mut crfsuite_params_t,
641 name: *const libc::c_char,
642 ptr_value: *mut floatval_t,
643 ) -> libc::c_int,
644 >,
645 /// Get a string value of a parameter.
646 ///
647 /// * `params` The pointer to this parameter instance.
648 /// * `name` The parameter name.
649 /// * `ptr_value` *ptr_value presents the parameter value.
650 ///
651 /// Returns int \c 0 if the parameter value is obtained
652 /// successfully, \c -1 otherwise (unknown parameter
653 /// or incompatible type).
654 pub get_string: ::std::option::Option<
655 unsafe extern "C" fn(
656 params: *mut crfsuite_params_t,
657 name: *const libc::c_char,
658 ptr_value: *mut *mut libc::c_char,
659 ) -> libc::c_int,
660 >,
661 /// Get the help message of a parameter.
662 ///
663 /// * `params` The pointer to this parameter instance.
664 /// * `name` The parameter name.
665 /// * `ptr_type` The pointer to \c char* to which this function
666 /// store the type of the parameter.
667 /// * `ptr_help` The pointer to \c char* to which this function
668 /// store the help message of the parameter.
669 ///
670 /// Returns int \c 0 if the parameter is found, \c -1 otherwise.
671 pub help: ::std::option::Option<
672 unsafe extern "C" fn(
673 params: *mut crfsuite_params_t,
674 name: *const libc::c_char,
675 ptr_type: *mut *mut libc::c_char,
676 ptr_help: *mut *mut libc::c_char,
677 ) -> libc::c_int,
678 >,
679 /// Free the memory block of a string allocated by this object.
680 ///
681 /// * `params` The pointer to this parameter instance.
682 /// * `str` The pointer to the string.
683 pub free: ::std::option::Option<
684 unsafe extern "C" fn(params: *mut crfsuite_params_t, str: *const libc::c_char),
685 >,
686}
687extern "C" {
688
689 /// Create an instance of an object by an interface identifier.
690 ///
691 /// * `iid` The interface identifier.
692 /// * `ptr` The pointer to \c void* that points to the
693 /// instance of the object if successful,
694 /// *ptr points to \c NULL otherwise.
695 ///
696 /// Returns int \c 1 if this function creates an object successfully,
697 /// \c 0 otherwise. Note that this is inconsistent with the
698 /// other CRFsuite API calls.
699 pub fn crfsuite_create_instance(
700 iid: *const libc::c_char,
701 ptr: *mut *mut libc::c_void,
702 ) -> libc::c_int;
703}
704extern "C" {
705
706 /// Create an instance of a model object from a model file.
707 ///
708 /// * `filename` The filename of the model.
709 /// * `ptr` The pointer to \c void* that points to the
710 /// instance of the model object if successful,
711 /// *ptr points to \c NULL otherwise.
712 ///
713 /// Returns int \c 0 if this function creates an object successfully,
714 /// \c 1 otherwise.
715 pub fn crfsuite_create_instance_from_file(
716 filename: *const libc::c_char,
717 ptr: *mut *mut libc::c_void,
718 ) -> libc::c_int;
719}
720extern "C" {
721
722 /// Create an instance of a model object from a model in memory.
723 ///
724 /// * `data` A pointer to the model data.
725 /// Must be 16-byte aligned.
726 /// * `size` A size (in bytes) of the model data.
727 /// * `ptr` The pointer to \c void* that points to the
728 /// instance of the model object if successful,
729 /// *ptr points to \c NULL otherwise.
730 ///
731 /// Returns int \c 0 if this function creates an object successfully,
732 /// \c 1 otherwise
733 pub fn crfsuite_create_instance_from_memory(
734 data: *const libc::c_void,
735 size: usize,
736 ptr: *mut *mut libc::c_void,
737 ) -> libc::c_int;
738}
739extern "C" {
740
741 /// Create instances of tagging object from a model file.
742 ///
743 /// * `filename` The filename of the model.
744 /// * `ptr_tagger` The pointer to \c void* that points to the
745 /// instance of the tagger object if successful,
746 /// *ptr points to \c NULL otherwise.
747 /// * `ptr_attrs` The pointer to \c void* that points to the
748 /// instance of the dictionary object for attributes
749 /// if successful, *ptr points to \c NULL otherwise.
750 /// * `ptr_labels` The pointer to \c void* that points to the
751 /// instance of the dictionary object for labels
752 /// if successful, *ptr points to \c NULL otherwise.
753 ///
754 /// Returns int \c 0 if this function creates an object successfully,
755 /// \c 1 otherwise.
756 pub fn crfsuite_create_tagger(
757 filename: *const libc::c_char,
758 ptr_tagger: *mut *mut crfsuite_tagger_t,
759 ptr_attrs: *mut *mut crfsuite_dictionary_t,
760 ptr_labels: *mut *mut crfsuite_dictionary_t,
761 ) -> libc::c_int;
762}
763extern "C" {
764
765 /// Initialize an attribute structure.
766 ///
767 /// `attr` The pointer to crfsuite_attribute_t.
768 pub fn crfsuite_attribute_init(attr: *mut crfsuite_attribute_t);
769}
770extern "C" {
771
772 /// Set an attribute and its value.
773 ///
774 /// * `attr` The pointer to crfsuite_attribute_t.
775 /// * `aid` The attribute identifier.
776 /// * `value` The attribute value.
777 pub fn crfsuite_attribute_set(
778 attr: *mut crfsuite_attribute_t,
779 aid: libc::c_int,
780 value: floatval_t,
781 );
782}
783extern "C" {
784
785 /// Copy the content of an attribute structure.
786 ///
787 /// * `dst` The pointer to the destination.
788 /// * `src` The pointer to the source.
789 pub fn crfsuite_attribute_copy(
790 dst: *mut crfsuite_attribute_t,
791 src: *const crfsuite_attribute_t,
792 );
793}
794extern "C" {
795
796 /// Swap the contents of two attribute structures.
797 ///
798 /// * `x` The pointer to an attribute structure.
799 /// * `y` The pointer to another attribute structure.
800 pub fn crfsuite_attribute_swap(x: *mut crfsuite_attribute_t, y: *mut crfsuite_attribute_t);
801}
802extern "C" {
803
804 /// Initialize an item structure.
805 ///
806 /// `item` The pointer to crfsuite_item_t.
807 pub fn crfsuite_item_init(item: *mut crfsuite_item_t);
808}
809extern "C" {
810
811 /// Initialize an item structure with the number of attributes.
812 ///
813 /// * `item` The pointer to crfsuite_item_t.
814 /// * `num_attributes` The number of attributes.
815 pub fn crfsuite_item_init_n(item: *mut crfsuite_item_t, num_attributes: libc::c_int);
816}
817extern "C" {
818
819 /// Uninitialize an item structure.
820 ///
821 /// `item` The pointer to crfsuite_item_t.
822 pub fn crfsuite_item_finish(item: *mut crfsuite_item_t);
823}
824extern "C" {
825
826 /// Copy the content of an item structure.
827 ///
828 /// * `dst` The pointer to the destination.
829 /// * `src` The pointer to the source.
830 pub fn crfsuite_item_copy(dst: *mut crfsuite_item_t, src: *const crfsuite_item_t);
831}
832extern "C" {
833
834 /// Swap the contents of two item structures.
835 ///
836 /// * `x` The pointer to an item structure.
837 /// * `y` The pointer to another item structure.
838 pub fn crfsuite_item_swap(x: *mut crfsuite_item_t, y: *mut crfsuite_item_t);
839}
840extern "C" {
841
842 /// Append an attribute to the item structure.
843 ///
844 /// * `item` The pointer to crfsuite_item_t.
845 /// * `attr` The attribute to be added to the item.
846 ///
847 /// Returns int \c 0 if successful, \c -1 otherwise.
848 pub fn crfsuite_item_append_attribute(
849 item: *mut crfsuite_item_t,
850 attr: *const crfsuite_attribute_t,
851 ) -> libc::c_int;
852}
853extern "C" {
854
855 /// Check whether the item has no attribute.
856 ///
857 /// `item` The pointer to crfsuite_item_t.
858 ///
859 /// Returns int \c 1 if the item has no attribute, \c 0 otherwise.
860 pub fn crfsuite_item_empty(item: *mut crfsuite_item_t) -> libc::c_int;
861}
862extern "C" {
863
864 /// Initialize an instance structure.
865 ///
866 /// `seq` The pointer to crfsuite_instance_t.
867 pub fn crfsuite_instance_init(seq: *mut crfsuite_instance_t);
868}
869extern "C" {
870
871 /// Initialize an instance structure with the number of items.
872 ///
873 /// * `seq` The pointer to crfsuite_instance_t.
874 /// * `num_items` The number of items.
875 pub fn crfsuite_instance_init_n(seq: *mut crfsuite_instance_t, num_items: libc::c_int);
876}
877extern "C" {
878
879 /// Uninitialize an instance structure.
880 ///
881 /// `seq` The pointer to crfsuite_instance_t.
882 pub fn crfsuite_instance_finish(seq: *mut crfsuite_instance_t);
883}
884extern "C" {
885
886 /// Copy the content of an instance structure.
887 ///
888 /// * `dst` The pointer to the destination.
889 /// * `src` The pointer to the source.
890 pub fn crfsuite_instance_copy(dst: *mut crfsuite_instance_t, src: *const crfsuite_instance_t);
891}
892extern "C" {
893
894 /// Swap the contents of two instance structures.
895 ///
896 /// * `x` The pointer to an instance structure.
897 /// * `y` The pointer to another instance structure.
898 pub fn crfsuite_instance_swap(x: *mut crfsuite_instance_t, y: *mut crfsuite_instance_t);
899}
900extern "C" {
901
902 /// Append a pair of item and label to the instance structure.
903 ///
904 /// * `seq` The pointer to crfsuite_instance_t.
905 /// * `item` The item to be added to the instance.
906 /// * `label` The label to be added to the instance.
907 ///
908 /// Returns int \c 0 if successful, \c -1 otherwise.
909 pub fn crfsuite_instance_append(
910 seq: *mut crfsuite_instance_t,
911 item: *const crfsuite_item_t,
912 label: libc::c_int,
913 ) -> libc::c_int;
914}
915extern "C" {
916
917 /// Check whether the instance has no item.
918 ///
919 /// `seq` The pointer to crfsuite_instance_t.
920 ///
921 /// Returns int \c 1 if the instance has no attribute, \c 0 otherwise.
922 pub fn crfsuite_instance_empty(seq: *mut crfsuite_instance_t) -> libc::c_int;
923}
924extern "C" {
925
926 /// Initialize a dataset structure.
927 ///
928 /// `data` The pointer to crfsuite_data_t.
929 pub fn crfsuite_data_init(data: *mut crfsuite_data_t);
930}
931extern "C" {
932
933 /// Initialize a dataset structure with the number of instances.
934 ///
935 /// * `data` The pointer to crfsuite_data_t.
936 /// * `n` The number of instances.
937 pub fn crfsuite_data_init_n(data: *mut crfsuite_data_t, n: libc::c_int);
938}
939extern "C" {
940
941 /// Uninitialize a dataset structure.
942 ///
943 /// `data` The pointer to crfsuite_data_t.
944 pub fn crfsuite_data_finish(data: *mut crfsuite_data_t);
945}
946extern "C" {
947
948 /// Copy the content of a dataset structure.
949 ///
950 /// * `dst` The pointer to the destination.
951 /// * `src` The pointer to the source.
952 pub fn crfsuite_data_copy(dst: *mut crfsuite_data_t, src: *const crfsuite_data_t);
953}
954extern "C" {
955
956 /// Swap the contents of two dataset structures.
957 ///
958 /// * `x` The pointer to a dataset structure.
959 /// * `y` The pointer to another dataset structure.
960 pub fn crfsuite_data_swap(x: *mut crfsuite_data_t, y: *mut crfsuite_data_t);
961}
962extern "C" {
963
964 /// Append an instance to the dataset structure.
965 ///
966 /// * `data` The pointer to crfsuite_data_t.
967 /// * `inst` The instance to be added to the dataset.
968 ///
969 /// Returns int \c 0 if successful, \c -1 otherwise.
970 pub fn crfsuite_data_append(
971 data: *mut crfsuite_data_t,
972 inst: *const crfsuite_instance_t,
973 ) -> libc::c_int;
974}
975extern "C" {
976
977 /// Obtain the maximum length of the instances in the dataset.
978 ///
979 /// `data` The pointer to crfsuite_data_t.
980 ///
981 /// Returns the maximum number of items of the instances in the
982 /// dataset.
983 pub fn crfsuite_data_maxlength(data: *mut crfsuite_data_t) -> libc::c_int;
984}
985extern "C" {
986
987 /// Obtain the total number of items in the dataset.
988 ///
989 /// `data` The pointer to crfsuite_data_t.
990 ///
991 /// Returns the total number of items in the dataset.
992 pub fn crfsuite_data_totalitems(data: *mut crfsuite_data_t) -> libc::c_int;
993}
994extern "C" {
995
996 /// Initialize an evaluation structure.
997 ///
998 /// * `eval` The pointer to crfsuite_evaluation_t.
999 /// * `n` The number of labels in the dataset.
1000 pub fn crfsuite_evaluation_init(eval: *mut crfsuite_evaluation_t, n: libc::c_int);
1001}
1002extern "C" {
1003
1004 /// Uninitialize an evaluation structure.
1005 ///
1006 /// `eval` The pointer to crfsuite_evaluation_t.
1007 pub fn crfsuite_evaluation_finish(eval: *mut crfsuite_evaluation_t);
1008}
1009extern "C" {
1010
1011 /// Reset an evaluation structure.
1012 ///
1013 /// `eval` The pointer to crfsuite_evaluation_t.
1014 pub fn crfsuite_evaluation_clear(eval: *mut crfsuite_evaluation_t);
1015}
1016extern "C" {
1017
1018 /// Accmulate the correctness of the predicted label sequence.
1019 ///
1020 /// * `eval` The pointer to crfsuite_evaluation_t.
1021 /// * `reference` The reference label sequence.
1022 /// * `prediction` The predicted label sequence.
1023 /// * `T` The length of the label sequence.
1024 ///
1025 /// Returns int \c 0 if succeeded, \c 1 otherwise.
1026 pub fn crfsuite_evaluation_accmulate(
1027 eval: *mut crfsuite_evaluation_t,
1028 reference: *const libc::c_int,
1029 prediction: *const libc::c_int,
1030 T: libc::c_int,
1031 ) -> libc::c_int;
1032}
1033extern "C" {
1034
1035 /// Finalize the evaluation result.
1036 ///
1037 /// `eval` The pointer to crfsuite_evaluation_t.
1038 pub fn crfsuite_evaluation_finalize(eval: *mut crfsuite_evaluation_t);
1039}
1040extern "C" {
1041
1042 /// Print the evaluation result.
1043 ///
1044 /// * `eval` The pointer to crfsuite_evaluation_t.
1045 /// * `labels` The pointer to the label dictionary.
1046 /// * `cbm` The callback function to receive the evaluation result.
1047 /// * `user` The pointer to the user data that is forwarded to the
1048 /// callback function.
1049 pub fn crfsuite_evaluation_output(
1050 eval: *mut crfsuite_evaluation_t,
1051 labels: *mut crfsuite_dictionary_t,
1052 cbm: crfsuite_logging_callback,
1053 user: *mut libc::c_void,
1054 );
1055}
1056extern "C" {
1057
1058 /// Increments the value of the integer variable as an atomic operation.
1059 ///
1060 /// `count` The pointer to the integer variable.
1061 ///
1062 /// Returns the value after this increment.
1063 pub fn crfsuite_interlocked_increment(count: *mut libc::c_int) -> libc::c_int;
1064}
1065extern "C" {
1066
1067 /// Decrements the value of the integer variable as an atomic operation.
1068 ///
1069 /// `count` The pointer to the integer variable.
1070 ///
1071 /// Returns the value after this decrement.
1072 pub fn crfsuite_interlocked_decrement(count: *mut libc::c_int) -> libc::c_int;
1073}
1074
1075#[repr(C)]
1076#[derive(Debug, Copy, Clone)]
1077pub struct __va_list_tag {
1078 pub gp_offset: libc::c_uint,
1079 pub fp_offset: libc::c_uint,
1080 pub overflow_arg_area: *mut libc::c_void,
1081 pub reg_save_area: *mut libc::c_void,
1082}