Previous topic

speect.addendum – Addendum Class

Next topic

speect.syllabification – Syllabification Class

speect.lexicon – Lexicon Class

class speect.lexicon.SLexicon

A lexicon class, for accessing a defined lexicon.

SLexicon.name() Get the name of the lexicon.
SLexicon.description() Get a description of the lexicon.
SLexicon.language() Get the lexicon language.
SLexicon.lang_code() Get the lexicon’s ISO 639-2 language code.
SLexicon.version() Get the lexicon’s version.
SLexicon.get_word(word, features) Get a word from the lexicon.
SLexicon.features Get the features that are defined for the lexicon.
SLexicon.name()

name()

Get the name of the lexicon.

Returns:The lexicon name.
Return type:string
SLexicon.description()

description()

Get a description of the lexicon.

Returns:The lexicon description.
Return type:string
SLexicon.language()

language()

Get the lexicon language.

Returns:The lexicon language.
Return type:string
SLexicon.lang_code()

lang_code()

Get the lexicon’s ISO 639-2 language code.

Returns:The ISO 639-2 language code of the lexicon.
Return type:string
SLexicon.version()

version()

Get the lexicon’s version.

Returns:The version of the lexicon (major, minor).
Return type:tuple
SLexicon.get_word()

get_word(word, features)

Get a word from the lexicon.

Parameters:
  • word (string) – The word to get.
  • features (dict) – Specific features which might distinguish the word if multiple entries of the word exists in the lexicon. If None then the first entry of the word is returned.
Returns:

The return value is dependent on the word definition in the lexicon, and can be:

  • A list of phones for the given word (no syllables were defined in the lexicon).
  • A list of syllables, where the syllables are lists of phones.
  • None if word was not found in the lexicon.

As well as a bool value, specifying if the returned list is phones or syllables. If True then syllables were returned, else if False a list of phones were returned.

For example:

list, syllabified = mylexicon.get_word("hello", None)

Return type:

list, bool

SLexicon.features

Get the features that are defined for the lexicon.

Returns:A map of the lexicon features.
Return type:SMap