Parse Nodes

There are five types of nodes in E-HowNet expression — Entity, Reference, Placeholder, Feature, Function, and Subject.

Inheritance diagram of ehn.parse.node.base.EhnParseEntityBase, ehn.parse.node.base.EhnParseReferenceBase, ehn.parse.node.base.EhnParsePlaceholderBase, ehn.parse.node.base.EhnParseFeatureBase, ehn.parse.node.base.EhnParseFunctionBase, ehn.parse.node.base.EhnParseSubjectBase
Inheritance diagram of ehn.parse.node.entity, ehn.parse.node.reference, ehn.parse.node.placeholder, ehn.parse.node.feature, ehn.parse.node.other

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:

property features

A list of Features.

Reference

class EhnParseReferenceBase

The base class of E-HowNet parsing reference nodes.

See also: ehn.parse.node.base.EhnParseReferenceBase

Subclasses:

Placeholder

class EhnParsePlaceholderBase

The base class of E-HowNet parsing restriction nodes.

See also: ehn.parse.node.base.EhnParsePlaceholderBase

Subclasses:

property value

Must be an Entity (for EhnParseRestrictionPlaceholder) or None (for EhnParseAnyPlaceholder).

Non-Entity-Like Nodes

Feature

class EhnParseFeatureBase

The base class of E-HowNet parsing feature nodes.

See also: ehn.parse.node.base.EhnParseFeatureBase

Subclasses:

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:

property features

A list of Features.

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:

property function

Must be a Function.

Anchor Body

class EhnParseAnchorBody

The base class of anchor nodes.

See also: ehn.parse.node.base.EhnParseAnchorBody

Subclasses:

property anchor

The Anchor.

Anchor

class EhnParseAnchor

The coindex target.

See also: ehn.parse.node.base.EhnParseAnchor

head: str

The coindex of this anchor.