-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverb_count.py
24 lines (18 loc) · 1.06 KB
/
verb_count.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import re
import nltk
from nltk import word_tokenize
#verbs = ['disappointed', 'hurt', 'enjoyed']
verbs = ['disappointed', 'hurt', 'enjoyed', 'pleased', 'cleaned', 'taught', 'behaved','amused', 'helped', 'convinced', 'repeated', 'proved', 'confused', 'examined','talked to','hated','killed','cut','dried','introduced','prepared','blamed','expressed','distanced','found','helped','saw','changed','stopped','drove','denied','encouraged','paid','distinguished','committed','suited','explained','dressed','burnt','called','licked','satisfied','chocked','surprised','pushed','relied on','surpassed','forgave','rinsed','washed','loved']
count = 0
with open('verbs_count.txt', 'w+') as outputfile:
with open('train.txt', 'r') as txtfile:
linelist = [line for line in txtfile.readlines()]
for verb in verbs:
count = 0
for line in linelist:
if re.search(verb, line):
count += 1
print(verb, count)
outputfile.write(verb + ' ' + str(count) + '\n')
txtfile.close()
outputfile.close()