Quick search

Table Of Contents

Spelling

Provides abstracted access to a range of spellchecking backends as well as word suggestions. The API is inspired by enchant but other backends can be added that implement the same API.

Spelling currently requires python-enchant for all platforms except OSX, where a native implementation exists.

>>> from kivy.core.spelling import Spelling
>>> s = Spelling()
>>> s.list_languages()
['en', 'en_CA', 'en_GB', 'en_US']
>>> s.select_language('en_US')
>>> s.suggest('helo')
[u'hole', u'help', u'helot', u'hello', u'halo', u'hero', u'hell', u'held',
 u'helm', u'he-lo']
class kivy.core.spelling.SpellingBase(language=None)[ソース]

ベースクラス: builtins.object

Base class for all spelling providers. Supports some abstract methods for checking words and getting suggestions.

check(word)[ソース]

If word is a valid word in self._language (the currently active language), returns True. If the word shouldn’t be checked, returns None (e.g. for ‘’). If it is not a valid word in self._language, return False.

Parameters:
word: str

The word to check.

list_languages()[ソース]

Return a list of all supported languages. E.g. [‘en’, ‘en_GB’, ‘en_US’, ‘de’, ...]

select_language(language)[ソース]

From the set of registered languages, select the first language for language.

Parameters:
language: str

Language identifier. Needs to be one of the options returned by list_languages(). Sets the language used for spell checking and word suggestions.

suggest(fragment)[ソース]

For a given fragment (i.e. part of a word or a word by itself), provide corrections (fragment may be misspelled) or completions as a list of strings.

Parameters:
fragment: str

The word fragment to get suggestions/corrections for. E.g. ‘foo’ might become ‘of’, ‘food’ or ‘foot’.

exception kivy.core.spelling.NoSuchLangError[ソース]

ベースクラス: Exception

Exception to be raised when a specific language could not be found.

exception kivy.core.spelling.NoLanguageSelectedError[ソース]

ベースクラス: Exception

Exception to be raised when a language-using method is called but no language was selected prior to the call.