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
//! Pure Rust implementation of Conditional Random Fields (CRF)
//!
//! This library provides both training and prediction capabilities for linear-chain CRFs.
//!
//! # Examples
//!
//! ## Training
//!
//! ```no_run
//! use crfs::train::Trainer;
//! use crfs::Attribute;
//! use std::path::Path;
//!
//! let mut trainer = Trainer::lbfgs();
//! trainer.verbose(true);
//!
//! let xseq = vec![
//! vec![Attribute::new("walk", 1.0)],
//! vec![Attribute::new("shop", 1.0)],
//! ];
//! let yseq = vec!["sunny", "rainy"];
//! trainer.append(&xseq, &yseq)?;
//!
//! trainer.params_mut().set_c2(1.0)?;
//! trainer.train(Path::new("model.crfsuite"))?;
//! # Ok::<(), std::io::Error>(())
//! ```
//!
//! ## Prediction
//!
//! ```no_run
//! use crfs::{Attribute, Model};
//!
//! let model_data = std::fs::read("model.crfsuite")?;
//! let model = Model::new(&model_data)?;
//! let tagger = model.tagger()?;
//!
//! let xseq = vec![
//! vec![Attribute::new("walk", 1.0)],
//! vec![Attribute::new("shop", 1.0)],
//! ];
//! let result = tagger.tag(&xseq)?;
//! # Ok::<(), std::io::Error>(())
//! ```
/// Training module containing all components for training CRF models
// Re-export main types
pub use Attribute;
pub use Model;
pub use Tagger;
// Re-export training types for convenience
pub use Trainer;