Parse Nodes¶
There are five types of nodes in E-HowNet expression — Entity, Reference, Placeholder, Feature, Function, and Subject.
Node Prototype¶
- class EhnParseNode
The prototype of E-HowNet parsing nodes.
See also:
ehn.parse.node.base.EhnParseNode
- head: str¶
The head of this node.
- get_features(key=None)¶
Get the features (or
[]
if not exists).If key is set, returns only the features with feature.head==key.
- get_arguments()¶
Get the arguments (or
[]
if not exists).
- get_value()¶
Get the value (or
None
if not exists).
- get_function()¶
Get the function (or
None
if not exists).
- get_anchor()¶
Get the anchor (or
None
if not exists).
- get_coindex()¶
Get the coindex key (the head of the anchor, the head of reference nodes, or
None
otherwise).
- children()¶
Yields all direct child nodes of this node.
- descendant()¶
Yields all descendant nodes (including self) of this node.
- dumps()¶
Converts to text representation.
- tree() ehn.parse.node.base.EhnParseTree ¶
Generates a tree representation of this node and all its descendant nodes.
One may use
node.tree().show()
to show a pretty tree representation.
Entity-Like Nodes¶
Entity¶
- class EhnParseEntityBase
The base class of E-HowNet parsing entity nodes.
See also:
ehn.parse.node.base.EhnParseEntityBase
Subclasses:
EhnParseNormalEntity
A normal entity. Can be an anchor.EhnParseFunctionEntity
An entity with function head. Can be an anchor.EhnParseNameEntity
A name entity.EhnParseNumberEntity
A number entity.
Reference¶
- class EhnParseReferenceBase
The base class of E-HowNet parsing reference nodes.
See also:
ehn.parse.node.base.EhnParseReferenceBase
Subclasses:
EhnParseCoindexReference
An entity refers to an anchor entity.EhnParseSubjectReference
An entity refers to the unmentioned subject entity (EhnParseSubject
in feature-based expressions.)EhnParseTildeReference
An entity refers to the root entity.
Placeholder¶
- class EhnParsePlaceholderBase
The base class of E-HowNet parsing restriction nodes.
See also:
ehn.parse.node.base.EhnParsePlaceholderBase
Subclasses:
EhnParseRestrictionPlaceholder
. Can be an anchor.EhnParseAnyPlaceholder
A placeholder without restriction.
- property value¶
Must be an Entity (for
EhnParseRestrictionPlaceholder
) orNone
(forEhnParseAnyPlaceholder
).
Non-Entity-Like Nodes¶
Feature¶
- class EhnParseFeatureBase
The base class of E-HowNet parsing feature nodes.
See also:
ehn.parse.node.base.EhnParseFeatureBase
Subclasses:
EhnParseNormalFeature
A normal feature.EhnParseFunctionFeature
An feature with function head.
- property value¶
Can be a Entity-Like Node.
Function¶
- class EhnParseFunctionBase
The base class of E-HowNet parsing function nodes.
See also:
ehn.parse.node.base.EhnParseFunctionBase
Subclasses:
EhnParseFunction
.
- property arguments¶
A list of Entity-Like Nodes.
Subject¶
- class EhnParseSubjectBase
The base class of E-HowNet parsing unmentioned subject nodes. Works similar to entities but is not an entity. Used only in feature-based expressions.
See also:
ehn.parse.node.base.EhnParseSubjectBase
Subclasses:
EhnParseSubject
. Always an anchor ofx?
.
Partial Nodes¶
Function Head¶
- class EhnParseFunctionHead
The base class of nodes with a function as its head.
Note that the attribute obj.head of this object obj returns obj.function.head.
See also:
ehn.parse.node.base.EhnParseFunctionHead
Subclasses:
Anchor Body¶
- class EhnParseAnchorBody
The base class of anchor nodes.
See also:
ehn.parse.node.base.EhnParseAnchorBody
Subclasses:
Anchor¶
- class EhnParseAnchor
The coindex target.
See also:
ehn.parse.node.base.EhnParseAnchor
- head: str¶
The coindex of this anchor.