当前位置: 首页>>代码示例>>Python>>正文


Python enchant.DictWithPWL方法代码示例

本文整理汇总了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) 
开发者ID:zdenop,项目名称:lector,代码行数:19,代码来源:textwidget.py

示例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') 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:13,代码来源:doc_spell_checker.py

示例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 
开发者ID:AtomLinter,项目名称:linter-pylama,代码行数:43,代码来源:spelling.py

示例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 
开发者ID:caspartse,项目名称:python-translate,代码行数:13,代码来源:translate.py

示例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 
开发者ID:sphinx-contrib,项目名称:spelling,代码行数:11,代码来源:checker.py

示例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) 
开发者ID:sky-uk,项目名称:bslint,代码行数:5,代码来源:words_dictionary.py

示例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 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:50,代码来源:spelling.py


注:本文中的enchant.DictWithPWL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。