Morphology
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.
Name | Description |
---|---|
strings | The 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.
Name | Description |
---|---|
features | The morphological features. Union[Dict, str] |
Morphology.get method
Get the FEATS string for the hash of the morphological analysis.
Name | Description |
---|---|
morph | The 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.
Name | Description |
---|---|
feats | The morphological features in Universal Dependencies FEATS format. str |
RETURNS | The morphological features as a dictionary. Dict[str, str] |
Morphology.dict_to_feats staticmethod
Convert a dictionary of features and values to a string FEATS representation.
Name | Description |
---|---|
feats_dict | The morphological features as a dictionary. Dict[str, str] |
RETURNS | The morphological features in Universal Dependencies FEATS format. str |
Attributes
Name | Description |
---|---|
FEATURE_SEP | The FEATS feature separator. Default is | . str |
FIELD_SEP | The FEATS field separator. Default is = . str |
VALUE_SEP | The 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.
Name | Description |
---|---|
vocab | The vocab. Vocab |
features | The morphological features. Union[Dict[str, str], str] |
MorphAnalysis.__contains__ method
Whether a feature/value pair is in the analysis.
Name | Description |
---|---|
feature | A feature/value pair. str |
RETURNS | Whether the feature/value pair is contained in the analysis. bool |
MorphAnalysis.__iter__ method
Iterate over the feature/value pairs in the analysis.
Name | Description |
---|---|
YIELDS | A feature/value pair in the analysis. str |
MorphAnalysis.__len__ method
Returns the number of features in the analysis.
Name | Description |
---|---|
RETURNS | The number of features in the analysis. int |
MorphAnalysis.__str__ method
Returns the morphological analysis in the Universal Dependencies FEATS string format.
Name | Description |
---|---|
RETURNS | The analysis in the Universal Dependencies FEATS format. str |
MorphAnalysis.get method
Retrieve values for a feature by field.
Name | Description |
---|---|
field | The field to retrieve. str |
default v3.5.3 | The value to return if the field is not present. If unset or None , the default return value is [] . Optional[List[str]] |
RETURNS | A list of the individual features. List[str] |
MorphAnalysis.to_dict method
Produce a dict representation of the analysis, in the same format as the tag map.
Name | Description |
---|---|
RETURNS | The dict representation of the analysis. Dict[str, str] |
MorphAnalysis.from_id classmethod
Create a morphological analysis from a given hash ID.
Name | Description |
---|---|
vocab | The vocab. Vocab |
key | The hash of the features string. int |