Other

Morphology

class

Store the possible morphological analyses for a language, and index them by hash. To save space on each token, tokens only know the hash of their morphological analysis, so queries of morphological attributes are delegated to this class. See MorphAnalysis for the container storing a single morphological analysis.

Morphology.__init__ method

Create a Morphology object.

NameDescription
stringsThe string store. StringStore

Morphology.add method

Insert a morphological analysis in the morphology table, if not already present. The morphological analysis may be provided in the Universal Dependencies FEATS format as a string or in the tag map dictionary format. Returns the hash of the new analysis.

NameDescription
featuresThe morphological features. Union[Dict, str]

Morphology.get method

Get the FEATS string for the hash of the morphological analysis.

NameDescription
morphThe hash of the morphological analysis. int

Morphology.feats_to_dict staticmethod

Convert a string FEATS representation to a dictionary of features and values in the same format as the tag map.

NameDescription
featsThe morphological features in Universal Dependencies FEATS format. str

Morphology.dict_to_feats staticmethod

Convert a dictionary of features and values to a string FEATS representation.

NameDescription
feats_dictThe morphological features as a dictionary. Dict[str, str]

Attributes

NameDescription
FEATURE_SEPThe FEATS feature separator. Default is |. str
FIELD_SEPThe FEATS field separator. Default is =. str
VALUE_SEPThe FEATS value separator. Default is ,. str

MorphAnalysis class

Stores a single morphological analysis.

MorphAnalysis.__init__ method

Initialize a MorphAnalysis object from a Universal Dependencies FEATS string or a dictionary of morphological features.

NameDescription
vocabThe vocab. Vocab
featuresThe morphological features. Union[Dict[str, str], str]

MorphAnalysis.__contains__ method

Whether a feature/value pair is in the analysis.

NameDescription
featureA feature/value pair. str

MorphAnalysis.__iter__ method

Iterate over the feature/value pairs in the analysis.

NameDescription

MorphAnalysis.__len__ method

Returns the number of features in the analysis.

NameDescription

MorphAnalysis.__str__ method

Returns the morphological analysis in the Universal Dependencies FEATS string format.

NameDescription

MorphAnalysis.get method

Retrieve values for a feature by field.

NameDescription
fieldThe field to retrieve. str
default v3.5.3The value to return if the field is not present. If unset or None, the default return value is []. Optional[List[str]]

MorphAnalysis.to_dict method

Produce a dict representation of the analysis, in the same format as the tag map.

NameDescription

MorphAnalysis.from_id classmethod

Create a morphological analysis from a given hash ID.

NameDescription
vocabThe vocab. Vocab
keyThe hash of the features string. int