Kaceka2016/instructionstokeywords.py

28 lines
743 B
Python
Raw Normal View History

2016-11-17 08:49:49 +01:00
dotsfile = open('dots.txt', 'r')
wantedfile = open('wanted.txt', 'r')
keywordsfile = open('keywords.txt', 'w')
instructionsfile = open('instructions.txt', 'r')
def commandStrip(sentence):
for line in dotsfile:
2016-11-17 09:11:46 +01:00
sentence = sentence.replace(line.strip('\n'), '')
2016-11-17 08:49:49 +01:00
return sentence
def searchKeyWords(sentence):
found = []
for line in wantedfile:
2016-11-17 09:02:24 +01:00
if sentence.find(line.strip('\n')) >= 0:
found.append(line.strip('\n'))
return found
2016-11-17 08:49:49 +01:00
def saveKeyWords(array):
for line in array:
2016-11-17 09:02:24 +01:00
if line != '':
keywordsfile.write(line + '\n')
2016-11-17 08:49:49 +01:00
saveKeyWords(searchKeyWords(commandStrip(instructionsfile.read())))
dotsfile.close()
wantedfile.close()
keywordsfile.close()
instructionsfile.close()