本文整理汇总了Python中enchant.DictWithPWL方法的典型用法代码示例。如果您正苦于以下问题:Python enchant.DictWithPWL方法的具体用法?Python enchant.DictWithPWL怎么用?Python enchant.DictWithPWL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enchant
的用法示例。
在下文中一共展示了enchant.DictWithPWL方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: usePWL
# 需要导入模块: import enchant [as 别名]
# 或者: from enchant import DictWithPWL [as 别名]
def usePWL(self, dictionary):
""" Restart spellchecker with personal private list
"""
import enchant
pwlDict = settings.get('spellchecker:pwlDict')
pwlLang = settings.get('spellchecker:pwlLang')
if pwlLang:
try:
(name, extension) = pwlDict.rsplit('.', 1)
pwlDict = name + '_' + dictionary.tag + "." + extension
except:
pwlDict = name + '_' + dictionary.tag
self.dict = enchant.DictWithPWL(dictionary.tag, pwlDict)
self.highlighter = Highlighter(self.document())
self.highlighter.setDict(self.dict)
示例2: __init__
# 需要导入模块: import enchant [as 别名]
# 或者: from enchant import DictWithPWL [as 别名]
def __init__(self):
HTMLParser.__init__(self)
self.__spell_check_res = {}
self.__grammar_check_res = None
self.__ignore_tag = False
self.__is_code_block = False
self.__in_code_block = False
self.__dictionary = enchant.DictWithPWL('en_US', 'web-data/mxnet/doc/ignored_words.txt')
self.__spell_checker = SpellChecker(self.__dictionary)
self.__parsed_content = ""
self.__grammar_checker = grammar_check.LanguageTool('en-US')
示例3: open
# 需要导入模块: import enchant [as 别名]
# 或者: from enchant import DictWithPWL [as 别名]
def open(self):
self.initialized = False
self.private_dict_file = None
if enchant is None:
return
dict_name = self.config.spelling_dict
if not dict_name:
return
self.ignore_list = [w.strip() for w in self.config.spelling_ignore_words.split(",")]
# "param" appears in docstring in param description and
# "pylint" appears in comments in pylint pragmas.
self.ignore_list.extend(["param", "pylint"])
# Expand tilde to allow e.g. spelling-private-dict-file = ~/.pylintdict
if self.config.spelling_private_dict_file:
self.config.spelling_private_dict_file = os.path.expanduser(
self.config.spelling_private_dict_file)
if self.config.spelling_private_dict_file:
self.spelling_dict = enchant.DictWithPWL(
dict_name, self.config.spelling_private_dict_file)
self.private_dict_file = open(
self.config.spelling_private_dict_file, "a")
else:
self.spelling_dict = enchant.Dict(dict_name)
if self.config.spelling_store_unknown_words:
self.unknown_words = set()
self.tokenizer = get_tokenizer(dict_name,
chunkers=[ForwardSlashChunkder],
filters=[EmailFilter,
URLFilter,
WikiWordFilter,
WordsWithDigigtsFilter,
WordsWithUnderscores,
CamelCasedWord,
SphinxDirectives])
self.initialized = True
示例4: suggest
# 需要导入模块: import enchant [as 别名]
# 或者: from enchant import DictWithPWL [as 别名]
def suggest(self):
if re.sub(r'[a-zA-Z\d\'\-\.\s]', '', self.word):
return None
import enchant
try:
d = enchant.DictWithPWL(
'en_US', path + '/data/spell-checker/american-english-large')
except:
d = enchant.Dict('en_US')
suggestion = d.suggest(self.word)
return suggestion
示例5: __init__
# 需要导入模块: import enchant [as 别名]
# 或者: from enchant import DictWithPWL [as 别名]
def __init__(self, lang, suggest, word_list_filename,
tokenizer_lang='en_US', filters=None, context_line=False):
if filters is None:
filters = []
self.dictionary = enchant.DictWithPWL(lang, word_list_filename)
self.tokenizer = get_tokenizer(tokenizer_lang, filters)
self.original_tokenizer = self.tokenizer
self.suggest = suggest
self.context_line = context_line
示例6: get_new_dictionary
# 需要导入模块: import enchant [as 别名]
# 或者: from enchant import DictWithPWL [as 别名]
def get_new_dictionary(dictionary_lang="en_GB"):
personal_words_list_path = os.path.join(CONFIG_PATH, 'personal-words-list.txt')
return enchant.DictWithPWL(dictionary_lang, personal_words_list_path)
示例7: open
# 需要导入模块: import enchant [as 别名]
# 或者: from enchant import DictWithPWL [as 别名]
def open(self):
self.initialized = False
self.private_dict_file = None
if enchant is None:
return
dict_name = self.config.spelling_dict
if not dict_name:
return
self.ignore_list = [
w.strip() for w in self.config.spelling_ignore_words.split(",")
]
# "param" appears in docstring in param description and
# "pylint" appears in comments in pylint pragmas.
self.ignore_list.extend(["param", "pylint"])
# Expand tilde to allow e.g. spelling-private-dict-file = ~/.pylintdict
if self.config.spelling_private_dict_file:
self.config.spelling_private_dict_file = os.path.expanduser(
self.config.spelling_private_dict_file
)
if self.config.spelling_private_dict_file:
self.spelling_dict = enchant.DictWithPWL(
dict_name, self.config.spelling_private_dict_file
)
self.private_dict_file = open(self.config.spelling_private_dict_file, "a")
else:
self.spelling_dict = enchant.Dict(dict_name)
if self.config.spelling_store_unknown_words:
self.unknown_words = set()
self.tokenizer = get_tokenizer(
dict_name,
chunkers=[ForwardSlashChunkder],
filters=[
EmailFilter,
URLFilter,
WikiWordFilter,
WordsWithDigigtsFilter,
WordsWithUnderscores,
CamelCasedWord,
SphinxDirectives,
],
)
self.initialized = True