Files
python3-cookbook/exts/zh.py
2017-09-19 20:45:29 +08:00

17 lines
405 B
Python

# -*- coding: utf-8 -*-
from sphinx.search import SearchLanguage
from smallseg import SEG
class SearchChinese(SearchLanguage):
lang = 'zh'
def init(self, options):
print("reading Chiniese dictionary")
self.seg = SEG()
def split(self, input):
return self.seg.cut(input.encode("utf8"))
def word_filter(self, stemmed_word):
return len(stemmed_word) > 1