Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/dict.py
diff options
context:
space:
mode:
Diffstat (limited to 'dict.py')
-rw-r--r--dict.py33
1 files changed, 16 insertions, 17 deletions
diff --git a/dict.py b/dict.py
index ac3e6ad..d9a2836 100644
--- a/dict.py
+++ b/dict.py
@@ -26,12 +26,12 @@ class dict:
self.wordid_list = []
self.length = 0
- def getnumwords(self, level = 0):
+ def getnumwords(self, length = 0):
if self.numwords == -1:
- if level == 0:
+ if length == 0:
self.cur.execute("SELECT COUNT(wordid) from las_word")
else:
- self.cur.execute("SELECT COUNT(wordid) from las_word where length = ?", (level, ))
+ self.cur.execute("SELECT COUNT(wordid) from las_word where length = ?", (length, ))
self.numwords = self.cur.fetchone()
return self.numwords
@@ -64,6 +64,7 @@ class word:
self.cur.execute("SELECT * from las_word where laswid = ?", (value,))
elif identifier == "wordid":
self.wordid = value
+ print "Word is initiated"
self.cur.execute("SELECT * from las_word where wordid = ?", (value,))
elif identifier == "word":
self.word = value
@@ -73,6 +74,7 @@ class word:
self.wordid = None
self.word = None
self.length = None
+ self.synsetid_list = []
return
else:
return "Invalid Usage"
@@ -82,6 +84,7 @@ class word:
self.wordid = wordid
self.word = lemma
self.length = length
+ self.synsetid_list = []
def getword(self):
return self.word
@@ -90,7 +93,6 @@ class word:
return self.wordid
def getsynsetid(self):
- self.synsetid_list = []
self.cur.execute("SELECT * from las_sense where wordid = ?", (self.wordid,))
for (wordid, synsetid, rank) in self.cur:
self.synsetid_list.append(synsetid)
@@ -98,9 +100,7 @@ class word:
def getdef(self):
self.def_list = []
- try:
- self.synsetid_list
- except AttributeError:
+ if self.synsetid_list == []:
self.getsynsetid()
for synsetid in self.synsetid_list:
self.cur.execute("SELECT * from las_synset where synsetid = ?", (synsetid,) )
@@ -109,9 +109,7 @@ class word:
return self.def_list
def getusage(self):
- try:
- self.synsetid_list
- except AttributeError:
+ if self.synsetid_list == []:
self.getsynsetid()
self.usage_list = []
for synsetid in self.synsetid_list:
@@ -126,10 +124,11 @@ if __name__ == "__main__":
num_words = k.getnumwords()
print num_words
- wordid = k.getrandomwordid(15) #will return word of length 15
- l = word("wordid", wordid )
-
- print l.getword()
- l.getsynsetid()
- print l.getdef()
- print l.getusage() \ No newline at end of file
+ id = k.getrandomwordid(length = 5, numwords = 3) #will return word of length 15
+ for (wordid,) in id:
+ print wordid
+ l = word("wordid", wordid )
+
+ print l.getword()
+ print l.getdef()
+ print l.getusage() \ No newline at end of file