removed redundant filter

serve
Avril 4 years ago
parent 032e5d74dc
commit 77d4c2da73
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -1,6 +1,6 @@
[package] [package]
name = "markov" name = "markov"
version = "0.5.3" version = "0.5.4"
description = "Generate string of text from Markov chain fed by stdin" description = "Generate string of text from Markov chain fed by stdin"
authors = ["Avril <flanchan@cumallover.me>"] authors = ["Avril <flanchan@cumallover.me>"]
edition = "2018" edition = "2018"

@ -11,7 +11,6 @@ pub fn feed(chain: &mut Chain<String>, what: impl AsRef<str>, bounds: impl std::
if #[cfg(feature="split-sentance")] { if #[cfg(feature="split-sentance")] {
let map = Sentance::new_iter(&what) //get each sentance in string let map = Sentance::new_iter(&what) //get each sentance in string
.map(|what| what.words() .map(|what| what.words()
.filter(|word| !word.is_empty())
.map(|s| s.to_owned()).collect::<Vec<_>>()); .map(|s| s.to_owned()).collect::<Vec<_>>());
debug_assert!(!bounds.contains(&0), "Cannot allow 0 size feeds"); debug_assert!(!bounds.contains(&0), "Cannot allow 0 size feeds");
for map in map {// feed each sentance seperately for map in map {// feed each sentance seperately
@ -24,8 +23,7 @@ pub fn feed(chain: &mut Chain<String>, what: impl AsRef<str>, bounds: impl std::
} }
} else { } else {
let map = Sentance::new_iter(&what) //get each sentance in string let map = Sentance::new_iter(&what) //get each sentance in string
.map(|what| what.words() .map(|what| what.words())
.filter(|word| !word.is_empty()))
.flatten() // add all into one buffer .flatten() // add all into one buffer
.map(|s| s.to_owned()).collect::<Vec<_>>(); .map(|s| s.to_owned()).collect::<Vec<_>>();
debug_assert!(!bounds.contains(&0), "Cannot allow 0 size feeds"); debug_assert!(!bounds.contains(&0), "Cannot allow 0 size feeds");

@ -77,7 +77,7 @@ impl Sentance
} }
/// Get the words in this sentance /// Get the words in this sentance
pub fn words(&self) -> impl Iterator<Item = &'_ Word> #[inline] pub fn words(&self) -> impl Iterator<Item = &'_ Word>
{ {
Word::new_iter(self) Word::new_iter(self)
} }

Loading…
Cancel
Save