fork(1) download
  1. def stemmer(text):
  2. stemmed_string = []
  3. suffixes = ('ed', 'ly', 'ing')
  4.  
  5. for word in text.split():
  6. for suffix in suffixes:
  7. if word.endswith(suffix):
  8. word = word[:-len(suffix)]
  9. stemmed_string.append(word)
  10.  
  11. return stemmed_string
  12.  
  13. print(stemmer("I have a dog that is barking"))
  14. print(stemmer("a fly could fling my bed"))
Success #stdin #stdout 0.03s 9148KB
stdin
Standard input is empty
stdout
['I', 'have', 'a', 'dog', 'that', 'is', 'bark']
['a', 'f', 'could', 'fl', 'my', 'b']