Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAssim Deodia <assim.deodia@gmail.com>2008-06-21 11:20:16 (GMT)
committer Assim Deodia <assim.deodia@gmail.com>2008-06-21 11:20:16 (GMT)
commitc1ac8a3d3ea9a180b5645c52dddc9d6a43a0885e (patch)
tree73828b9dc04aa240a1f22e58a64071b0dbed2adb
parentbff3f1a1c99f3c7c79808972fe5345949d686e6d (diff)
bug fix: definition was not changing with word
-rw-r--r--dict.py33
-rw-r--r--dict.pycbin0 -> 4522 bytes
-rw-r--r--las.py14
-rw-r--r--las.pycbin0 -> 7364 bytes
-rw-r--r--ls.py90
5 files changed, 67 insertions, 70 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
diff --git a/dict.pyc b/dict.pyc
new file mode 100644
index 0000000..ecaf589
--- /dev/null
+++ b/dict.pyc
Binary files differ
diff --git a/las.py b/las.py
index 1a61511..9ed08d3 100644
--- a/las.py
+++ b/las.py
@@ -8,16 +8,6 @@ import csnd
from dict import dict
from dict import word
-bus = dbus.SessionBus()
-APLAY = "/usr/bin/aplay"
-espeak_object = bus.get_object('org.laptop.Speech','/org/laptop/Speech')
-
-dictionary = ""
-pronouncedict = ""
-skill = ""
-answer = ""
-clearit = "" # Because I couldn't null a string
-
# My class for key detection
class _Getch:
"""Gets a single character from standard input. Does not echo to the screen."""
@@ -127,7 +117,6 @@ class listenspell():
def load_wordid(self, num_words):
temp_list = []
self.wordid_list = []
-
temp_list = self.dict_obj.getrandomwordid(length = self.skill_level,numwords = num_words)
for(wordid, ) in temp_list:
self.wordid_list.append(wordid)
@@ -135,7 +124,8 @@ class listenspell():
def getwordinfo(self,wordid, attribute):
if self.word_obj.getwordid() != wordid:
- self.word_obj.__init__("wordid", wordid)
+ self.word_obj.__init__(identifier = "wordid", value= wordid)
+ print "Hello Again"
self.words_played = self.words_played + 1
if attribute == "def":
diff --git a/las.pyc b/las.pyc
new file mode 100644
index 0000000..eff4507
--- /dev/null
+++ b/las.pyc
Binary files differ
diff --git a/ls.py b/ls.py
index 82a19da..6871e61 100644
--- a/ls.py
+++ b/ls.py
@@ -2,10 +2,6 @@ from las import listenspell
-las = listenspell()
-las.clearscreen()
-las.playsound("begin")
-
########################################################################################
def playword(wordid):
elem = las.getwordinfo(wordid, "word") #get a word from the list
@@ -35,6 +31,7 @@ def playword(wordid):
2 for Sample
3 to repete the word
4 for word length
+ * to quit
or any other key to answer"""
if reprint == True:
print string
@@ -53,8 +50,10 @@ def playword(wordid):
reprint = True
for (sample) in usage:
las.saytext(sample)
+ reprint = False
num_sample = num_sample - 1
if num_sample != 0:
+ reprint = True
print "To get another sample press 'n' or anyother key to answer"
k = las.getkey()
if k != 'n': break
@@ -63,6 +62,8 @@ def playword(wordid):
reprint = False
elif k == "4":
print "Word Length:" + str(len(elem))
+ elif k =="*":
+ las.exitgame()
else:
cluemode = False
@@ -105,44 +106,51 @@ def getskilllevel():
-gameover = False
-while gameover == False:
- levelsize = 7 # this stays constant throughout
-
- getskilllevel()
- wordidlist = las.load_wordid(levelsize + 3) # At max Three error possible
- num_words = len(wordidlist)
- las.clearscreen()
- #### MAIN LOOP
+if __name__=='__main__':
+ las = listenspell()
+ las.clearscreen()
las.playsound("begin")
-
-
- for index in range(num_words):
-
- ## print pronouncedict
- ## print pronouncedictstring
- ## print pronouncelist
- wordid = wordidlist[index]
- result = playword(wordid)
- print "Your score is " + str(las.getpoints())
-
- if result == True:
- if las.getwords_correct == 7:
- print "Very good."
- print "If you want to play game again with another level press $ or any other key to quit"
- k = las.getkey()
- if k == '$':
- break # Restart game with next level
- else:
- las.exitgame()
-
- if las.getwords_correct == 7:
- continue # Restart game with next level
- else:
- gameover = True
- las.saytext("Game Over")
- print "Game Over."
- las.exitgame()
+
+ gameover = False
+ while gameover == False:
+ levelsize = 7 # this stays constant throughout
+
+ getskilllevel()
+ wordidlist = las.load_wordid(levelsize + 3) # At max Three error possible
+ num_words = len(wordidlist)
+ las.clearscreen()
+
+ #### MAIN LOOP
+
+ las.playsound("begin")
+
+
+ for index in range(num_words):
+
+ ## print pronouncedict
+ ## print pronouncedictstring
+ ## print pronouncelist
+ wordid = wordidlist[index]
+ result = playword(wordid)
+ print "Your score is " + str(las.getpoints())
+
+ if result == True:
+ if las.getwords_correct == 7:
+ print "Very good."
+ print "If you want to play game again with another level press % or any other key to quit"
+ k = las.getkey()
+ if k == '%':
+ break # Restart game with next level
+ else:
+ las.exitgame()
+
+ if las.getwords_correct == 7:
+ continue # Restart game with next level
+ else:
+ gameover = True
+ las.saytext("Game Over")
+ print "Game Over."
+ las.exitgame()