mirror of
https://github.com/house-of-vanity/mystem-rs.git
synced 2025-07-06 21:24:07 +00:00
Impl Display for Grammems structs. Added readme. Reworked lexeme detection - now stores all the lexemes order by weight.
This commit is contained in:
@ -1,13 +1,37 @@
|
||||
extern crate mystem;
|
||||
|
||||
use mystem::Other::Obscene;
|
||||
|
||||
#[allow(unused_must_use)]
|
||||
fn main() -> Result<(), mystem::AppError> {
|
||||
let mut instance = mystem::MyStem::new()?;
|
||||
for stem in instance.stemming("Связался с лучшим - подохни как все.".into())?
|
||||
for stem in instance.stemming("Связался с лучшим - подохни как все, Говноед.".into())?
|
||||
{
|
||||
println!("{} is a lexeme of {}", stem.lex, stem.text)
|
||||
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 => "",
|
||||
}
|
||||
},
|
||||
{
|
||||
match stem.lex.len()
|
||||
{
|
||||
0|1 => "".to_string(),
|
||||
x if x > 1 => format!(" Also has {} found lexems.", x),
|
||||
_ => unreachable!()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
instance.terminate();
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user