code: def convert2json(self, convert_dir, out_dir):
      def add_node(id, type, weight):
          node_buf = {}
          node_buf["id"] = id
          node_buf["type"] = type
          node_buf["weight"] = weight
          node_buf["features"] = []
          return node_buf
  
      def add_edge(src, dst, id, type, weight):
          edge_buf = {}
          edge_buf["src"] = src
          edge_buf["dst"] = dst
          edge_buf["type"] = type
          edge_buf["weight"] = weight
          edge_buf["features"] = []
          lab_buf = {}
          lab_buf["name"] = "id"
          lab_buf["type"] = "dense"
          lab_buf["value"] = [id]
          edge_buf["features"].append(lab_buf)
          return edge_buf
  
      out_test = open(self.edge_id_file, "w")
      node_out_test = open(self.node_id_file, "w")
      with open(out_dir, "w") as out:
          buf = {}
          buf["nodes"] = []
          buf["edges"] = []
          entity_map = {}
          relation_map = {}
          entity_id = 0
          relation_id = 0
          for file_type in ["train", "test", "valid"]:
              in_file = open(
                  convert_dir
                  + "/freebase_mtr100_mte100-"
                  + file_type
                  + ".txt",
                  "r",
              )
              for line in in_file.readlines():
                  triple = line.strip().split()
                  if not triple[0] in entity_map:
                      entity_map[triple[0]] = entity_id
                      entity_id += 1
                      buf["nodes"].append(
                          add_node(entity_map[triple[0]], file_type, 1)
                      )
                  if not triple[2] in entity_map:
                      entity_map[triple[2]] = entity_id
                      entity_id += 1
                      buf["nodes"].append(
                          add_node(entity_map[triple[2]], file_type, 1)
                      )
                  if not triple[1] in relation_map:
                      relation_map[triple[1]] = relation_id
                      relation_id += 1
                  buf["edges"].append(
                      add_edge(
                          entity_map[triple[0]],
                          entity_map[triple[2]],
                          relation_map[triple[1]],
                          file_type,
                          1,
                      )
                  )
                  if file_type == "test":
                      edge_line = (
                          str(entity_map[triple[0]])
                          + " "
                          + str(entity_map[triple[2]])
                          + " "
                          + "1"
                          + "\n"
                      )
                      id_line = str(entity_map[triple[0]]) + "\n"
                      out_test.write(edge_line)
                      node_out_test.write(id_line)
              in_file.close()
          out.write(json.dumps(buf))
          print(
              "Total Entity: {}, Relation: {}, Node: {}, Edge: {}.".format(
                  len(buf["nodes"]),
                  relation_id,
                  entity_id,
                  len(buf["edges"]),
              )
          )
      out_test.close()
      node_out_test.close()
  
file_path: euler/tf_euler/python/dataset/fb15k.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import json
  import urllib
  import tarfile
  import tqdm
  from tf_euler.python.dataset.sage_util import *
  from tf_euler.python.dataset.base_dataset import DataSet
label_desc: Use image node_id 3 for calling the FB15K obj's underlying member method code with example usage: obj.convert2json(convert_dir, out_dir) and returns: node_buf, edge_buf