pub struct NativeTokenizer { /* private fields */ }Implementations§
Source§impl NativeTokenizer
impl NativeTokenizer
Sourcepub fn new(
dict_path: String,
options: Option<NativeTokenizerOptions>,
) -> Result<Self>
pub fn new( dict_path: String, options: Option<NativeTokenizerOptions>, ) -> Result<Self>
Load a system dictionary and create the native tokenizer.
Create a tokenizer from a shared dictionary handle. The ~150 MB trie is shared via Arc (16-byte refcount bump, not a copy).
Sourcepub fn add_user_dictionary(&mut self, dict_path: String) -> Result<()>
pub fn add_user_dictionary(&mut self, dict_path: String) -> Result<()>
Add a user dictionary.
Sourcepub fn tokenize(
&self,
bytes: Uint8Array,
can_bow: Uint8Array,
char_categories: Uint32Array,
word_candidate_lengths: Uint32Array,
continuous_lengths: Uint32Array,
code_point_byte_lengths_flat: Uint8Array,
code_point_offsets: Uint32Array,
) -> Result<Vec<NativePathNode>>
pub fn tokenize( &self, bytes: Uint8Array, can_bow: Uint8Array, char_categories: Uint32Array, word_candidate_lengths: Uint32Array, continuous_lengths: Uint32Array, code_point_byte_lengths_flat: Uint8Array, code_point_offsets: Uint32Array, ) -> Result<Vec<NativePathNode>>
The hot path — builds lattice and returns best path nodes.
Sourcepub fn get_word_info(&self, word_id: i32) -> Result<NativeWordInfo>
pub fn get_word_info(&self, word_id: i32) -> Result<NativeWordInfo>
Get word info by packed word ID. Called during TS post-processing.
Trait Implementations§
Source§impl FromNapiMutRef for NativeTokenizer
impl FromNapiMutRef for NativeTokenizer
Source§unsafe fn from_napi_mut_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static mut Self>
unsafe fn from_napi_mut_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static mut Self>
Safety Read more
Source§impl FromNapiRef for NativeTokenizer
impl FromNapiRef for NativeTokenizer
Source§unsafe fn from_napi_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static Self>
unsafe fn from_napi_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static Self>
Safety Read more
Source§impl JavaScriptClassExt for NativeTokenizer
impl JavaScriptClassExt for NativeTokenizer
fn into_instance<'scope>( self, env: &'scope Env, ) -> Result<ClassInstance<'scope, Self>>
fn into_reference(self, env: Env) -> Result<Reference<Self>>
fn instance_of<'env, V: JsValue<'env>>(env: &Env, value: &V) -> Result<bool>
Source§impl ObjectFinalize for NativeTokenizer
impl ObjectFinalize for NativeTokenizer
Source§impl ToNapiValue for NativeTokenizer
impl ToNapiValue for NativeTokenizer
Source§unsafe fn to_napi_value(
env: napi_env,
val: NativeTokenizer,
) -> Result<napi_value>
unsafe fn to_napi_value( env: napi_env, val: NativeTokenizer, ) -> Result<napi_value>
Safety Read more
fn into_unknown(self, env: &Env) -> Result<Unknown<'_>, Error>
Source§impl TypeName for &NativeTokenizer
impl TypeName for &NativeTokenizer
Source§impl TypeName for &mut NativeTokenizer
impl TypeName for &mut NativeTokenizer
Source§impl TypeName for NativeTokenizer
impl TypeName for NativeTokenizer
Source§impl ValidateNapiValue for &NativeTokenizer
impl ValidateNapiValue for &NativeTokenizer
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Source§impl ValidateNapiValue for &mut NativeTokenizer
impl ValidateNapiValue for &mut NativeTokenizer
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Auto Trait Implementations§
impl Freeze for NativeTokenizer
impl RefUnwindSafe for NativeTokenizer
impl Send for NativeTokenizer
impl Sync for NativeTokenizer
impl Unpin for NativeTokenizer
impl UnsafeUnpin for NativeTokenizer
impl UnwindSafe for NativeTokenizer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more