sentencetree

A SentenceTree is a thin wrapper around a Sentence that also provides a tree based representation of the sentence. The sentence for a SentenceTree can be retreived through the sentence property and the tree through the tree property. The data on the Tree nodes are Tokens which can be accessed through the data member.

This wrapper is very bare currently and only seeks to create the tree based representation, and does not provide additional logic. Please create a github issue if you would like to see functionality added in this area!

API

Create the SentenceTree type as a wrapper around a sentence that constructs a tree as well to traverse the sentence in a new way.

class pyconll.tree.sentencetree.SentenceTree(sentence)[source]

A Tree wrapper around a sentence. This type will take in an existing serial sentence, and create a tree representation from it. This type holds both the sentence and the tree representation of the sentence. Note that an empty sentence input will have no data and no children.

__init__(sentence)[source]

Creates a new SentenceTree given the sentence.

Parameters:sentence – The sentence to wrap and construct a tree from.
conll()[source]

Outputs the provided tree into CoNLL format.

Returns:The CoNLL formatted string.
sentence

Provides the unwrapped sentence. This property is readonly.

Returns:The unwrapped sentence.
tree

Provides the constructed tree. This property is readonly.

Returns:The constructed tree.