issues/514

This commit is contained in:
恍兮惚兮 2024-02-09 21:15:27 +08:00
parent 0935407e2a
commit 24cd9b7c04
4 changed files with 22 additions and 14 deletions

View File

@ -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 :

View File

@ -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:

View File

@ -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

View File

@ -656,7 +656,8 @@
"mecab": {
"use": false,
"path": "",
"name": "MeCab"
"name": "MeCab",
"codec":0
},
"mojinlt": {
"use": false,