summaryrefslogtreecommitdiff
path: root/gstudio/update_lexicon.py
blob: 8a4a359ebe1ff5e9e73415e93a40341ff6e780df (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
from gstudio.lex import *

def lex(self):
	destination = open( "/home/user/gnowsys-studio/demo/aFile.pl", "a+"  )        
        f = destination.read()
        ##print "f---" ,f
        b = []
        c = []
        r = []
        source_r = []
        """
        strpos=f.find("one")
        ##print strpos
        """
        
        #Updates lexicon file with each Objecttype as noun singular and plural
        for each in Objecttype.objects.all():
             source=get_lex_OT(each)
             for e_i in source:
                        strpos=f.find(e_i)
                        #print strpos
                        if strpos == -1:
                             #print "Going to write --", e_i
                             destination.write(str(e_i) + '\n')
                        else:
                             pass
             
        #Updates lexicon file with Gbobject and author of each Nodetype and stores them as Proper noun
        for each in Nodetype.objects.all():
             for a in get_lex_author(each):
                  b.append(a)
        

        for each in Gbobject.objects.all():
            for a in get_lex_GB(each):
                  b.append(a)

        
        #Compares each of the entries of author & Gbobject, to make a unique list
        for each in b:
            if each not in c:
                    c.append(each)

        for e_i in c:
                 strpos=f.find(e_i)
                 #print strpos
                 if strpos == -1:
                          #print "Going to write --", e_i
                          destination.write(str(e_i) + '\n')
                 else:
                          pass
        
        #Updates lexicon file with each Relationtype as an intransitive adjective or transitive verb  
        for each in Relationtype.objects.all():
              for e_i in get_lex_RT(each):
                    r.append(e_i)
        ##print " r---(will contain all rts, may contain repetition of prepositions)"
         
        #Compares each of the entries to ensure preposition entries are unique        
        for each_r in r:
            if each_r not in source_r:
                 source_r.append(each_r) 
                 
        ###print "source_r, should not contain any rep"    
                           
        for e_ir in source_r:
                        strpos=f.find(e_ir)
                        #print strpos
                        if strpos == -1:
                             ##print "Going to write the above statement",e_i
                             destination.write(str(e_ir) + '\n')
                        else:
                             pass

        #Updates lexicon file with each Metatype as noun singular and plural
        for each in Metatype.objects.all():
              source_m=get_lex_MT(each)
              for e_im in source_m:
                        strpos=f.find(e_im)
                        #print strpos
                        if strpos == -1:
                             ##print "Going to write the above statement",e_i
                             destination.write(str(e_im) + '\n')
                        else:
                             pass
         
        #Updates lexicon file with each Attributetype as noun singular and plural
        for each in Attributetype.objects.all():
              source_a=get_lex_AT(each)
              for e_ia in source_a:
                        strpos=f.find(e_ia)
                        #print strpos
                        if strpos == -1:
                             ##print "Going to write the above statement",e_i
                             destination.write(str(e_ia) + '\n')
                        else:
                             pass
         
        
        destination.close()