forked from vishal3011/Sen-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.py
More file actions
45 lines (31 loc) · 817 Bytes
/
Copy pathcode.py
File metadata and controls
45 lines (31 loc) · 817 Bytes
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
38
39
40
41
42
43
44
import nltk
from nltk.tokenize import *
from nltk.corpus import *
file = open('dummy.txt', 'r')
dummy= file.read()
lines = dummy.split('\n')
declarations=["declar","creat","tak","mak","consider","new",'New','Creat','Declar','Tak','Mak','Consider']
integers=["integer","int","integers"]
naming=["nam","call"]
initialize=["valu","giv","initializ","assign"]
var_names=[]
code_file = open('code.c','a')
def declare(di):
for j in di["NN"]:
#for jj in integers:
if "int" in j:
print("int")
break
for a in lines:
c = word_tokenize(a)
b = nltk.pos_tag(c)
dict = {"VB": [], "NN": [], "JJ": [], "DT": [], "CC": [], "PR": []}
for (w,t) in b:
if (t in dict):
dict[t[:2]].append(w)
print(dict)
for i in dict["VB"]:
for d in declarations:
if d in i:
print("yess!!!")
declare(dict)