Merge branch 'master' of https://git.wmi.amu.edu.pl/chlebzmaslemorzechowym/Kaceka2016
This commit is contained in:
commit
d387d9a2f0
32
instructionstokeywords.py
Normal file
32
instructionstokeywords.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
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:
|
||||||
|
line=line.strip('\n').replace(line, "")
|
||||||
|
return sentence
|
||||||
|
|
||||||
|
def searchKeyWords(sentence):
|
||||||
|
found = []
|
||||||
|
for line in wantedfile:
|
||||||
|
line=line.strip('\n')
|
||||||
|
if sentence.find(line) >= 0:
|
||||||
|
found.append(line)
|
||||||
|
|
||||||
|
if found:
|
||||||
|
return found
|
||||||
|
return 1
|
||||||
|
|
||||||
|
def saveKeyWords(array):
|
||||||
|
for line in array:
|
||||||
|
keywordsfile.write(line)
|
||||||
|
keywordsfile.write("\n")
|
||||||
|
|
||||||
|
saveKeyWords(searchKeyWords(commandStrip(instructionsfile.read())))
|
||||||
|
|
||||||
|
dotsfile.close()
|
||||||
|
wantedfile.close()
|
||||||
|
keywordsfile.close()
|
||||||
|
instructionsfile.close()
|
@ -1,27 +0,0 @@
|
|||||||
dotsfile = open('dots.txt', 'r')
|
|
||||||
wantedfile = open('wanted.txt', 'r')
|
|
||||||
|
|
||||||
def commandStrip(sentence):
|
|
||||||
for line in dotsfile:
|
|
||||||
line=line.strip('\n')
|
|
||||||
sentence = sentence.replace(line, "")
|
|
||||||
return sentence
|
|
||||||
|
|
||||||
def searchKeyWords(sentence):
|
|
||||||
found = []
|
|
||||||
for line in wantedfile:
|
|
||||||
line=line.strip('\n')
|
|
||||||
if sentence.find(line) >= 0:
|
|
||||||
found.append(line)
|
|
||||||
|
|
||||||
if found:
|
|
||||||
return found
|
|
||||||
return 1
|
|
||||||
|
|
||||||
temp = commandStrip("Guten tag, ich want you to pick up big red triangle.")
|
|
||||||
temp = searchKeyWords(temp)
|
|
||||||
if temp!=1:
|
|
||||||
print("I have found words: " + " ".join(temp))
|
|
||||||
|
|
||||||
dotsfile.close()
|
|
||||||
wantedfile.close()
|
|
Loading…
Reference in New Issue
Block a user