delphin.tfs¶
Basic classes for modeling feature structures.
This module defines the FeatureStructure
and
TypedFeatureStructure
classes, which model an attribute value
matrix (AVM), with the latter including an associated type. They allow
feature access through TDL-style dot notation regular dictionary keys.
In addition, the TypeHierarchy
class implements a
multiple-inheritance hierarchy with checks for type subsumption and
compatibility.
-
class
delphin.tfs.
FeatureStructure
(featvals=None)[source]¶ A feature structure.
This class manages the access of nested features using dot-delimited notation (e.g.,
SYNSEM.LOCAL.CAT.HEAD
).Parameters: featvals (dict, list) – a mapping or iterable of feature paths to feature values -
features
(expand=False)[source]¶ Return the list of tuples of feature paths and feature values.
Parameters: expand (bool) – if True
, expand all feature pathsExample
>>> fs = FeatureStructure([('A.B', 1), ('A.C', 2)]) >>> fs.features() [('A', <FeatureStructure object at ...>)] >>> fs.features(expand=True) [('A.B', 1), ('A.C', 2)]
-