Skip to main content

Crate crftag

Crate crftag 

Source
Expand description

§crftag

CRF-based POS tagger and shallow parser (chunker) built on crfrs.

Fully independent — drop it into any Rust project.

§Features

  • POSTagger — structured-perceptron tagger
  • Chunker — IOB chunker (shallow parser)
  • RuleBasedChunker — grammar-based chunker, no model file required
  • tree2brackets — formats a parse result as a bracketed string
  • features — raw feature extraction (for custom models)
  • crfrs — re-exported; use for training/loading models directly

§Quick start

use crftag::POSTagger;

let mut tagger = POSTagger::new();
tagger.load_model("pos_tagger.model").unwrap();
let tagged = tagger.tag(&["من", "به", "مدرسه", "رفتم", "."]).unwrap();

§Training

use crftag::{POSTagger, crfrs::TrainConfig};

let corpus: Vec<Vec<(String, String)>> = vec![];  // (word, tag) pairs
POSTagger::train_and_save(&corpus, "pos_tagger.model", TrainConfig::default()).unwrap();

Re-exports§

pub use chunker::iob_to_tree;
pub use chunker::tree2brackets;
pub use chunker::Chunker;
pub use chunker::ChunkedSentence;
pub use chunker::ChunkedToken;
pub use chunker::ParseNode;
pub use chunker::RuleBasedChunker;
pub use error::Error;
pub use error::Result;
pub use tagger::POSTagger;
pub use crfrs;

Modules§

chunker
Shallow parser (chunker) for Persian text.
error
Error types for crftag.
features
Feature extraction for Persian POS tagging and chunking.
tagger
CRF-based Persian POS tagger.