Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import string
- # Program to index sentences
- # Author: <***MUST DO*** - REPLACE THIS WITH YOUR NAME AND STUDENT ID>
- # Date:
- stopWords = [ "a", "i", "it", "am", "at", "on", "in", "to", "too", "very", \
- "of", "from", "here", "even", "the", "but", "and", "is", "my", \
- "them", "then", "this", "that", "than", "though", "so", "are" ]
- noStemWords = [ "feed", "sages", "yearling", "mass", "make", "sly", "ring" ]
- endings = ["s","es","ed","er","ly","ing"]
- lines = []
- while True:
- line = raw_input()
- if not line: break
- lines.append(line)
- q = 0
- i = 0
- x = 0
- d = {}
- while x < len(lines):
- d[x]=lines[x].split()
- x = x + 1
- for i in d:
- linelist = d[i]
- '''for stemword in noStemWords:
- for word in linelist:
- if word != stemword:
- for ending in endings:
- word = word.rstrip(ending)
- linelist.append(word)'''
- for word in stopWords:
- if word in linelist:
- linelist.remove(word)
- d[i] = linelist
- i = i + 1
- for i in d:
- linelist = d[i]
- for word in linelist:
- while q < len(linelist):
- q = q + 1
- if word != noStemWords[q]:
- for ending in endings:
- word.strip(ending)
- d[i] = linelist
- print d
Add Comment
Please, Sign In to add comment