| | |
- __builtin__.object
-
- ProviderDesc
- _EnchantObject(__builtin__.object)
-
- Broker
- Dict
-
- DictWithPWL
class Broker(_EnchantObject) |
| |
Broker object for the Enchant spellchecker.
Broker objects are responsible for locating and managing dictionaries.
Unless custom functionality is required, there is no need to use Broker
objects directly. The 'enchant' module provides a default broker object
so that 'Dict' objects can be created directly.
The most important methods of this class include:
* dict_exists: check existence of a specific language dictionary
* request_dict: obtain a dictionary for specific language
* set_ordering: specify which dictionaries to try for for a
given language. |
| |
- Method resolution order:
- Broker
- _EnchantObject
- __builtin__.object
Methods defined here:
- __del__(self)
- Broker object destructor.
- __init__(self)
- Broker object constructor.
This method is the constructor for the 'Broker' object. No
arguments are required.
- describe(self)
- Return list of provider descriptions.
This method returns a list of descriptions of each of the
dictionary providers available. Each entry in the list is a
ProviderDesc object.
- dict_exists(self, tag)
- Check availability of a dictionary.
This method checks whether there is a dictionary available for
the language specified by 'tag'. It returns True if a dictionary
is available, and False otherwise.
- get_param(self, name)
- Get the value of a named parameter on this broker.
Parameters are used to provide runtime information to individual
provider backends. See the method 'set_param' for more details.
- list_dicts(self)
- Return list of available dictionaries.
This method returns a list of dictionaries available to the
broker. Each entry in the list is a two-tuple of the form:
(tag,provider)
where <tag> is the language lag for the dictionary and
<provider> is a ProviderDesc object describing the provider
through which that dictionary can be obtained.
- list_languages(self)
- List languages for which dictionaries are available.
This function returns a list of language tags for which a
dictionary is available.
- request_dict(self, tag=None)
- Request a Dict object for the language specified by <tag>.
This method constructs and returns a Dict object for the
requested language. 'tag' should be a string of the appropriate
form for specifying a language, such as "fr" (French) or "en_AU"
(Australian English). The existence of a specific language can
be tested using the 'dict_exists' method.
If <tag> is not given or is None, an attempt is made to determine
the current language in use. If this cannot be determined, Error
is raised.
NOTE: this method is functionally equivalent to calling the Dict()
constructor and passing in the <broker> argument.
- request_pwl_dict(self, pwl)
- Request a Dict object for a personal word list.
This method behaves as 'request_dict' but rather than returning
a dictionary for a specific language, it returns a dictionary
referencing a personal word list. A personal word list is a file
of custom dictionary entries, one word per line.
- set_ordering(self, tag, ordering)
- Set dictionary preferences for a language.
The Enchant library supports the use of multiple dictionary programs
and multiple languages. This method specifies which dictionaries
the broker should prefer when dealing with a given language. 'tag'
must be an appropriate language specification and 'ordering' is a
string listing the dictionaries in order of preference. For example
a valid ordering might be "aspell,myspell,ispell".
The value of 'tag' can also be set to "*" to set a default ordering
for all languages for which one has not been set explicitly.
- set_param(self, name, value)
- Set the value of a named parameter on this broker.
Parameters are used to provide runtime information to individual
provider backends. For example, the myspell provider will search
any directories given in the "enchant.myspell.dictionary.path"
parameter when looking for its dictionary files.
Data descriptors inherited from _EnchantObject:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class Dict(_EnchantObject) |
| |
Dictionary object for the Enchant spellchecker.
Dictionary objects are responsible for checking the spelling of words
and suggesting possible corrections. Each dictionary is owned by a
Broker object, but unless a new Broker has explicitly been created
then this will be the 'enchant' module default Broker and is of little
interest.
The important methods of this class include:
* check(): check whether a word id spelled correctly
* suggest(): suggest correct spellings for a word
* add(): add a word to the user's personal dictionary
* remove(): add a word to the user's personal exclude list
* add_to_session(): add a word to the current spellcheck session
* store_replacement(): indicate a replacement for a given word
Information about the dictionary is available using the following
attributes:
* tag: the language tag of the dictionary
* provider: a ProviderDesc object for the dictionary provider |
| |
- Method resolution order:
- Dict
- _EnchantObject
- __builtin__.object
Methods defined here:
- __del__(self)
- Dict object destructor.
- __init__(self, tag=None, broker=None)
- Dict object constructor.
A dictionary belongs to a specific language, identified by the
string <tag>. If the tag is not given or is None, an attempt to
determine the language currently in use is made using the 'locale'
module. If the current language cannot be determined, Error is raised.
If <tag> is instead given the value of False, a 'dead' Dict object
is created without any reference to a language. This is typically
only useful within PyEnchant itself. Any other non-string value
for <tag> raises Error.
Each dictionary must also have an associated Broker object which
obtains the dictionary information from the underlying system. This
may be specified using <broker>. If not given, the default broker
is used.
- add(self, word)
- Add a word to the user's personal word list.
- add_to_pwl(self, word)
- Add a word to the user's personal word list.
- add_to_session(self, word)
- Add a word to the session personal list.
- check(self, word)
- Check spelling of a word.
This method takes a word in the dictionary language and returns
True if it is correctly spelled, and false otherwise.
- is_added(self, word)
- Check whether a word is in the personal word list.
- is_in_session(self, word)
- Check whether a word is in the session list.
- is_removed(self, word)
- Check whether a word is in the personal exclude list.
- remove(self, word)
- Add a word to the user's personal exclude list.
- remove_from_session(self, word)
- Add a word to the session exclude list.
- store_replacement(self, mis, cor)
- Store a replacement spelling for a miss-spelled word.
This method makes a suggestion to the spellchecking engine that the
miss-spelled word <mis> is in fact correctly spelled as <cor>. Such
a suggestion will typically mean that <cor> appears early in the
list of suggested spellings offered for later instances of <mis>.
- suggest(self, word)
- Suggest possible spellings for a word.
This method tries to guess the correct spelling for a given
word, returning the possibilities in a list.
Data descriptors inherited from _EnchantObject:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class DictWithPWL(Dict) |
| |
Dictionary with separately-managed personal word list.
NOTE: As of version 1.4.0, enchant manages a per-user pwl and
exclude list. This class is now only needed if you want
to explicitly maintain a separate word list in addition to
the default one.
This class behaves as the standard Dict class, but also manages a
personal word list stored in a separate file. The file must be
specified at creation time by the 'pwl' argument to the constructor.
Words added to the dictionary are automatically appended to the pwl file.
A personal exclude list can also be managed, by passing another filename
to the constructor in the optional 'pel' argument. If this is not given,
requests to exclude words are ignored.
If either 'pwl' or 'pel' are None, an in-memory word list is used.
This will prevent calls to add() and remove() from affecting the user's
default word lists.
The Dict object managing the PWL is available as the 'pwl' attribute.
The Dict object managing the PEL is available as the 'pel' attribute.
To create a DictWithPWL from the user's default language, use None
as the 'tag' argument. |
| |
- Method resolution order:
- DictWithPWL
- Dict
- _EnchantObject
- __builtin__.object
Methods defined here:
- __init__(self, tag, pwl=None, pel=None, broker=None)
- DictWithPWL constructor.
The argument 'pwl', if not None, names a file containing the
personal word list. If this file does not exist, it is created
with default permissions.
The argument 'pel', if not None, names a file containing the personal
exclude list. If this file does not exist, it is created with
default permissions.
- add(self, word)
- Add a word to the associated personal word list.
This method adds the given word to the personal word list, and
automatically saves the list to disk.
- add_to_pwl(self, word)
- Add a word to the associated personal word list.
This method adds the given word to the personal word list, and
automatically saves the list to disk.
- check(self, word)
- Check spelling of a word.
This method takes a word in the dictionary language and returns
True if it is correctly spelled, and false otherwise. It checks
both the dictionary and the personal word list.
- is_added(self, word)
- Check whether a word is in the personal word list.
- is_removed(self, word)
- Check whether a word is in the personal exclude list.
- remove(self, word)
- Add a word to the associated exclude list.
Methods inherited from Dict:
- __del__(self)
- Dict object destructor.
- add_to_session(self, word)
- Add a word to the session personal list.
- is_in_session(self, word)
- Check whether a word is in the session list.
- remove_from_session(self, word)
- Add a word to the session exclude list.
- store_replacement(self, mis, cor)
- Store a replacement spelling for a miss-spelled word.
This method makes a suggestion to the spellchecking engine that the
miss-spelled word <mis> is in fact correctly spelled as <cor>. Such
a suggestion will typically mean that <cor> appears early in the
list of suggested spellings offered for later instances of <mis>.
- suggest(self, word)
- Suggest possible spellings for a word.
This method tries to guess the correct spelling for a given
word, returning the possibilities in a list.
Data descriptors inherited from _EnchantObject:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class ProviderDesc(__builtin__.object) |
| |
Simple class describing an Enchant provider.
Each provider has the following information associated with it:
* name: Internal provider name (e.g. "aspell")
* desc: Human-readable description (e.g. "Aspell Provider")
* file: Location of the library containing the provider |
| |
Methods defined here:
- __eq__(self, pd)
- Equality operator on ProviderDesc objects.
- __hash__(self)
- Hash operator on ProviderDesc objects.
- __init__(self, name, desc, file)
- __repr__(self)
- __str__(self)
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |