class_docstr:     Information Extraction based graph construction class
  
  Parameters
  ----------
  embedding_style: dict
      Specify embedding styles including ``single_token_item``,
      ``emb_strategy``, ``num_rnn_layers``, ``bert_model_name``
      and ``bert_lower_case``.
  vocab: VocabModel
      Vocabulary including all words appeared in graphs.
class_docstr_tok: ["Information","Extraction","based","graph","construction","class","Parameters","--","--","--","--","--","embedding_style",":","dict","Specify","embedding","styles","including","``","single_token_item","``",",","``","emb_strategy","``",",","``","num_rnn_layers","``",",","``","bert_model_name","``","and","``","bert_lower_case","``",".","vocab",":","VocabModel","Vocabulary","including","all","words","appeared","in","graphs","."]
docstr: Parameters
  ----------
  all_sent_triples_list: list
  edge_strategy: str
  
  Returns
  -------
  parsed_results: dict
      parsed_results is an intermediate dict that contains all the information of
      the constructed IE graph for a piece of raw text input.
  
      `parsed_results['graph_content']` is a list of dict.
  
      Each dict in `parsed_results['graph_content']` contains information about a
      triple (src_ent, rel, tgt_ent).
  
      `parsed_results['graph_nodes']` contains all nodes in the KG graph.
  
      `parsed_results['node_num']` is the number of nodes in the KG graph.
docstr_tok: ["Parameters","--","--","--","--","--","all_sent_triples_list",":","list","edge_strategy",":","str","Returns","--","--","--","-","parsed_results",":","dict","parsed_results","is","an","intermediate","dict","that","contains","all","the","information","of","the","constructed","IE","graph","for","a","piece","of","raw","text","input",".","`","parsed_results","[","'graph_content","'","]","`","is","a","list","of","dict",".","Each","dict","in","`","parsed_results","[","'graph_content","'","]","`","contains","information","about","a","triple","(","src_ent",",","rel",",","tgt_ent",")",".","`","parsed_results","[","'graph_nodes","'","]","`","contains","all","nodes","in","the","KG","graph",".","`","parsed_results","[","'node_num","'","]","`","is","the","number","of","nodes","in","the","KG","graph","."]
code: def parsing(cls, all_sent_triples_list, edge_strategy):
      """
      Parameters
      ----------
      all_sent_triples_list: list
      edge_strategy: str
  
      Returns
      -------
      parsed_results: dict
          parsed_results is an intermediate dict that contains all the information of
          the constructed IE graph for a piece of raw text input.
  
          `parsed_results['graph_content']` is a list of dict.
  
          Each dict in `parsed_results['graph_content']` contains information about a
          triple (src_ent, rel, tgt_ent).
  
          `parsed_results['graph_nodes']` contains all nodes in the KG graph.
  
          `parsed_results['node_num']` is the number of nodes in the KG graph.
      """
  
      parsed_results = {}
      parsed_results["graph_content"] = []
      graph_nodes = []
      for triple in all_sent_triples_list:
          if edge_strategy is None:
              if triple[0] not in graph_nodes:
                  graph_nodes.append(triple[0])
  
              if triple[2] not in graph_nodes:
                  graph_nodes.append(triple[2])
  
              triple_info = {
                  "edge_tokens": triple[1],
                  "src": {
                      "tokens": triple[0],
                      "id": graph_nodes.index(triple[0]),
                  },
                  "tgt": {
                      "tokens": triple[2],
                      "id": graph_nodes.index(triple[2]),
                  },
              }
              if triple_info not in parsed_results["graph_content"]:
                  parsed_results["graph_content"].append(triple_info)
          elif edge_strategy == "as_node":
              if triple[0] not in graph_nodes:
                  graph_nodes.append(triple[0])
  
              if triple[1] not in graph_nodes:
                  graph_nodes.append(triple[1])
  
              if triple[2] not in graph_nodes:
                  graph_nodes.append(triple[2])
  
              triple_info_0_1 = {
                  "edge_tokens": [],
                  "src": {
                      "tokens": triple[0],
                      "id": graph_nodes.index(triple[0]),
                      "type": 0,  # 'ent_node'
                  },
                  "tgt": {
                      "tokens": triple[1],
                      "id": graph_nodes.index(triple[1]),
                      "type": 3,  # 'edge_node'
                  },
              }
  
              triple_info_1_2 = {
                  "edge_tokens": [],
                  "src": {
                      "tokens": triple[1],
                      "id": graph_nodes.index(triple[1]),
                      "type": 3,  # 'edge_node'
                  },
                  "tgt": {
                      "tokens": triple[2],
                      "id": graph_nodes.index(triple[2]),
                      "type": 0,  # 'ent_node'
                  },
              }
  
              if triple_info_0_1 not in parsed_results["graph_content"]:
                  parsed_results["graph_content"].append(
                      triple_info_0_1
                  )
              if triple_info_1_2 not in parsed_results["graph_content"]:
                  parsed_results["graph_content"].append(
                      triple_info_1_2
                  )
          else:
              raise NotImplementedError(
                  "Not Implemented Edge Strategy: {}.".format(
                      edge_strategy
                  )
              )
  
      parsed_results["node_num"] = len(graph_nodes)
      parsed_results["graph_nodes"] = graph_nodes
  
      return parsed_results
  
file_path: graph4nlp/graph4nlp/pytorch/modules/graph_construction/ie_graph_construction.py
imports: import json
  from ...data.data import GraphData
  from .base import StaticGraphConstructionBase
label_desc: Use image node_id 3 for calling the IEBasedGraphConstruction obj's underlying member method code with example usage: obj.parsing(cls, all_sent_triples_list, edge_strategy) and returns: parsed_results