Skip to main content

Crate nerrs

Crate nerrs 

Source
Expand description

§nerrs

CRF-based Named Entity Recognition for Persian text.

Uses crfrs for model training and Viterbi inference.

§Entity types

The default tagset uses BIO encoding over these entity classes:

TagMeaning
OOutside any entity
B-PER / I-PERPerson name
B-ORG / I-ORGOrganisation
B-LOC / I-LOCLocation
B-DAT / I-DATDate
B-TIM / I-TIMTime
B-MON / I-MONMoney / currency amount
B-PCT / I-PCTPercentage
B-EVE / I-EVEEvent

§Quick start

use nerrs::NerTagger;

let mut tagger = NerTagger::new();
tagger.load_model("ner.model").unwrap();
let entities = tagger.tag(&["علی", "به", "تهران", "رفت", "."]).unwrap();
// → [("علی","B-PER"), ("به","O"), ("تهران","B-LOC"), ("رفت","O"), (".","O")]

§Training

use nerrs::{NerTagger, crfrs::TrainConfig};

// IOB-tagged corpus: Vec<Vec<(word, ner_tag)>>
let corpus: Vec<Vec<(String, String)>> = vec![];
NerTagger::train_and_save(&corpus, "ner.model", TrainConfig::default()).unwrap();

Re-exports§

pub use error::Error;
pub use error::Result;
pub use tagger::extract_entities;
pub use tagger::NerTagger;
pub use crfrs;

Modules§

error
Error types for nerrs.
features
Feature extraction for Persian NER.
tagger
CRF-based Persian NER tagger.

Constants§

DEFAULT_LABELS
Default NER labels in BIO encoding.