camel_tools.morphology.reinflector

The reinflector component of CAMeL Tools.

Classes

class camel_tools.morphology.reinflector.Reinflector(db)

Morphological reinflector component.

Parameters:db (MorphologyDB) – Database to use for generation. Must be opened in reinflection mode or both analysis and generation modes.
Raises:ReinflectorError – If db is not an instance of MorphologyDB or if db does not support reinflection.
all_feats()

Return a set of all features provided by the database used in this reinflector instance.

Returns:The set all features provided by the database used in this reinflector instance.
Return type:frozenset of str
reinflect(word, feats)

Generate surface forms and their associated analyses for a given word and a given set of (possibly underspecified) features. The surface form is accessed through the diac feature.

Parameters:
Returns:

List of generated analyses. See CAMeL Morphology Features for more information on features and their values.

Return type:

list of dict

Raises:
tok_feats()

Return a set of tokenization features provided by the database used in this reinflector instance.

Returns:The set tokenization features provided by the database used in this reinflector instance.
Return type:frozenset of str

Examples

from camel_tools.morphology.database import MorphologyDB
from camel_tools.morphology.reinflector import Reinflector

# Initialize database in reinflection mode
db = MorphologyDB.builtin_db(flags='r')

# Create reinflector instance
reinflector = Reinflector(db)

# Specify word and features to generate for
word = 'شوارع'
features = {
    'gen': 'm',
    'num': 'd',
    'prc1': 'bi_prep'
}

# Generate analyses for lemma and features
analyses = reinflector.reinflect(word, features)