Closed vsraptor closed 2 years ago
I don't really get what you're trying to do, what is file
, sents
and words
?
Is that really different from list( file('text/622_lines.txt') | sents | words)) )
?
you are right.. i was trying to squeeze too much stuff into pipes.. i have something like this
for words in sentences :
....code ...
filtered = words | longer(2) | is_word | isnt_stop | lwcase | lemma
.... code ..
process(filltered)
the exit of the pipe (process) requires sentences rather than stream of words
i was trying to squeeze too much stuff into pipes
Yes, bad idea, keep your code easily modifiable.
Also maybe try to stick to "one line do one thing", it helps readability too.
filtered = words | longer(2) | is_word | isnt_stop | lwcase | lemma
is OK, it filters, but don't try to stuff more in this line, better keep it in a for loop as you showed.
It's like trying to put list comprehension inside list comprehension: it can nicely fit on a single line, but can't be (easily) modified.
when i try to list() the result :
I'm trying to do nested iterators ...