Skip to main content

SystemDictionary

Struct SystemDictionary 

Source
pub struct SystemDictionary { /* private fields */ }
Expand description

시스템 사전

Trie, Matrix, Features를 통합하여 형태소 검색과 연접 비용 계산을 제공합니다. 메모리 맵 기반으로 로드되어 효율적이며, 여러 인스턴스 간 메모리 공유가 가능합니다.

Implementations§

Source§

impl SystemDictionary

Source

pub fn load_default() -> Result<SystemDictionary, DictError>

기본 경로에서 사전 로드

다음 순서로 사전 경로를 탐색합니다:

  1. MECAB_DICDIR 환경변수
  2. 기본 경로 목록 (DEFAULT_DICDIR_PATHS)
§Errors
  • 사전 파일을 찾을 수 없는 경우
  • 사전 파일 포맷이 잘못된 경우
Source

pub fn load_memory_optimized() -> Result<SystemDictionary, DictError>

기본 경로에서 메모리 최적화 옵션으로 사전 로드

mmap과 lazy loading을 사용하여 메모리 사용량을 줄입니다.

§Errors
  • 사전 파일을 찾을 수 없는 경우
  • 사전 파일 포맷이 잘못된 경우
Source

pub fn load_with_options<P>( dicdir: P, options: LoadOptions, ) -> Result<SystemDictionary, DictError>
where P: AsRef<Path>,

옵션과 함께 사전 로드

§Errors
  • 사전 파일을 찾을 수 없는 경우
  • 사전 파일 포맷이 잘못된 경우
Source

pub fn load<P>(dicdir: P) -> Result<SystemDictionary, DictError>
where P: AsRef<Path>,

특정 경로에서 사전 로드

§Arguments
  • dicdir - 사전 디렉토리 경로
§Errors
  • 사전 파일을 찾을 수 없는 경우
  • 사전 파일 포맷이 잘못된 경우
Source

pub fn save_entries_bin( entries: &[DictEntry], path: &Path, ) -> Result<(), DictError>

엔트리를 바이너리 파일로 저장

§Errors

파일 쓰기 실패 시 에러 반환

Source

pub fn save_entries_csv( entries: &[DictEntry], path: &Path, ) -> Result<(), DictError>

엔트리를 CSV 파일로 저장

§Errors

파일 쓰기 실패 시 에러 반환

Source

pub fn with_user_dictionary(self, user_dict: UserDictionary) -> SystemDictionary

사용자 사전 추가

§Arguments
  • user_dict - 사용자 사전
Source

pub fn set_user_dictionary(&mut self, user_dict: UserDictionary)

사용자 사전 설정

Source

pub fn dicdir(&self) -> &Path

사전 디렉토리 경로 반환

Source

pub const fn trie(&self) -> &Trie<'static>

Trie 참조 반환

Source

pub const fn matrix(&self) -> &ConnectionMatrix

Matrix 참조 반환

Source

pub fn entries(&self) -> &[DictEntry]

엔트리 배열 참조 반환

Source

pub fn user_dictionary(&self) -> Option<&UserDictionary>

사용자 사전 참조 반환

Source

pub fn get_entry(&self, index: u32) -> Option<&DictEntry>

인덱스로 엔트리 조회

§Arguments
  • index - Trie에서 반환된 인덱스

공통 접두사 검색

주어진 텍스트의 접두사와 일치하는 모든 엔트리를 찾습니다. 같은 surface에 복수 엔트리가 있으면 모두 반환합니다.

§Arguments
  • text - 검색할 텍스트
§Returns

일치하는 엔트리와 바이트 길이의 벡터

Source

pub fn common_prefix_search_at( &self, text: &str, start_byte: usize, ) -> Vec<(&DictEntry, usize)>

특정 위치에서 공통 접두사 검색

§Arguments
  • text - 전체 텍스트
  • start_byte - 검색 시작 바이트 위치
Source

pub fn lookup_combined(&self, surface: &str) -> Vec<Entry>

시스템 사전과 사용자 사전을 통합하여 검색

§Arguments
  • surface - 검색할 표면형

Trait Implementations§

Source§

impl Dictionary for SystemDictionary

Source§

fn lookup(&self, surface: &str) -> Vec<Entry>

형태소 검색
Source§

fn get_connection_cost(&self, left_id: u16, right_id: u16) -> i16

연접 비용 조회

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

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.