3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2011 Yukikaze
7 def getDBKey(key,chtxt):
8 return rec10d.rec10db.select_by_key_in_auto_bayes_key(key, chtxt)
9 def changeDBEpg(chtxt,beforenum,newnum):
10 rec10d.rec10db.change_ratio_all_reduce_in_auto_bayes_key(chtxt, beforenum, newnum)
11 def changeDBNum(chtxt,recaddnum,alladdnum):
15 rec10d.rec10db.add_num_in_auto_bayes_key(chtxt, recaddnum,alladdnum)
16 def changeDBRatioRec(key,chtxt,beforenum,addnum):
17 rec10d.rec10db.change_ratio_rec_in_auto_bayes_key(key, chtxt, beforenum, addnum)
18 def changeDBRatioMultiRec(chtxt,beforenum,list):
19 rec10d.rec10db.change_multi_ratio_rec_in_auto_bayes_key(chtxt, beforenum, list)
20 def changeDBReduceRatioRec(chtxt,beforenum,addnum):
21 rec10d.rec10db.change_ratio_rec_reduce_in_auto_bayes_key(chtxt, beforenum, addnum)
22 def changeDBRatioAll(key,chtxt,beforenum,addnum):
23 rec10d.rec10db.change_ratio_all_in_auto_bayes_key(key, chtxt, beforenum, addnum)
24 def changeDBRatioMultiAll(chtxt,beforenum,list):
25 rec10d.rec10db.change_multi_ratio_all_in_auto_bayes_key(chtxt,beforenum, list)
27 ret=getDBKey("NUM", chtxt)
29 rec10d.rec10db.add_in_auto_bayes_key("NUM", chtxt, 1,1)
30 ret=getDBKey("NUM", chtxt)
32 def updateRecall(chtxt,titles,descs,newnum):
38 str1=titles*2+descs+titles*2
39 noun=n_gram.getNounQuadGram(str1)
40 bnum=getDBNum(chtxt)[3]
43 changeDBRatioMultiAll(chtxt, bnum,noun)
44 changeDBEpg(chtxt, bnum, newnum)
45 changeDBNum(chtxt, 0, newnum)
46 def addKey(chtxt,title,desc):
49 str1=title*2+desc+title*2##タイトルは重視したいので幾度か足す。
50 noun=n_gram.getNounQuadGram(str1)#nounは辞書のキーに文字を、中身に出現回数を書いたもの。
51 bnum=getDBNum(chtxt)[2]
54 changeDBRatioMultiRec(chtxt, bnum, noun)
55 changeDBNum(chtxt,1,0)
56 changeDBReduceRatioRec(chtxt, bnum,1)
57 def calcKey(chtxt,title,desc):
63 str1=title*2+desc+title*2##タイトルは重視したいので幾度か足す。
64 noun=n_gram.getNounQuadGram(str1)#nounは辞書のキーに文字を、中身に出現回数を書いたもの。
67 for key,num in noun.items():
68 pp=getDBKey(key,chtxt)
69 pp2=getDBKey(key,"ALL")
80 p=(1000*trec+5)/(1000*tall+5)
82 p2=(1000*tarec+5)/(1000*taall+5)