Guest User

Untitled

a guest
Nov 22nd, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.36 KB | None | 0 0
  1. import string
  2.  
  3. # Program to index sentences
  4.  
  5. # Author:   <***MUST DO*** - REPLACE THIS WITH YOUR NAME AND STUDENT ID>
  6.  
  7. # Date:
  8.  
  9. stopWords = [ "a", "i", "it", "am", "at", "on", "in", "to", "too", "very", \
  10.               "of", "from", "here", "even", "the", "but", "and", "is", "my", \
  11.               "them", "then", "this", "that", "than", "though", "so", "are" ]
  12.  
  13. noStemWords = [ "feed", "sages", "yearling", "mass", "make", "sly", "ring" ]
  14.  
  15. endings = ["s","es","ed","er","ly","ing"]
  16.  
  17.  
  18. lines = []
  19. while True:
  20.     line = raw_input()
  21.     if not line: break
  22.     lines.append(line)
  23.  
  24. q = 0
  25. i = 0
  26. x = 0
  27. d = {}
  28.  
  29. while x < len(lines):
  30.     d[x]=lines[x].split()
  31.     x = x + 1
  32.  
  33.  
  34.  
  35. for i in d:
  36.     linelist = d[i]
  37.     '''for stemword in noStemWords:
  38.        for word in linelist:
  39.           if word != stemword:
  40.            for ending in endings:
  41.                word = word.rstrip(ending)
  42.                linelist.append(word)'''
  43.  
  44.     for word in stopWords:
  45.         if word in linelist:
  46.             linelist.remove(word)
  47.     d[i] = linelist
  48.     i = i + 1
  49.  
  50. for i in d:
  51.     linelist = d[i]
  52.  
  53.     for word in linelist:
  54.             while q < len(linelist):
  55.                 q = q + 1
  56.                 if word != noStemWords[q]:
  57.                     for ending in endings:
  58.                         word.strip(ending)
  59.  
  60.  
  61.     d[i] = linelist
  62.  
  63.  
  64. print d
Add Comment
Please, Sign In to add comment