|
|
@ -195,9 +195,14 @@ async fn main() {
|
|
|
|
async move {
|
|
|
|
async move {
|
|
|
|
let (tx, rx) = mpsc::channel(state.config().max_gen_size);
|
|
|
|
let (tx, rx) = mpsc::channel(state.config().max_gen_size);
|
|
|
|
tokio::spawn(gen::body(state, num, tx));
|
|
|
|
tokio::spawn(gen::body(state, num, tx));
|
|
|
|
Ok::<_, std::convert::Infallible>(Response::new(Body::wrap_stream(rx.map(move |x| {
|
|
|
|
Ok::<_, std::convert::Infallible>(Response::new(Body::wrap_stream(rx.filter_map(move |mut x| {
|
|
|
|
info!("{} <- {:?}", host, x);
|
|
|
|
if x.trim_in_place().len() != 0 {
|
|
|
|
Ok::<_, std::convert::Infallible>(x)
|
|
|
|
info!("{} <- {:?}", host, x);
|
|
|
|
|
|
|
|
x.push('\n');
|
|
|
|
|
|
|
|
Some(Ok::<_, std::convert::Infallible>(x))
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
None
|
|
|
|
|
|
|
|
}
|
|
|
|
}))))
|
|
|
|
}))))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -213,16 +218,14 @@ async fn main() {
|
|
|
|
async move {
|
|
|
|
async move {
|
|
|
|
let (tx, rx) = mpsc::channel(state.config().max_gen_size);
|
|
|
|
let (tx, rx) = mpsc::channel(state.config().max_gen_size);
|
|
|
|
tokio::spawn(sentance::body(state, num, tx));
|
|
|
|
tokio::spawn(sentance::body(state, num, tx));
|
|
|
|
Ok::<_, std::convert::Infallible>(Response::new(Body::wrap_stream(rx.map(move |mut x| {
|
|
|
|
Ok::<_, std::convert::Infallible>(Response::new(Body::wrap_stream(rx.filter_map(move |mut x| {
|
|
|
|
info!("{} (sentance) <- {:?}", host, x);
|
|
|
|
if x.trim_in_place().len() != 0 {
|
|
|
|
// match x.chars().last() {
|
|
|
|
info!("{} (sentance) <- {:?}", host, x);
|
|
|
|
// Some(chr) if sanitise::is_sentance_boundary(chr) => {
|
|
|
|
x.push(' ');
|
|
|
|
// x.push(' ');
|
|
|
|
Some(Ok::<_, std::convert::Infallible>(x))
|
|
|
|
// },
|
|
|
|
} else {
|
|
|
|
// _ => (),
|
|
|
|
None
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
x.push(' ');
|
|
|
|
|
|
|
|
Ok::<_, std::convert::Infallible>(x)
|
|
|
|
|
|
|
|
}))))
|
|
|
|
}))))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|