當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。