Skip to main content

test/
test.rs

1extern crate mystem;
2
3use mystem::Other::Obscene;
4
5#[allow(unused_must_use)]
6fn main() -> Result<(), mystem::AppError> {
7    let mut instance = mystem::MyStem::new()?;
8    for stem in instance.stemming("Связался с лучшим - подохни как все, Говноед.".into())?
9    {
10        println!(
11            "'{}' most likely is a '{}' and lexeme is '{}'.{}{}",
12            stem.text,
13            stem.lex[0].grammem.part_of_speech,
14            stem.lex[0].lex,
15            {
16                match stem.lex[0]
17                    .grammem
18                    .facts
19                    .contains(&mystem::Fact::Other(Obscene))
20                {
21                    true => " Obscene lexis.",
22                    false => "",
23                }
24            },
25            {
26                match stem.lex.len() {
27                    0 | 1 => "".to_string(),
28                    x if x > 1 => format!(" Also has {} found lexems.", x),
29                    _ => unreachable!(),
30                }
31            }
32        )
33    }
34    instance.terminate();
35    Ok(())
36}