mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-10-14 09:22:11 -05:00
MecabBinder should support both of Python 2 and 3.
This commit is contained in:
1 parent
042daed015
commit
431d72091d
1 file changed
+6
-3
+6
-3
@@ -21,7 +21,7 @@ import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
from six import iteritems
|
||||
from six import iteritems, PY3
|
||||
|
||||
try:
|
||||
import MeCab
|
||||
@@ -43,13 +43,16 @@ class MecabBinder(object):
|
||||
self.dict_encode = options.get('dic_enc', 'utf-8')
|
||||
|
||||
def split(self, input):
|
||||
input2 = input.encode(self.dict_encode)
|
||||
input2 = input if PY3 else input.encode(self.dict_encode)
|
||||
if native_module:
|
||||
result = self.native.parse(input2)
|
||||
else:
|
||||
result = self.ctypes_libmecab.mecab_sparse_tostr(
|
||||
self.ctypes_mecab, input.encode(self.dict_encode))
|
||||
return result.decode(self.dict_encode).split(' ')
|
||||
if PY3:
|
||||
return result.split(' ')
|
||||
else:
|
||||
return result.decode(self.dict_encode).split(' ')
|
||||
|
||||
def init_native(self, options):
|
||||
param = '-Owakati'
|
||||
|
||||
Reference in new issue
Block a user