mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 00:24:13 +08:00
issues/514
This commit is contained in:
parent
0935407e2a
commit
24cd9b7c04
@ -25,14 +25,18 @@ def gethiragrid(self) :
|
||||
getsimpleswitch(globalconfig['hirasetting'][name],'use',parent=self,name=name,callback=functools.partial(yuitsu_switch,self,globalconfig['hirasetting'],'hiraswitchs',name,gobject.baseobject.starthira),pair='hiraswitchs'),
|
||||
|
||||
]
|
||||
if 'path' in globalconfig['hirasetting'][name]:
|
||||
line+=[getcolorbutton(globalconfig,'',callback=functools.partial(getsomepath1,self,globalconfig['hirasetting'][name]['name'],globalconfig['hirasetting'][name], 'path',globalconfig['hirasetting'][name]['name'],gobject.baseobject.starthira,True),icon='fa.gear',constcolor="#FF69B4")]
|
||||
elif 'token' in globalconfig['hirasetting'][name] and 'token_name' in globalconfig['hirasetting'][name]:
|
||||
items=[{
|
||||
't':'lineedit','l': globalconfig['hirasetting'][name]['token_name'],'d':globalconfig['hirasetting'][name],'k':'token'
|
||||
},
|
||||
{'t':'okcancel' }]
|
||||
line+=[getcolorbutton(globalconfig,'',callback= functools.partial(autoinitdialog,self, globalconfig['hirasetting'][name]['name'],800,items) ,icon='fa.gear',constcolor="#FF69B4")]
|
||||
items=[]
|
||||
for key in globalconfig['hirasetting'][name]:
|
||||
if key=='path':
|
||||
items.append({'t':'file','l':globalconfig['hirasetting'][name]['name'],'d':globalconfig['hirasetting'][name],'k':'path','dir':True})
|
||||
elif key=='token':
|
||||
items.append({'t':'lineedit','l': globalconfig['hirasetting'][name]['token_name'],'d':globalconfig['hirasetting'][name],'k':'token'})
|
||||
elif key=='codec':
|
||||
items.append({'t':'combo','l': 'codec','d':globalconfig['hirasetting'][name],'k':'codec','list':['utf8','shiftjis']})
|
||||
if len(items):
|
||||
items.append({'t':'okcancel','callback':gobject.baseobject.starthira})
|
||||
line+=[getcolorbutton(globalconfig,'',callback= functools.partial(autoinitdialog,self, globalconfig['hirasetting'][name]['name'],800,items) ,icon='fa.gear',constcolor="#FF69B4")]
|
||||
|
||||
else:
|
||||
line+=['']
|
||||
if i%3==2 :
|
||||
|
@ -16,7 +16,8 @@ class hira:
|
||||
def fy(self,text):
|
||||
start=0
|
||||
result=[]
|
||||
for node,fields in self.kks.parse( text):# self.kks.parseToNodeList(text):
|
||||
codec=['utf8','shiftjis'][globalconfig['hirasetting']['mecab']['codec']]
|
||||
for node,fields in self.kks.parse( text,codec):# self.kks.parseToNodeList(text):
|
||||
if len(fields):
|
||||
pos1=fields[0]
|
||||
if len(fields)>29:
|
||||
@ -27,6 +28,8 @@ class hira:
|
||||
kana=fields[17]
|
||||
elif len(fields)>9:
|
||||
kana=fields[9] #无kana,用lform代替
|
||||
elif len(fields)==9:
|
||||
kana=fields[8]#7/8均可,issues/514
|
||||
else:
|
||||
kana=''
|
||||
else:
|
||||
|
@ -76,16 +76,16 @@ class mecabwrap:
|
||||
self.kks=_mecab_init(mecabpath.encode('utf8'),gobject.GetDllpath('libmecab.dll') )
|
||||
def __del__(self):
|
||||
_mecab_end(self.kks)
|
||||
def parse(self,text):
|
||||
def parse(self,text,codec):
|
||||
surface=POINTER(c_char_p)()
|
||||
feature=POINTER(c_char_p)()
|
||||
num=c_uint()
|
||||
_mecab_parse(self.kks,text.encode('utf8'),pointer(surface),pointer(feature),pointer(num))
|
||||
_mecab_parse(self.kks,text.encode(codec),pointer(surface),pointer(feature),pointer(num))
|
||||
res=[]
|
||||
for i in range(num.value):
|
||||
f=feature[i]
|
||||
fields=f.decode('utf8').split(',')
|
||||
res.append((surface[i].decode('utf8'),fields))
|
||||
fields=f.decode(codec).split(',')
|
||||
res.append((surface[i].decode(codec),fields))
|
||||
_freestringlist(feature,num.value)
|
||||
_freestringlist(surface,num.value)
|
||||
return res
|
||||
|
@ -656,7 +656,8 @@
|
||||
"mecab": {
|
||||
"use": false,
|
||||
"path": "",
|
||||
"name": "MeCab"
|
||||
"name": "MeCab",
|
||||
"codec":0
|
||||
},
|
||||
"mojinlt": {
|
||||
"use": false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user