def new_bayeskey(self):
db = self.connect_db()
try:
- db[1].execute('\
- CREATE TABLE bayeskey \
+ db[1].execute('CREATE TABLE bayeskey \
(\
- key VARCHAR(10),\
+ keychar VARCHAR(10),\
chtxt VARCHAR(20),\
- ratio_rec DECIMAL(24,8),\
- ratio_all DECIMAL(24,8),\
+ ratio_rec DECIMAL(32,8),\
+ ratio_all DECIMAL(32,8)\
)')
except:
""
self.close_db(db)
def add_bayeskey(self,key,chtxt,ratio_rec,ratio_all):
db = self.connect_db()
- db[1].executemany('\
+ ratio_rec=str(ratio_rec)
+ ratio_all=str(ratio_all)
+ print (key,chtxt,ratio_rec,ratio_all)
+ db[1].execute('\
INSERT IGNORE INTO bayeskey \
- (key,chtxt,ratio_rec,ratio_all) \
- values(%s,%s,%s,%s)',\
- (key,chtxt,ratio_rec,ratio_all))
+ (keychar,chtxt,ratio_rec,ratio_all) \
+ values (%s,%s,%s,%s)',\
+ (key,chtxt,ratio_rec,ratio_all))
self.close_db(db)
def change_bayeskey(self,key,chtxt,new_ratio_rec,new_ratio_all):
"""
- statuをiだけ増減する
- iはint
"""
db = self.connect_db()
db[1].execute("\
- UPDATE bayeskey SET ratio_rec=%s,ratio_all=%s WHERE key=%s AND chtxt=%s",(new_ratio_rec,new_ratio_all,key,chtxt)\
+ UPDATE bayeskey SET ratio_rec=%s,ratio_all=%s WHERE keychar=%s AND chtxt=%s",(str(new_ratio_rec),str(new_ratio_all),key,chtxt)\
)
self.close_db(db)
def change_ratio_all_bayeskey(self,chtxt,beforenum,newnum):
db = self.connect_db()
db[1].execute("\
- UPDATE bayeskey SET ratio_all=ratio_all*%s/(%s+%s) WHERE chtxt=%s",(beforenum,newnum,beforenum,chtxt)\
+ UPDATE bayeskey SET ratio_all=ratio_all*%s/(%s+%s) WHERE chtxt=%s",(str(beforenum),str(newnum),str(beforenum),chtxt)\
)
self.close_db(db)
def change_ratio_rec_bayeskey(self,key,chtxt,beforenum,addnum):
db = self.connect_db()
+ beforenum=str(beforenum)
+ addnum=str(addnum)
db[1].execute("\
- UPDATE bayeskey SET ratio_rec=(ratio_rec*%s+%s)/%s WHERE chtxt=%s AND key=%s",\
+ UPDATE bayeskey SET ratio_rec=(ratio_rec*%s+%s)/%s WHERE chtxt=%s AND keychar=%s",\
(beforenum,addnum,beforenum,chtxt,key)\
)
self.close_db(db)
def select_by_key_bayeskey(self,chtxt,key):
db = self.connect_db()
dbexe = db[1].execute("\
- SELECT key,chtxt,ratio_rec,ratio_all \
+ SELECT keychar,chtxt,ratio_rec,ratio_all \
FROM bayeskey \
- WHERE key = %s AND chtxt = %s", \
+ WHERE keychar = %s AND chtxt = %s", \
(key,chtxt))
dls = []
if dbexe > 0: