mirror of
https://github.com/house-of-vanity/mystem-rs.git
synced 2025-07-06 13:14:07 +00:00
Fix mystem stdin feed.
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "mystem"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
authors = ["AB <ab@hexor.ru>"]
|
||||
license = "WTFPL"
|
||||
edition = "2018"
|
||||
|
@ -23,11 +23,10 @@ fn main() -> Result<(), mystem::AppError> {
|
||||
}
|
||||
},
|
||||
{
|
||||
match stem.lex.len()
|
||||
{
|
||||
match stem.lex.len() {
|
||||
0 | 1 => "".to_string(),
|
||||
x if x > 1 => format!(" Also has {} found lexems.", x),
|
||||
_ => unreachable!()
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@ -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;
|
||||
|
11
src/lib.rs
11
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<Stemming> = Vec::new();
|
||||
|
Reference in New Issue
Block a user