Skip to main content

Crate novel_segment

Crate novel_segment 

Source
Expand description

Chinese word segmentation for web novels.

This crate is a Rust port of the TypeScript novel-segment package. Other Rust programs should depend on this crate only:

ws-segment-rs = { path = "../ws-segment-rs/crates/novel-segment" }
use novel_segment::{DoSegmentOptions, Segment, SegmentOptions};

fn main() -> Result<(), novel_segment::Error> {
    let mut seg = Segment::new(SegmentOptions { auto_cjk: true, ..Default::default() });
    seg.use_default()?;
    let words = seg.do_segment("這是一個中文分詞模組。", DoSegmentOptions::default());
    for w in words {
        println!("{} {:?}", w.w, w.p);
    }
    Ok(())
}

Structs§

DoSegmentOptions
Per-call segmentation options.
POSTAG
POS tag bit flags (identical numeric values to the TypeScript POSTAG enum).
Segment
Chinese word segmenter.
SegmentOptions
Segmenter construction options.
TestRequest
TestResult
Word
A segmented word. Field names match the JavaScript IWord object.

Enums§

Error
Library error.
ExpectedItem
SegmentMode

Traits§

Optimizer
Tokenizer

Functions§

apply_extras
convert_joined
crlf_normalize
load_json_config
process_text
run_test
segment_words
stringify
Join words back into the original text.
stringify_list
Join words or strings (for simple mode results stored as words).

Type Aliases§

Result