-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnl.py
More file actions
37 lines (33 loc) · 1.25 KB
/
nl.py
File metadata and controls
37 lines (33 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import sys
import nltk
from nltk.corpus import treebank
import os
inputstring = " "
wordlist=[]
for i in range(1,len(sys.argv)):
inputstring = inputstring + " " + sys.argv[i]
tokens = nltk.word_tokenize(inputstring)
tagged = nltk.pos_tag(tokens)
#print(tagged)
for i in range(0,len(tagged)):
if tagged[i][0] == "offsite":
wordlist.append(tagged[i][0])
elif tagged[i][1] != "PRP$" and tagged[i][1] != "VBP" and tagged[i][1] != "PRP" and tagged[i][1] != "TO" and tagged[i][1] != "VBZ" and tagged[i][1] != "VBG" and tagged[i][1] != "RB" and tagged[i][1] != "DT" and tagged[i][1] != "CC" and tagged[i][1] != "MD" and tagged[i][1] != "VB" and tagged[i][1] != "IN":
wordlist.append(tagged[i][0])
print(wordlist)
nolist = ["i","name","trip","pizza","site"]
output = ""
for i in range(0,len(wordlist)):
if wordlist[i] not in nolist:
if wordlist[i] == "field":
output = output + "fieldtrip "
elif wordlist[i] == "world":
output = output + "worldpizza "
elif wordlist[i] == "off":
output = output + "offsite "
else:
output = output + wordlist[i] + " "
else:
print(str(wordlist[i] + "was in nolist"))
print(output)
os.system("attendance.py " + "Bravery! " + output)