pub struct UserWord {
pub word: String,
pub tag: String,
pub score: f32,
}Expand description
A user dictionary entry consumed by crate::KiwiBuilder::add_user_words.
Fields§
§word: StringSurface form to add.
tag: StringPart-of-speech tag for the word.
score: f32User score used by Kiwi during ranking.
Implementations§
Source§impl UserWord
impl UserWord
Sourcepub fn new(word: impl Into<String>, tag: impl Into<String>, score: f32) -> Self
pub fn new(word: impl Into<String>, tag: impl Into<String>, score: f32) -> Self
Creates a user dictionary entry.
Examples found in repository?
examples/builder_custom_words.rs (line 8)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4 let library = KiwiLibrary::load_from_env_or_default()?;
5 let mut builder = library.builder(BuilderConfig::default())?;
6
7 builder.add_user_words([
8 UserWord::new("키위러스트", "NNP", 0.0),
9 UserWord::new("형태소파이프라인", "NNG", 0.0),
10 ])?;
11
12 builder.add_re_rule("NNP", "Rust", "러스트", 0.0)?;
13
14 let kiwi = builder.build_with_default_options(AnalyzeOptions::default())?;
15 let tokens = kiwi.tokenize("Kiwi Rust 기반 형태소파이프라인을 테스트합니다.")?;
16
17 for token in tokens {
18 println!("{}/{}", token.form, token.tag);
19 }
20
21 Ok(())
22}Trait Implementations§
Auto Trait Implementations§
impl Freeze for UserWord
impl RefUnwindSafe for UserWord
impl Send for UserWord
impl Sync for UserWord
impl Unpin for UserWord
impl UnsafeUnpin for UserWord
impl UnwindSafe for UserWord
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