Skip to main content

UserDictionary

Struct UserDictionary 

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

사용자 정의 사전

사용자가 커스텀 단어를 추가하여 형태소 분석을 개선할 수 있습니다.

Implementations§

Source§

impl UserDictionary

Source

pub fn new() -> UserDictionary

새 사용자 사전 생성

Source

pub const fn with_default_cost(self, cost: i16) -> UserDictionary

기본 비용 설정

Source

pub fn add_entry( &mut self, surface: impl Into<String>, pos: impl Into<String>, cost: Option<i16>, reading: Option<String>, ) -> &mut UserDictionary

엔트리 추가

§Arguments
  • surface - 표면형
  • pos - 품사 태그 (예: “NNG”, “NNP”, “VV”)
  • cost - 비용 (낮을수록 우선, None이면 기본값 사용)
  • reading - 읽기 (발음, 선택)
Source

pub fn add_entry_with_ids( &mut self, surface: impl Into<String>, pos: impl Into<String>, cost: i16, left_id: u16, right_id: u16, reading: Option<String>, ) -> &mut UserDictionary

컨텍스트 ID와 함께 엔트리 추가

Source

pub fn load_from_csv<P>( &mut self, path: P, ) -> Result<&mut UserDictionary, DictError>
where P: AsRef<Path>,

CSV 파일에서 사전 로드

§포맷
# 주석 라인
표면형,품사,비용,읽기
  • 표면형: 필수
  • 품사: 필수 (예: NNG, NNP, VV)
  • 비용: 선택 (기본값: -1000)
  • 읽기: 선택
§Errors

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

Source

pub fn load_from_str( &mut self, content: &str, ) -> Result<&mut UserDictionary, DictError>

CSV 문자열에서 사전 로드

§Errors

파싱 오류가 발생한 경우 에러를 반환합니다.

Source

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

표면형으로 엔트리 검색

공통 접두사 검색

주어진 텍스트의 접두사와 일치하는 모든 엔트리를 찾습니다.

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

일치하는 엔트리의 벡터

Source

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

모든 엔트리 반환

Source

pub fn len(&self) -> usize

엔트리 수 반환

Source

pub fn is_empty(&self) -> bool

사전이 비어있는지 확인

Source

pub fn build_trie(&mut self) -> Result<&[u8], DictError>

Trie 빌드

사전 검색을 위한 Double-Array Trie를 빌드합니다.

§Errors

사전이 비어있거나 Trie 빌드에 실패한 경우 에러를 반환합니다.

Source

pub fn get_trie(&self) -> Option<Trie<'_>>

빌드된 Trie 가져오기

Source

pub fn to_entries(&self) -> Vec<Entry>

Entry 목록으로 변환

Source

pub fn clear(&mut self)

사전 초기화 (모든 엔트리 제거)

Source

pub fn validate(&self) -> ValidationResult

사전 검증

모든 엔트리의 유효성을 검사합니다.

§Returns

검증 결과와 발견된 문제점 목록

Source

pub fn remove_duplicates(&mut self)

중복 엔트리 제거

같은 표면형과 품사를 가진 엔트리 중 첫 번째만 유지합니다.

Source

pub fn remove_surface(&mut self, surface: &str) -> usize

특정 표면형의 엔트리 삭제

§Returns

삭제된 엔트리 수

Source

pub fn check_csv_duplicates<P>( path: P, ) -> Result<Vec<(usize, String, String)>, DictError>
where P: AsRef<Path>,

CSV 파일 중복 검사 (파일 로드 전 검사)

§Arguments
  • path - CSV 파일 경로
§Returns

중복된 엔트리 목록 (라인 번호, 표면형, 품사)

§Errors

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

Source

pub fn add_entry_auto_pos( &mut self, surface: impl Into<String>, cost: Option<i16>, reading: Option<String>, ) -> &mut UserDictionary

자동 품사 추정을 사용하여 엔트리 추가

표면형만 제공하면 품사를 자동으로 추정합니다.

Source

pub fn check_system_conflicts<S>( &self, system_surfaces: &HashSet<String, S>, ) -> Vec<(usize, String, String)>
where S: BuildHasher,

시스템 사전과 충돌 검사

시스템 사전에 이미 존재하는 표면형을 찾습니다.

§Arguments
  • system_surfaces - 시스템 사전의 표면형 집합
§Returns

충돌하는 엔트리 목록 (인덱스, 표면형, 품사)

Source

pub fn stats(&self) -> DictionaryStats

통계 정보 반환

Source

pub fn save_to_csv<P>(&self, path: P) -> Result<(), DictError>
where P: AsRef<Path>,

파일로 저장 (CSV 형식)

§Errors

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

Trait Implementations§

Source§

impl Clone for UserDictionary

Source§

fn clone(&self) -> UserDictionary

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for UserDictionary

Source§

fn default() -> UserDictionary

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.