2020-12-27 23:04:09 +03:00
|
|
|
|
extern crate mystem;
|
|
|
|
|
|
2020-12-28 13:25:53 +03:00
|
|
|
|
use mystem::Other::Obscene;
|
|
|
|
|
|
2020-12-27 23:10:29 +03:00
|
|
|
|
#[allow(unused_must_use)]
|
2020-12-27 23:04:09 +03:00
|
|
|
|
fn main() -> Result<(), mystem::AppError> {
|
|
|
|
|
let mut instance = mystem::MyStem::new()?;
|
2020-12-28 13:25:53 +03:00
|
|
|
|
for stem in instance.stemming("Связался с лучшим - подохни как все, Говноед.".into())?
|
2020-12-27 23:04:09 +03:00
|
|
|
|
{
|
2020-12-28 13:25:53 +03:00
|
|
|
|
println!(
|
|
|
|
|
"'{}' most likely is a '{}' and lexeme is '{}'.{}{}",
|
|
|
|
|
stem.text,
|
|
|
|
|
stem.lex[0].grammem.part_of_speech,
|
|
|
|
|
stem.lex[0].lex,
|
|
|
|
|
{
|
|
|
|
|
match stem.lex[0]
|
|
|
|
|
.grammem
|
|
|
|
|
.facts
|
|
|
|
|
.contains(&mystem::Fact::Other(Obscene))
|
|
|
|
|
{
|
|
|
|
|
true => " Obscene lexis.",
|
|
|
|
|
false => "",
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
2021-01-10 21:16:49 +03:00
|
|
|
|
match stem.lex.len() {
|
|
|
|
|
0 | 1 => "".to_string(),
|
2020-12-28 13:25:53 +03:00
|
|
|
|
x if x > 1 => format!(" Also has {} found lexems.", x),
|
2021-01-10 21:16:49 +03:00
|
|
|
|
_ => unreachable!(),
|
2020-12-28 13:25:53 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)
|
2020-12-27 23:04:09 +03:00
|
|
|
|
}
|
|
|
|
|
instance.terminate();
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|