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§
- DoSegment
Options - Per-call segmentation options.
- POSTAG
- POS tag bit flags (identical numeric values to the TypeScript
POSTAGenum). - Segment
- Chinese word segmenter.
- Segment
Options - Segmenter construction options.
- Test
Request - Test
Result - Word
- A segmented word. Field names match the JavaScript
IWordobject.
Enums§
- Error
- Library error.
- Expected
Item - Segment
Mode
Traits§
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).