From 7a34c31e7c4f4f0e1c5e6293666598efcab1d0cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Wrzesi=C5=84ski?= Date: Thu, 17 Nov 2016 07:49:49 +0000 Subject: [PATCH] Add 'instructionstokeywords.py' --- instructionstokeywords.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 instructionstokeywords.py diff --git a/instructionstokeywords.py b/instructionstokeywords.py new file mode 100644 index 0000000..2bc9c4b --- /dev/null +++ b/instructionstokeywords.py @@ -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() \ No newline at end of file