From c43f89984bfe523e0f7b6a97ae401e4df535db27 Mon Sep 17 00:00:00 2001 From: gn64_jp Date: Mon, 19 Oct 2009 14:46:15 +0000 Subject: [PATCH] begin to implement guess function. git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@182 4e526526-5e11-4fc0-8910-f8fd03428081 --- rec10/trunk/src/guess.py | 73 ++++++++++++++++++++++++++++++++++++++++------- rec10/trunk/src/tester.py | 3 +- 2 files changed, 64 insertions(+), 12 deletions(-) diff --git a/rec10/trunk/src/guess.py b/rec10/trunk/src/guess.py index b868167..d65eb76 100644 --- a/rec10/trunk/src/guess.py +++ b/rec10/trunk/src/guess.py @@ -9,6 +9,7 @@ import time import os import datetime import n_gram +import zenhan def detName(title,path): tt=detNameType(title, path) @@ -22,44 +23,86 @@ def detNum(title,movepath): ff=[] maxnum=0 for file in files: + print file + file=os.path.join(movepath,file) if os.path.isfile(file): name=os.path.splitext(os.path.split(file)[1]) + name=name[0] + name=zenhan.toHankaku(unicode(name)) p1=detNameType(name,movepath) print p1['title']+" "+str(p1['num']) time1=time.localtime(os.path.getmtime(file)) - ff.append([p1['num'],p1['title'],time1]) - if maxnumd: + dn=dn+d + if dm%d*2>d: + dm=dm+d + if dp%d*2>d: + dp=dp+d + print str(d)+":"+str(dn) + if dp!=dn: + ret.append([dn/d,60]) + ret.append([dp/d,40]) + elif dm!=dn: + ret.append([dn/d,60]) + ret.append([dm/d,40]) + else: + ret.append([dn/d,100]) + return ret def detNameType(title,path): """ type A ---title# type B ---title#subtitle type C ---title subtitle type D ---title(without number) + type Aj ---title第話 path --search reflexively """ - #print title + print title #rA=re.compile(".+(?P)#\d(?P<num>)\s[0,10]\z") rA=re.compile("(.+)#(\d*)\s*\Z") tA=rA.match(title) rB=re.compile("(.+)#(\d*)\s*(\D*)") tB=rB.match(title) + rAj=re.compile("(.+)第(\d*)話\s*\Z") + tAj=rAj.match(title) ret={'title':"",'type':"",'num':0,'subtitle':"",'folder':""} if tA: print "typeA" @@ -69,6 +112,14 @@ def detNameType(title,path): ret['title']=tA.group(1) ret['num']=int(tA.group(2)) ret['folder']=searchFolder(tA.group(1),path) + if tAj: + print "typeA" + print "title="+tAj.group(1) + print "num="+tAj.group(2) + ret['type']="Aj" + ret['title']=tAj.group(1) + ret['num']=int(tAj.group(2)) + ret['folder']=searchFolder(tAj.group(1),path) elif tB: print "typeB" print "title="+tB.group(1) @@ -100,7 +151,7 @@ def detNameType(title,path): #print "title="+rt[0][1:]+"/" #print "subtitle = "+title.replace(rt[0][1:],"")[1:] ret['title']=rt[0][1:] - ret['num']="" + ret['num']=-1 ret['folder']=rt[2] ret['subtitle']=title.replace(rt[0][1:],"")[1:] if ret['subtitle'].replace(" ","")=="": diff --git a/rec10/trunk/src/tester.py b/rec10/trunk/src/tester.py index b6c26c2..018aa4a 100644 --- a/rec10/trunk/src/tester.py +++ b/rec10/trunk/src/tester.py @@ -55,5 +55,6 @@ if __name__ == "__main__": #xml2db.xml2db("te18.xml", "te20") #classify.detNameType("te#st#25") #classify.detNameType("te#st#32 subtest") - guess.detNameType("",recordedpath) + #guess.detNameType("",recordedpath) + #guess.detNum("よくわかる現代魔法",recordedpath+"アニメ/ひだまりスケッチ") "" \ No newline at end of file -- 2.11.0