Parse Nodes

There are five types of nodes in E-HowNet expression — Entity, Feature, Function, Restriction, and Root.

Inheritance diagram of ehn.parse.node.entity, ehn.parse.node.feature, ehn.parse.node.other

Major Nodes

class EhnParseNode

The prototype of E-HowNet parsing nodes.

head: str

The head of this node.

get_features()

Get the features (or [] if not exists)

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)

children()

Yields all direct child nodes of this node.

descendant()

Yields all descendant nodes (including self) of this node.

decode()

Converts to text representation.

tree() → treelib.Tree

Generates a tree representation of this node and all its descendant nodes.

Entity

class EhnParseEntityBase

The base class of E-HowNet parsing entity nodes.

Subclasses:

property features

A list of Features.

Feature

class EhnParseFeatureBase

The base class of E-HowNet parsing feature nodes.

Subclasses:

property value

Can be either Entity or Restriction.

Function

class EhnParseFunctionBase

The base class of E-HowNet parsing function nodes.

Subclasses:

property arguments

A list of Entities or Restriction

Restriction

class EhnParseRestrictionBase

The base class of E-HowNet parsing function nodes.

Subclasses:

property value

Must be an Entity.

Root

class EhnParseRootBase

The base class of E-HowNet parsing root nodes. Works similar to entities but is not an entity. Used only in feature-based expressions.

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.

Subclasses:

property function

Must be a Function.

Anchor Body

class EhnParseAnchorBody

The base class of anchor nodes.

Subclasses:

property anchor

The Anchor.

Anchor

class EhnParseAnchor

The coindex target.

head: str

The coindex of this anchor.