concepts.language.neural_ccg.grammar.NeuralCCGNode#
- class NeuralCCGNode[source]#
Bases:
CCGNode
A node in the Neural CCG parsing tree.
Methods
Convert the node to a string in nltk format.
compose
(rhs[, composition_type])Compose the current node with another node.
compose_check
(rhs, composition_type)Check if the current node can be composed with another node.
compose_guess
(rhs)Guess the composition type of the current node with another node.
Format the node as a nltk tree.
Linearize the lexicons of the node.
Print the node as a nltk tree.
set_used_lexicon_entries
(used_lexicon_entries)Set the used lexicon entries.
Attributes
The execution result of the node.
Whether the node is a None node.
A set of lexicon entries used in the derivation.
The composition system.
The syntax type of the node.
The semantics of the node.
The composition type of the node.
The lexicon (if the composition type is LEXICON).
The left child of the node (for other types of composition).
The right child of the node (for other types of composition).
The weight of the node.
A string representation of the composition inside the tree.
- __init__(composition_system, syntax, semantics, composition_type, lexicon=None, lhs=None, rhs=None, weight=None, composition_str=None)[source]#
Initialize a CCG node.
- Parameters:
composition_system (CCGCompositionSystem) – the composition system.
syntax (NeuralCCGSyntaxType) – the syntax of the node.
semantics (NeuralCCGSemantics) – the semantics of the node.
composition_type (CCGCompositionType) – the composition type of the node.
lexicon (Lexicon | None) – the lexicon of the node (only if the composition type is LEXICON).
lhs (NeuralCCGNode | None) – the left child of the node (when available).
rhs (NeuralCCGNode | None) – the right child of the node (when available).
composition_str (str) – a string representation of the composition, which can be used to remove duplicated trees.
- __new__(**kwargs)#
- compose(rhs, composition_type=None)#
Compose the current node with another node. This function will automatically guess the composition type.
- Parameters:
rhs (CCGNode) – the right node.
composition_type (CCGCompositionType | None) – the composition type. If not given, it will be guessed automatically.
- Returns:
The composition result. When the composition type is not given, it will be a
CCGCompositionResult
object.- Return type:
- compose_check(rhs, composition_type)[source]#
Check if the current node can be composed with another node. If the check fails, a CCGCompositionError will be raised.
- Parameters:
rhs (NeuralCCGNode) – the right node.
composition_type (CCGCompositionType) – the composition type.
- Raises:
CCGCompositionError – if the check fails.
- compose_guess(rhs)[source]#
Guess the composition type of the current node with another node.
- Parameters:
rhs (NeuralCCGNode) – the right node.
- Returns:
The guessed composition type. If None, all composition types are allowed.
- Return type:
- linearize_lexicons()#
Linearize the lexicons of the node. It return a list of lexicons corresponding to the leaves of parsing tree.
- print_nltk_tree()#
Print the node as a nltk tree.
- composition_system: CCGCompositionSystem#
The composition system.
- composition_type: CCGCompositionType#
The composition type of the node.
- property execution_result#
The execution result of the node.
- property is_none#
Whether the node is a None node.
- lhs: NeuralCCGNode | None#
The left child of the node (for other types of composition).
- rhs: NeuralCCGNode | None#
The right child of the node (for other types of composition).
- semantics: NeuralCCGSemantics | None#
The semantics of the node.
- syntax: NeuralCCGSyntaxType | None#
The syntax type of the node.