fork download
  1. #Подготавливаем данные
  2. stopWords = [ "a", "i", "it", "am", "at", "on", "in", "to", "too", "very", \
  3. "of", "from", "here", "even", "the", "but", "and", "is", "my", \
  4. "them", "then", "this", "that", "than", "though", "so", "are" ]
  5.  
  6. noStemWords = [ "feed", "sages", "yearling", "mass", "make", "sly", "ring" ]
  7.  
  8. lines = ["I've seen things you people wouldn't believe.",
  9. 'Attack ships on fire off the shoulder of Orion.',
  10. 'I watched C-beams glitter in the dark near the Tannhäuser Gate.',
  11. 'All those moments will be lost in time, like tears in rain. Time to die.']
  12.  
  13. #Делаем все остальное
  14. print({word:'строка#'+ str(number) for word, number in [(word.rstrip('ing'), number) if word in noStemWords else (word, number) for number, line in enumerate(lines) for word in line.split() if word not in stopWords]})
  15.  
Success #stdin #stdout 0s 9992KB
stdin
Standard input is empty
stdout
{'lost': 'строка#3', 'will': 'строка#3', 'fire': 'строка#1', 'Tannhäuser': 'строка#2', 'Orion.': 'строка#1', 'seen': 'строка#0', "wouldn't": 'строка#0', 'tears': 'строка#3', 'people': 'строка#0', 'Time': 'строка#3', 'those': 'строка#3', 'near': 'строка#2', 'watched': 'строка#2', 'shoulder': 'строка#1', 'you': 'строка#0', "I've": 'строка#0', 'like': 'строка#3', 'Attack': 'строка#1', 'things': 'строка#0', 'Gate.': 'строка#2', 'believe.': 'строка#0', 'ships': 'строка#1', 'dark': 'строка#2', 'moments': 'строка#3', 'be': 'строка#3', 'I': 'строка#2', 'off': 'строка#1', 'All': 'строка#3', 'glitter': 'строка#2', 'rain.': 'строка#3', 'die.': 'строка#3', 'time,': 'строка#3', 'C-beams': 'строка#2'}