Closed suyog-pipliwaal closed 1 year ago
There you go...
from constituent_treelib import ConstituentTree, BracketedTree, Language, Structure
language = Language.English
# Define which specific SpaCy model should be used (default is Medium)
spacy_model_size = ConstituentTree.SpacyModelSize.Medium
# Create the pipeline (note, the required models will be downloaded and installed automatically)
nlp = ConstituentTree.create_pipeline(language, spacy_model_size)
sentence = "Tokyo Disneyland opened on April 15, 1983 and is mostly based on its sister castle parks in Anaheim, California, and Bay Lake, Florida."
tree = ConstituentTree(sentence, nlp)
To determine the height of the tree, we simply access the underlying nltk tree and the corresponding height function:
tree.nltk_tree.height()
>>> 12
That's it.
I am a student studying NLP at the university. I am studying the different ways to parse and build a tree for a language like English. I am just wondering if is there any way to determine the depth of a tree for a given sentence in English.