diff options
Diffstat (limited to 'dict.py')
-rwxr-xr-x | dict.py | 30 |
1 files changed, 23 insertions, 7 deletions
@@ -9,6 +9,8 @@ __debug = True class Dict: + + level_1 = () def __init__(self, sqliteDB = None): @@ -52,6 +54,10 @@ class Dict: def get_DB_name(self): return + def level_map(self, level): + level_1 = { 3:{s:30000000000, e:1460000000 }, 4:{s:23, e:312} } + pass + class Word: def __init__(self, identifier=None, value= None): @@ -75,16 +81,18 @@ class Word: self.wordid = None self.word = None self.length = None + self.freq = None self.synsetid_list = [] return None else: return "Invalid Usage" - (laswid, wordid, lemma, length) = self.cur.fetchone() + (laswid, wordid, lemma, length, freq) = self.cur.fetchone() self.las_word_id = laswid self.wordid = wordid self.word = lemma self.length = length + self.freq = freq self.synsetid_list = [] def get_word(self): @@ -107,6 +115,8 @@ class Word: return self.synsetid_list + def get_freq(self): + return self.freq def get_def(self): self.def_list = [] if self.synsetid_list == []: @@ -160,17 +170,23 @@ class Word: else:return None def update_phoneme(self, phoneme, is_correct = True): - #print phoneme + #try: + #if is_correct == True: + #self.cur.execute("UPDATE las_phoneme SET phoneme = ?, is_correct = ? where wordid = ?", (phoneme, 1, self.wordid,)) + #else: + #self.cur.execute("UPDATE las_phoneme SET phoneme = ?, is_correct = ? where wordid = ?", (phoneme, 0, self.wordid,)) + #except: try: if is_correct == True: - self.cur.execute("UPDATE las_phoneme SET phoneme = ?, is_correct = ? where wordid = ?", (phoneme, 1, self.wordid,)) - else: - self.cur.execute("UPDATE las_phoneme SET phoneme = ?, is_correct = ? where wordid = ?", (phoneme, 0, self.wordid,)) - except: - if is_correct == True: self.cur.execute("INSERT into las_phoneme (wordid, phoneme, is_correct ) VALUES (?,?,?) ", (self.wordid, phoneme, 1, )) else: self.cur.execute("INSERT into las_phoneme (wordid, phoneme, is_correct ) VALUES (?,?,?) ", (self.wordid, phoneme, 0, )) + except sqlite3.OperationalError: + if is_correct == True: + self.cur.execute("UPDATE las_phoneme SET phoneme = " + phoneme + ", is_correct = 1 where wordid = ?", (self.wordid,)) + else: + self.cur.execute("UPDATE las_phoneme SET phoneme = " + phoneme +", is_correct = 0 where wordid = ?", (self.wordid,)) + self.conn.commit() if __name__ == "__main__": |