I'm trying using itertools to figure out this useful module but I don't understand why the filterfalse line doesn't return the value I expected. It should remove just a single vowel after a consonant but it doesn't.
input: "hoooowe yyyooouuu duoooiiine"
the line returns:['h', 'w', ' ', 'y', 'y', 'y', 'u', 'u', 'u', ' ', 'd', 'u', 'i', 'i', 'i', 'n']
Could anyone tell me why it leaves out all 'o's and keeps 'u' after 'd'? Thank you.
VOWELS = "aeiouy " #"aeiouy" + " "
data = list(itertools.filterfalse(lambda x: data[data.index(x)-1] not in VOWELS, data))
data = [list(g) for k,g in itertools.groupby(data)]
data = [i if i not in VOWELS or len(i) < 3 else [i] * (len(i) // 3) for i in data]
return "".join([e for i in data for e in i])
Created at: May 9, 2015, 3:51 a.m.; Updated at: May 12, 2015, 6:44 p.m.
author:[username] - Returns posts by user
associated with the given user.
tag:[tag_name1],[tag_name2], ... - Returns
posts associated with the given tag(s).
phrase - Returns posts that contain the word
or set of words in title or text.