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.
reinflect(word, feats)

Generate analyses for a given word from a given set of inflectional features.

Parameters:
Returns:

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

Return type:

list of dict

Raises:

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)