pub struct SpacePenalty { /* private fields */ }Expand description
띄어쓰기 패널티 설정
mecab-ko의 left-space-penalty-factor 기능을 구현합니다.
띄어쓰기 직후에 특정 품사가 오면 페널티를 부여하여 오분석을 방지합니다.
§Example
use mecab_ko_core::viterbi::SpacePenalty;
// mecab-ko 기본 설정
let penalty = SpacePenalty::korean_default();
// dicrc 형식에서 생성
let penalty = SpacePenalty::from_dicrc("1785,6000;1786,6000");Implementations§
Source§impl SpacePenalty
impl SpacePenalty
Sourcepub fn korean_default() -> Self
pub fn korean_default() -> Self
한국어 기본 페널티 설정
조사(JK*)와 어미(E*)가 띄어쓰기 직후 나타나면 높은 페널티를 부여합니다. 이는 “아버지가방에” → “아버지가 방에“로 분석하는 데 도움이 됩니다.
Sourcepub fn from_dicrc(config: &str) -> Self
pub fn from_dicrc(config: &str) -> Self
mecab-ko의 dicrc 설정에서 생성
§Format
left_id,penalty;left_id,penalty;...
§Example
use mecab_ko_core::viterbi::SpacePenalty;
let penalty = SpacePenalty::from_dicrc("1785,6000;1786,6000;1787,5000");
assert_eq!(penalty.get(1785), 6000);
assert_eq!(penalty.get(1786), 6000);
assert_eq!(penalty.get(9999), 0); // 미등록Trait Implementations§
Source§impl Clone for SpacePenalty
impl Clone for SpacePenalty
Source§fn clone(&self) -> SpacePenalty
fn clone(&self) -> SpacePenalty
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SpacePenalty
impl Debug for SpacePenalty
Source§impl Default for SpacePenalty
impl Default for SpacePenalty
Source§fn default() -> SpacePenalty
fn default() -> SpacePenalty
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SpacePenalty
impl RefUnwindSafe for SpacePenalty
impl Send for SpacePenalty
impl Sync for SpacePenalty
impl Unpin for SpacePenalty
impl UnsafeUnpin for SpacePenalty
impl UnwindSafe for SpacePenalty
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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