code: def convert2json(self, convert_dir, out_dir):
      def get_genre(genre_str):
          g = genre_str.split("|")
          result = []
          for i in g:
              result.append(self.genre_map[i])
          return result
  
      with open(out_dir, "w") as out, open(
          self.id_file, "w"
      ) as out_test:
          buf = {}
          buf["nodes"] = []
          buf["edges"] = []
          in_file = open(convert_dir + "/ml-1m/movies.dat", "r")
          for line in in_file.readlines():
              triple = line.strip().split("::")
              node_id = int(triple[0])
              node_buf = {}
              node_buf["id"] = node_id
              node_buf["type"] = "movie"
              node_buf["weight"] = 1.0
              node_buf["features"] = [{}]
              node_buf["features"][0]["name"] = "genre"
              node_buf["features"][0]["type"] = "sparse"
              node_buf["features"][0]["value"] = get_genre(triple[2])
              buf["nodes"].append(node_buf)
          in_file.close()
  
          in_file = open(convert_dir + "/ml-1m/users.dat", "r")
          for line in in_file.readlines():
              triple = line.strip().split("::")
              node_id = int(triple[0]) + self.movie_len
              node_buf = {}
              node_buf["id"] = node_id
              node_buf["type"] = "user"
              node_buf["weight"] = 1.0
              node_buf["features"] = [{}, {}, {}, {}]
              node_buf["features"][0]["name"] = "gender"
              node_buf["features"][0]["type"] = "sparse"
              node_buf["features"][0]["value"] = [
                  self.gender_map[triple[1]],
              ]
              node_buf["features"][1]["name"] = "age"
              node_buf["features"][1]["type"] = "sparse"
              node_buf["features"][1]["value"] = [
                  self.age_map[triple[2]],
              ]
              node_buf["features"][2]["name"] = "occupation"
              node_buf["features"][2]["type"] = "sparse"
              node_buf["features"][2]["value"] = [
                  int(triple[3]),
              ]
              node_buf["features"][3]["name"] = "zip_code"
              node_buf["features"][3]["type"] = "binary"
              node_buf["features"][3]["value"] = [
                  str(triple[4]),
              ]
              buf["nodes"].append(node_buf)
          in_file.close()
  
          in_file = open(convert_dir + "/ml-1m/ratings.dat", "r")
          for line in in_file.readlines():
              triple = line.strip().split("::")
              edge_buf = {}
              edge_buf["src"] = int(triple[0]) + self.movie_len
              edge_buf["dst"] = int(triple[1])
              edge_buf["type"] = "rate"
              edge_buf["weight"] = 1
              edge_buf["features"] = [{}, {}]
              edge_buf["features"][0]["name"] = "rating"
              edge_buf["features"][0]["type"] = "sparse"
              edge_buf["features"][0]["value"] = [
                  int(triple[2]),
              ]
              edge_buf["features"][1]["name"] = "timestamp"
              edge_buf["features"][1]["type"] = "binary"
              edge_buf["features"][1]["value"] = [
                  str(triple[3]),
              ]
              buf["edges"].append(edge_buf)
          in_file.close()
  
          out.write(json.dumps(buf))
          for i in range(self.max_node_id):
              out_test.write(str(i + 1) + "\n")
          print(
              "Total Node: {}, Edge: {}.".format(
                  len(buf["nodes"]), len(buf["edges"])
              )
          )
  
file_path: euler/tf_euler/python/dataset/ml_1m.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import json
  import tqdm
  import urllib
  import zipfile
  import numpy
  from tf_euler.python.dataset.base_dataset import DataSet
label_desc: Use image node_id 3 for calling the MovieLens_1M obj's underlying member method code with example usage: obj.convert2json(convert_dir, out_dir) and returns: result