pub struct Tokenizer { /* private fields */ }Expand description
토크나이저
형태소 분석의 메인 인터페이스입니다. 시스템 사전, 사용자 사전, 미등록어 처리기를 통합하여 형태소 분석을 수행합니다.
§메모리 최적화
lattice재사용으로 매 분석마다 재할당 방지pool_manager로 Token, Node 객체 재사용- String interning으로 중복 문자열 제거
Implementations§
Source§impl Tokenizer
impl Tokenizer
Sourcepub fn with_user_dict(self, user_dict: UserDictionary) -> Tokenizer
pub fn with_user_dict(self, user_dict: UserDictionary) -> Tokenizer
Sourcepub fn set_user_dict(&mut self, user_dict: UserDictionary)
pub fn set_user_dict(&mut self, user_dict: UserDictionary)
사용자 사전 설정 (in-place)
이미 생성된 토크나이저에 사용자 사전을 설정합니다. 빌더 패턴이 필요 없는 경우 사용합니다.
§Arguments
user_dict- 사용자 사전
§Example
use mecab_ko_core::Tokenizer;
use mecab_ko_dict::UserDictionary;
let mut tokenizer = Tokenizer::new().unwrap();
let mut user_dict = UserDictionary::new();
user_dict.add_entry("챗GPT", "NNP", Some(-2000), None);
tokenizer.set_user_dict(user_dict);Sourcepub fn with_space_penalty(self, penalty: SpacePenalty) -> Tokenizer
pub fn with_space_penalty(self, penalty: SpacePenalty) -> Tokenizer
Sourcepub fn tokenize_to_lattice(&mut self, text: &str) -> &Lattice
pub fn tokenize_to_lattice(&mut self, text: &str) -> &Lattice
Sourcepub fn wakati(&mut self, text: &str) -> Vec<String>
pub fn wakati(&mut self, text: &str) -> Vec<String>
표면형만 추출 (wakati)
§Arguments
text- 분석할 텍스트
§Returns
분리된 표면형 목록 (wakati gaki)
일본어 형태소 분석기의 wakati gaki 모드와 동일합니다. 형태소로 분리된 표면형만 반환합니다.
§Arguments
text- 분석할 텍스트
§Returns
분리된 표면형 목록
§Example
use mecab_ko_core::Tokenizer;
let mut tokenizer = Tokenizer::new().unwrap();
let surfaces = tokenizer.wakati("아버지가방에들어가신다");
// ["아버지", "가", "방", "에", "들어가", "신다"]Sourcepub const fn dictionary(&self) -> &SystemDictionary
pub const fn dictionary(&self) -> &SystemDictionary
시스템 사전 참조 반환
내부 시스템 사전에 대한 읽기 전용 참조를 반환합니다. 사전 정보 조회나 디버깅에 유용합니다.
Sourcepub fn lattice_stats(&self) -> LatticeStats
pub fn lattice_stats(&self) -> LatticeStats
Lattice 통계 정보
마지막 분석에서 생성된 Lattice의 통계 정보를 반환합니다. 노드 수, 엣지 수 등 디버깅 및 프로파일링에 유용합니다.
Sourcepub fn pool_stats(&self) -> PoolStats
pub fn pool_stats(&self) -> PoolStats
메모리 풀 통계 정보
메모리 풀의 사용 현황을 반환합니다.
Sourcepub fn memory_stats(&self) -> MemoryStats
pub fn memory_stats(&self) -> MemoryStats
메모리 사용량 통계
토크나이저의 메모리 사용 현황을 반환합니다.
Sourcepub fn clear_pools(&self)
pub fn clear_pools(&self)
메모리 풀 초기화
모든 풀을 비워 메모리를 해제합니다. 장기 실행 프로세스에서 주기적으로 호출하여 메모리 누수 방지.
Sourcepub fn set_normalization(
&mut self,
enable: bool,
config: Option<NormalizationConfig>,
) -> Result<(), Error>
pub fn set_normalization( &mut self, enable: bool, config: Option<NormalizationConfig>, ) -> Result<(), Error>
Sourcepub const fn normalizer(&self) -> Option<&Normalizer>
pub const fn normalizer(&self) -> Option<&Normalizer>
외래어 정규화기 참조 반환
Sourcepub const fn is_normalization_enabled(&self) -> bool
pub const fn is_normalization_enabled(&self) -> bool
정규화가 활성화되어 있는지 확인
Sourcepub fn tokenize_with_normalization(&mut self, text: &str) -> Vec<Token>
pub fn tokenize_with_normalization(&mut self, text: &str) -> Vec<Token>
Auto Trait Implementations§
impl !Freeze for Tokenizer
impl !RefUnwindSafe for Tokenizer
impl Send for Tokenizer
impl !Sync for Tokenizer
impl Unpin for Tokenizer
impl UnsafeUnpin for Tokenizer
impl !UnwindSafe for Tokenizer
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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