class_docstr: Predictor for the :class:`~allennlp.models.SpanConstituencyParser` model.
class_docstr_tok: ["Predictor","for","the",":","class",":","`","~allennlp.models.SpanConstituencyParser","`","model","."]
docstr: Recursively builds a JSON dictionary from an NLTK ``Tree`` suitable for
  rendering trees using the `Hierplane library<https://allenai.github.io/hierplane/>`.
  
  Parameters
  ----------
  tree : ``Tree``, required.
      The tree to convert into Hierplane JSON.
  index : int, required.
      The character index into the tree, used for creating spans.
  is_root : bool
      An indicator which allows us to add the outer Hierplane JSON which
      is required for rendering.
  
  Returns
  -------
  A JSON dictionary render-able by Hierplane for the given tree.
docstr_tok: ["Recursively","builds","a","JSON","dictionary","from","an","NLTK","``","Tree","``","suitable","for","rendering","trees","using","the","`","Hierplane","library","<","https",":","\/\/allenai.github.io\/hierplane\/",">","`",".","Parameters","--","--","--","--","--","tree",":","``","Tree","``",",","required",".","The","tree","to","convert","into","Hierplane","JSON",".","index",":","int",",","required",".","The","character","index","into","the","tree",",","used","for","creating","spans",".","is_root",":","bool","An","indicator","which","allows","us","to","add","the","outer","Hierplane","JSON","which","is","required","for","rendering",".","Returns","--","--","--","-","A","JSON","dictionary","render-able","by","Hierplane","for","the","given","tree","."]
code: def _build_hierplane_tree(self, tree, index, is_root):
      """
      Recursively builds a JSON dictionary from an NLTK ``Tree`` suitable for
      rendering trees using the `Hierplane library<https://allenai.github.io/hierplane/>`.
  
      Parameters
      ----------
      tree : ``Tree``, required.
          The tree to convert into Hierplane JSON.
      index : int, required.
          The character index into the tree, used for creating spans.
      is_root : bool
          An indicator which allows us to add the outer Hierplane JSON which
          is required for rendering.
  
      Returns
      -------
      A JSON dictionary render-able by Hierplane for the given tree.
      """
      children = []
      for child in tree:
          if isinstance(child, Tree):
              # If the child is a tree, it has children,
              # as NLTK leaves are just strings.
              children.append(
                  self._build_hierplane_tree(
                      child, index, is_root=False
                  )
              )
          else:
              # We're at a leaf, so add the length of
              # the word to the character index.
              index += len(child)
  
      label = tree.label()
      span = " ".join(tree.leaves())
      hierplane_node = {
          "word": span,
          "nodeType": label,
          "attributes": [label],
          "link": label,
      }
      if children:
          hierplane_node["children"] = children
      # TODO(Mark): Figure out how to span highlighting to the leaves.
      if is_root:
          hierplane_node = {
              "linkNameToLabel": LINK_TO_LABEL,
              "nodeTypeToStyle": NODE_TYPE_TO_STYLE,
              "text": span,
              "root": hierplane_node,
          }
      return hierplane_node
  
file_path: magnitude/pymagnitude/third_party/allennlp/predictors/constituency_parser.py
imports: from __future__ import absolute_import
  from nltk import Tree
  from spacy.lang.en.tag_map import TAG_MAP
  from allennlp.common.util import JsonDict, sanitize
  from allennlp.data import DatasetReader, Instance
  from allennlp.models import Model
  from allennlp.predictors.predictor import Predictor
  from allennlp.data.tokenizers.word_splitter import SpacyWordSplitter
label_desc: Use image node_id 6 for calling the ConstituencyParserPredictor obj's underlying member method code with example usage: obj._build_hierplane_tree(tree, index, is_root) and returns: hierplane_node