Skip to main content

TrieBuilder

Struct TrieBuilder 

Source
pub struct TrieBuilder;
Expand description

Trie 빌더

키-값 쌍에서 Double-Array Trie를 빌드합니다.

Implementations§

Source§

impl TrieBuilder

Source

pub fn build(entries: &[(&str, u32)]) -> Result<Vec<u8>, DictError>

정렬된 키-값 쌍에서 Trie 빌드

§Errors

엔트리가 비어있거나 Trie 빌드에 실패한 경우 에러를 반환합니다.

use mecab_ko_dict::trie::TrieBuilder;

let entries = vec![("가", 0u32), ("가다", 1), ("가방", 2)];
let bytes = TrieBuilder::build(&entries).unwrap();
assert!(!bytes.is_empty());
Source

pub fn build_bytes(entries: &[(&[u8], u32)]) -> Result<Vec<u8>, DictError>

바이트 키-값 쌍에서 Trie 빌드

§Errors

엔트리가 비어있거나 Trie 빌드에 실패한 경우 에러를 반환합니다.

Source

pub fn build_unsorted(entries: &mut [(&str, u32)]) -> Result<Vec<u8>, DictError>

정렬되지 않은 엔트리에서 Trie 빌드

§Errors

엔트리가 비어있거나 Trie 빌드에 실패한 경우 에러를 반환합니다.

Source

pub fn save_to_file<P>(bytes: &[u8], path: P) -> Result<(), DictError>
where P: AsRef<Path>,

Trie를 파일로 저장

§Errors

파일을 쓸 수 없는 경우 에러를 반환합니다.

Source

pub fn save_to_compressed_file<P>( bytes: &[u8], path: P, level: i32, ) -> Result<(), DictError>
where P: AsRef<Path>,

Trie를 압축하여 파일로 저장 (zstd)

§Errors

파일을 쓰거나 압축할 수 없는 경우 에러를 반환합니다.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.