class_docstr:     Dependency-parsing-tree based graph construction class
  
  Parameters
  ----------
  vocab: VocabModel
      Vocabulary including all words appeared in graphs.
class_docstr_tok: ["Dependency-parsing-tree","based","graph","construction","class","Parameters","--","--","--","--","--","vocab",":","VocabModel","Vocabulary","including","all","words","appeared","in","graphs","."]
docstr: Parameters
  ----------
  raw_text_data: str
  nlp_processor: StanfordCoreNLP
  processor_args: dict
  
  Returns
  -------
  parsed_results: list[dict]
      Each sentence is a dict. All sentences are packed by a list.
      key, value
      "node_num": int
          the node amount
      "node_content": list[dict]
          The list consisting node information. Each node is organized by a dict.
          'token': str
              word token
          'position_id': int
              the word's position id in original sentence. eg: I am a dog. position_id: 0, 1, 2, 3 # noqa
          'id': int,
              the node token's id which will be used in GraphData
          "sentence_id": int
              The sentence's id in the whole text.
      "graph_content": list[dict]
          The list consisting edge information. Each edge is organized by a dict.
          "edge_type": str
              The edge type token, eg: 'nsubj'
          'src': int
              The source node ``id``
          'tgt': int
              The target node ``id``
docstr_tok: ["Parameters","--","--","--","--","--","raw_text_data",":","str","nlp_processor",":","StanfordCoreNLP","processor_args",":","dict","Returns","--","--","--","-","parsed_results",":","list","[","dict","]","Each","sentence","is","a","dict",".","All","sentences","are","packed","by","a","list",".","key",",","value","``","node_num","''",":","int","the","node","amount","``","node_content","''",":","list","[","dict","]","The","list","consisting","node","information",".","Each","node","is","organized","by","a","dict",".","'token","'",":","str","word","token","'position_id","'",":","int","the","word","'s","position","id","in","original","sentence",".","eg",":","I","am","a","dog",".","position_id",":","0",",","1",",","2",",","3","#","noqa","'id","'",":","int",",","the","node","token","'s","id","which","will","be","used","in","GraphData","``","sentence_id","''",":","int","The","sentence","'s","id","in","the","whole","text",".","``","graph_content","''",":","list","[","dict","]","The","list","consisting","edge","information",".","Each","edge","is","organized","by","a","dict",".","``","edge_type","''",":","str","The","edge","type","token",",","eg",":","'nsubj'","'src","'",":","int","The","source","node","``","id","``","'tgt","'",":","int","The","target","node","``","id","``"]
code: def parsing(cls, raw_text_data, nlp_processor, processor_args):
      """
  
      Parameters
      ----------
      raw_text_data: str
      nlp_processor: StanfordCoreNLP
      processor_args: dict
  
      Returns
      -------
      parsed_results: list[dict]
          Each sentence is a dict. All sentences are packed by a list.
          key, value
          "node_num": int
              the node amount
          "node_content": list[dict]
              The list consisting node information. Each node is organized by a dict.
              'token': str
                  word token
              'position_id': int
                  the word's position id in original sentence. eg: I am a dog. position_id: 0, 1, 2, 3 # noqa
              'id': int,
                  the node token's id which will be used in GraphData
              "sentence_id": int
                  The sentence's id in the whole text.
          "graph_content": list[dict]
              The list consisting edge information. Each edge is organized by a dict.
              "edge_type": str
                  The edge type token, eg: 'nsubj'
              'src': int
                  The source node ``id``
              'tgt': int
                  The target node ``id``
      """
      dep_json = nlp_processor.annotate(
          raw_text_data.strip(), properties=processor_args
      )
      from .utils import CORENLP_TIMEOUT_SIGNATURE
  
      if CORENLP_TIMEOUT_SIGNATURE in dep_json:
          raise TimeoutError(
              "CoreNLP timed out at input: \n{}\n This item will be skipped. "
              "Please check the input or change the timeout threshold.".format(
                  raw_text_data
              )
          )
  
      dep_dict = json.loads(dep_json)
  
      parsed_results = []
      node_id = 0
      for s_id in range(len(dep_dict["sentences"])):
          parsed_sent = []
          node_item = []
          unique_hash = {}
          node_id = 0
  
          for tokens in dep_dict["sentences"][s_id]["tokens"]:
              unique_hash[(tokens["index"], tokens["word"])] = node_id
              node = {
                  "token": tokens["word"],
                  "position_id": tokens["index"] - 1,
                  "id": node_id,
                  "sentence_id": s_id,
              }
              node_item.append(node)
              node_id += 1
  
          for dep in dep_dict["sentences"][s_id]["basicDependencies"]:
              if cls.verbose > 0:
                  print(dep)
  
              if dep["governorGloss"] == "ROOT":
                  continue
  
              if dep["dependentGloss"] == "ROOT":
                  continue
  
              dep_info = {
                  "edge_type": dep["dep"],
                  "src": unique_hash[
                      (dep["governor"], dep["governorGloss"])
                  ],
                  "tgt": unique_hash[
                      (dep["dependent"], dep["dependentGloss"])
                  ],
              }
              if cls.verbose > 0:
                  print(dep_info)
              parsed_sent.append(dep_info)
          if cls.verbose > 0:
              print(node_id)
              print(len(parsed_sent))
          parsed_results.append(
              {
                  "graph_content": parsed_sent,
                  "node_content": node_item,
                  "node_num": node_id,
              }
          )
      return parsed_results
  
file_path: graph4nlp/graph4nlp/pytorch/modules/graph_construction/dependency_graph_construction.py
imports: import copy
  import json
  from ...data.data import GraphData
  from .base import StaticGraphConstructionBase
label_desc: Use image node_id 3 for calling the DependencyBasedGraphConstruction obj's underlying member method code with example usage: obj.parsing(cls, raw_text_data, nlp_processor, processor_args) and returns: parsed_results