Skip to main content

Normalizer

Struct Normalizer 

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

외래어 정규화기

Implementations§

Source§

impl Normalizer

Source

pub fn new(config: NormalizationConfig) -> Result<Self>

새 정규화기 생성

§Arguments
  • config - 정규화 설정
§Returns

Result<Self> - 생성된 정규화기 또는 에러

§Errors

데이터 로딩 실패 시 에러 반환

Source

pub fn with_data_file( config: NormalizationConfig, variant_csv_path: &Path, ) -> Result<Self>

외부 데이터 파일로 정규화기 생성

§Arguments
  • config - 정규화 설정
  • variant_csv_path - 변이형 CSV 파일 경로
§Returns

Result<Self> - 생성된 정규화기 또는 에러

§Errors

파일 로딩 또는 파싱 실패 시 에러 반환

Source

pub fn default() -> Result<Self>

기본 설정으로 생성

§Errors

데이터 로딩 실패 시 에러 반환

Source

pub fn normalize(&self, text: &str) -> String

외래어를 표준형으로 정규화

§Arguments
  • text - 정규화할 텍스트
§Returns

정규화된 텍스트

§Example
use mecab_ko_core::normalizer::{Normalizer, NormalizationConfig};

let normalizer = Normalizer::new(NormalizationConfig::default()).unwrap();
assert_eq!(normalizer.normalize("코피"), "커피");
assert_eq!(normalizer.normalize("소프트웨아"), "소프트웨어");
Source

pub fn get_variants(&self, standard: &str) -> Vec<String>

표준형의 모든 변이형 조회

§Arguments
  • standard - 표준형 단어
§Returns

변이형 목록

§Example
use mecab_ko_core::normalizer::{Normalizer, NormalizationConfig};

let normalizer = Normalizer::new(NormalizationConfig::default()).unwrap();
let variants = normalizer.get_variants("커피");
assert!(variants.contains(&"코피".to_string()));
Source

pub fn is_variant(&self, word1: &str, word2: &str) -> bool

두 단어가 변이형 관계인지 확인

§Arguments
  • word1 - 첫 번째 단어
  • word2 - 두 번째 단어
§Returns

변이형 관계이면 true, 아니면 false

§Example
use mecab_ko_core::normalizer::{Normalizer, NormalizationConfig};

let normalizer = Normalizer::new(NormalizationConfig::default()).unwrap();
assert!(normalizer.is_variant("커피", "코피"));
assert!(!normalizer.is_variant("커피", "라면"));
Source

pub fn phonetic_similarity(&self, word1: &str, word2: &str) -> f32

발음 유사도 계산 (0.0 ~ 1.0)

§Arguments
  • word1 - 첫 번째 단어
  • word2 - 두 번째 단어
§Returns

발음 유사도 (0.0 ~ 1.0)

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.