diff --git a/Cargo.toml b/Cargo.toml index aba7d6d..fd3aaad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mystem" -version = "0.2.1" +version = "0.2.2" authors = ["AB "] license = "WTFPL" edition = "2018" diff --git a/examples/test.rs b/examples/test.rs index 1b6ed1a..b7b8bb0 100644 --- a/examples/test.rs +++ b/examples/test.rs @@ -23,11 +23,10 @@ fn main() -> Result<(), mystem::AppError> { } }, { - match stem.lex.len() - { - 0|1 => "".to_string(), + match stem.lex.len() { + 0 | 1 => "".to_string(), x if x > 1 => format!(" Also has {} found lexems.", x), - _ => unreachable!() + _ => unreachable!(), } } ) diff --git a/src/grammems.rs b/src/grammems.rs index 9192373..c781194 100644 --- a/src/grammems.rs +++ b/src/grammems.rs @@ -10,10 +10,10 @@ use crate::Other::{ Parenthesis, Patronymic, Predicative, ProperNoun, Rare, }; use crate::PerfectiveAspect::{Imperfective, Perfective}; +use crate::Person::{First, Second, Third}; use crate::Plurality::{Plural, Singular}; use crate::Tense::{Inpresent, Past, Present}; use crate::Transitivity::{Intransitive, Transitive}; -use crate::Person::{First, Second, Third}; use crate::Voice::{Active, Passive}; use std::fmt; use std::str::FromStr; diff --git a/src/lib.rs b/src/lib.rs index 3b8b518..705aefc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -108,14 +108,21 @@ impl MyStem { ); self.process = MyStem::open_process()?; } - let clean_text = format!("{}{}", text.trim(), "\n"); + let mut clean_text = text.trim().to_string(); + for c in clean_text.clone().chars() { + if !char::is_alphabetic(c) && c != ' ' { + clean_text = clean_text.replace(c, ""); + } + } self.process .stdin .as_ref() .unwrap() .write(clean_text.as_bytes()); + self.process.stdin.as_ref().unwrap().write("\n".as_bytes()); let mut contents = String::new(); - let mut buf_reader = BufReader::new(self.process.stdout.as_ref().unwrap()); + let mut buf_reader = + BufReader::with_capacity(512 * 1024, self.process.stdout.as_ref().unwrap()); buf_reader.read_line(&mut contents); let mut stemmings: Vec = Vec::new();