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
//! A from-scratch, pure-Rust port of [SentencePiece] **inference**
//! (encode/decode), differentially verified against the upstream C++/Python
//! implementation — the same harness used across the author's other library
//! ports.
//!
//! This is **not** a wrapper around the C++ library (that already exists as the
//! `sentencepiece` crate). The algorithms here are reimplemented in Rust from
//! the reference source in `projects/Reference/sentencepiece`.
//!
//! # Status
//! Inference is feature-complete for BPE and Unigram models, verified against
//! the Python `sentencepiece` oracle:
//! - **v0.1:** BPE segmentation + ASCII/whitespace normalisation.
//! - **v0.2:** Darts charsmap normaliser → full Unicode input (full-width
//! folding, ligatures, CJK, …).
//! - **v0.3 (current):** Unigram Viterbi segmentation (the default model type),
//! plus faithful decode (byte-piece reassembly, unk surface, dummy-prefix).
//!
//! Encode *and* decode are verified against the oracle across BPE, Unigram, and
//! byte-fallback models (117 cases). Training is intentionally out of scope —
//! this crate loads a trained `.model` and tokenises with it.
//!
//! # Example
//! ```no_run
//! use sentencepiece_rust::SentencePieceProcessor;
//! let sp = SentencePieceProcessor::open("tests/models/botchan_1000_bpe.model")?;
//! let ids = sp.encode("hello world")?;
//! let text = sp.decode(&ids)?;
//! # Ok::<(), sentencepiece_rust::Error>(())
//! ```
//!
//! [SentencePiece]: https://github.com/google/sentencepiece
pub use ;
pub use ;
pub use SentencePieceProcessor;
pub use Vocab;