mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
MecabBinder should support both of Python 2 and 3.
This commit is contained in:
parent
89d7ab6941
commit
3bd40f35b4
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user