3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
7 def get_db_key(key,chtxt):
8 return rec10d.rec10db.select_by_key_in_auto_bayes_key(key, chtxt)
9 def change_db_epg(chtxt,beforenum,newnum):
10 rec10d.rec10db.change_ratio_all_reduce_in_auto_bayes_key(chtxt, beforenum, newnum)
11 def change_db_num(chtxt,recaddnum,alladdnum):
15 rec10d.rec10db.add_num_in_auto_bayes_key(chtxt, recaddnum,alladdnum)
16 def change_db_ratio_rec(key,chtxt,beforenum,addnum):
17 rec10d.rec10db.change_ratio_rec_in_auto_bayes_key(key, chtxt, beforenum, addnum)
18 def change_db_ratio_rec_many(chtxt,beforenum,list):
19 rec10d.rec10db.change_multi_ratio_rec_in_auto_bayes_key(chtxt, beforenum, list)
20 def change_db_reduce_ratio_rec(chtxt,beforenum,addnum):
21 rec10d.rec10db.change_ratio_rec_reduce_in_auto_bayes_key(chtxt, beforenum, addnum)
22 def change_db_ratio_all(key,chtxt,beforenum,addnum):
23 rec10d.rec10db.change_ratio_all_in_auto_bayes_key(key, chtxt, beforenum, addnum)
24 def change_db_ratio_all_many(chtxt,beforenum,list):
25 rec10d.rec10db.change_multi_ratio_all_in_auto_bayes_key(chtxt,beforenum, list)
26 def get_db_num(chtxt):
27 ret=get_db_key("NUM", chtxt)
29 rec10d.rec10db.add_in_auto_bayes_key("NUM", chtxt, 1,1)
30 ret=get_db_key("NUM", chtxt)
32 def update_recall(chtxt,titles,descs,newnum):
38 str1=titles*2+descs+titles*2
39 noun=n_gram.get_noun_quad_gram(str1)
40 bnum=get_db_num(chtxt)[3]
43 change_db_ratio_all_many(chtxt, bnum,noun)
44 change_db_epg(chtxt, bnum, newnum)
45 change_db_num(chtxt, 0, newnum)
46 def add_key(chtxt,title,desc):
49 str1=title*2+desc+title*2##タイトルは重視したいので幾度か足す。
51 noun=n_gram.get_noun_quad_gram(str1)#nounは辞書のキーに文字を、中身に出現回数を書いたもの。
52 bnum=get_db_num(chtxt)[2]
56 change_db_ratio_rec_many(chtxt, bnum, noun)
57 change_db_num(chtxt,1,0)
58 change_db_reduce_ratio_rec(chtxt, bnum,1)
59 def calc_key(chtxt,title,desc):
66 str1=title*2+desc+title*2##タイトルは重視したいので幾度か足す。
67 noun=n_gram.get_noun_quad_gram(str1)#nounは辞書のキーに文字を、中身に出現回数を書いたもの。
70 for key,num in noun.items():
71 pp=get_db_key(key,chtxt)
72 pp2=get_db_key(key,"ALL")
79 p=(1000*trec+5)/(1000*tall+5)
81 p2=(1000*tarec+5)/(1000*taall+5)
84 if (nump/tnum)>kyoukai: