class_docstr:     Line based graph construction class
  Parameters
  ----------
  embedding_style: dict
      Specify embedding styles including ``word_emb_type``, ``node_edge_level_emb_type``
      and ``graph_level_emb_type``.
  vocab: VocabModel
      Vocabulary including all words appeared in graphs.
class_docstr_tok: ["Line","based","graph","construction","class","Parameters","--","--","--","--","--","embedding_style",":","dict","Specify","embedding","styles","including","``","word_emb_type","``",",","``","node_edge_level_emb_type","``","and","``","graph_level_emb_type","``",".","vocab",":","VocabModel","Vocabulary","including","all","words","appeared","in","graphs","."]
docstr:     Build dependency-parsing-tree based graph for single sentence.
  Parameters
  ----------
  parsed_object: dict
      The parsing tree.
  edge_strategy: None or str, option=[None, "homogeneous", "heterogeneous", "as_node"]
      Strategy to process edge.
      ``None``: It will be the default option. We will do as ``"homogeneous"``.
      ``"homogeneous"``: We will drop the edge type information.
                         If there is a linkage among node ``i`` and node ``j``,
                         we will add an edge whose weight is ``1.0``. Otherwise there is
                         no edge.
      ``heterogeneous``: We will keep the edge type information.
                         An edge will have type information like ``n_subj``.
                         It is not implemented yet.
      ``as_node``: We will view the edge as a graph node.
                   If there is an edge whose type is ``k`` between node ``i`` and node ``j``,
                   we will insert a node ``k`` into the graph and link node (``i``, ``k``)
                   and (``k``, ``j``). It is not implemented yet.
  Returns
  -------
  graph: GraphData
      graph structure for single sentence
docstr_tok: ["Build","dependency-parsing-tree","based","graph","for","single","sentence",".","Parameters","--","--","--","--","--","parsed_object",":","dict","The","parsing","tree",".","edge_strategy",":","None","or","str",",","option=","[","None",",","``","homogeneous","''",",","``","heterogeneous","''",",","``","as_node","''","]","Strategy","to","process","edge",".","``","None","``",":","It","will","be","the","default","option",".","We","will","do","as","``","``","homogeneous","''","``",".","``","``","homogeneous","''","``",":","We","will","drop","the","edge","type","information",".","If","there","is","a","linkage","among","node","``","i","``","and","node","``","j","``",",","we","will","add","an","edge","whose","weight","is","``","1.0","``",".","Otherwise","there","is","no","edge",".","``","heterogeneous","``",":","We","will","keep","the","edge","type","information",".","An","edge","will","have","type","information","like","``","n_subj","``",".","It","is","not","implemented","yet",".","``","as_node","``",":","We","will","view","the","edge","as","a","graph","node",".","If","there","is","an","edge","whose","type","is","``","k","``","between","node","``","i","``","and","node","``","j","``",",","we","will","insert","a","node","``","k","``","into","the","graph","and","link","node","(","``","i","``",",","``","k","``",")","and","(","``","k","``",",","``","j","``",")",".","It","is","not","implemented","yet",".","Returns","--","--","--","-","graph",":","GraphData","graph","structure","for","single","sentence"]
code: def _construct_static_graph(
      cls, parsed_object, edge_strategy=None, sequential_link=True
  ):
      """
          Build dependency-parsing-tree based graph for single sentence.
      Parameters
      ----------
      parsed_object: dict
          The parsing tree.
      edge_strategy: None or str, option=[None, "homogeneous", "heterogeneous", "as_node"]
          Strategy to process edge.
          ``None``: It will be the default option. We will do as ``"homogeneous"``.
          ``"homogeneous"``: We will drop the edge type information.
                             If there is a linkage among node ``i`` and node ``j``,
                             we will add an edge whose weight is ``1.0``. Otherwise there is
                             no edge.
          ``heterogeneous``: We will keep the edge type information.
                             An edge will have type information like ``n_subj``.
                             It is not implemented yet.
          ``as_node``: We will view the edge as a graph node.
                       If there is an edge whose type is ``k`` between node ``i`` and node ``j``,
                       we will insert a node ``k`` into the graph and link node (``i``, ``k``)
                       and (``k``, ``j``). It is not implemented yet.
      Returns
      -------
      graph: GraphData
          graph structure for single sentence
      """
      ret_graph = GraphData()
      node_num = parsed_object["node_num"]
      assert node_num > 0
      ret_graph.add_nodes(node_num)
      head_node = 0
      tail_node = node_num - 1
  
      # insert node attributes
      node_objects = parsed_object["node_content"]
      for node in node_objects:
          ret_graph.node_attributes[node["id"]]["type"] = 0
          ret_graph.node_attributes[node["id"]]["token"] = node["token"]
          ret_graph.node_attributes[node["id"]]["position_id"] = node[
              "position_id"
          ]
          ret_graph.node_attributes[node["id"]]["sentence_id"] = node[
              "sentence_id"
          ]
          ret_graph.node_attributes[node["id"]]["head"] = False
          ret_graph.node_attributes[node["id"]]["tail"] = False
  
      for dep_info in parsed_object["graph_content"]:
          if edge_strategy is None or edge_strategy == "homogeneous":
              ret_graph.add_edge(dep_info["src"], dep_info["tgt"])
          elif edge_strategy == "heterogeneous":
              ret_graph.add_edge(dep_info["src"], dep_info["tgt"])
              edge_idx = ret_graph.edge_ids(
                  dep_info["src"], dep_info["tgt"]
              )[0]
              ret_graph.edge_attributes[edge_idx]["token"] = dep_info[
                  "edge_type"
              ]
          elif edge_strategy == "as_node":
              # insert a node
              node_idx = ret_graph.get_node_num()
              ret_graph.add_nodes(1)
              ret_graph.node_attributes[node_idx][
                  "type"
              ] = 3  # 3 for edge node
              ret_graph.node_attributes[node_idx]["token"] = dep_info[
                  "edge_type"
              ]
              ret_graph.node_attributes[node_idx]["position_id"] = None
              ret_graph.node_attributes[node_idx]["head"] = False
              ret_graph.node_attributes[node_idx]["tail"] = False
              # add edge infos
              ret_graph.add_edge(dep_info["src"], node_idx)
              ret_graph.add_edge(node_idx, dep_info["tgt"])
          else:
              raise NotImplementedError()
      ret_graph.node_attributes[head_node]["head"] = True
      ret_graph.node_attributes[tail_node]["tail"] = True
  
      sequential_list = list(range(node_num))
  
      if sequential_list and len(sequential_list) > 1:
          for st, ed in zip(sequential_list[:-1], sequential_list[1:]):
              try:
                  ret_graph.edge_ids(st, ed)
              except Exception:
                  ret_graph.add_edge(st, ed)
              try:
                  ret_graph.edge_ids(ed, st)
              except Exception:
                  ret_graph.add_edge(ed, st)
      return ret_graph
  
file_path: graph4nlp/examples/pytorch/name_entity_recognition/dependency_graph_construction_without_tokenize.py
imports: import copy
  import itertools
  import json
  from collections import Counter
  from graph4nlp.pytorch.data.data import GraphData
  from graph4nlp.pytorch.modules.graph_construction.base import StaticGraphConstructionBase
label_desc: Use image node_id 5 for calling the DependencyBasedGraphConstruction_without_tokenizer obj's underlying member method code with example usage: obj._construct_static_graph(cls, parsed_object, edge_strategy, sequential_link) and returns: ret_graph