class_docstr: Load knowledge graph data from files
  
  Args:
      path (str):
          Directory of triplet dataset.
      data_name (str):
          The folder name of triplet dataset.
      hrt_mode (str, optional):
          The order of head, relation and tail per line in triplet file.
          Choices: 'hrt', 'htr', 'trh', 'thr', 'rht', 'rth'.
      kv_mode (str, optional):
          The order of string names and ids in dictionary files.
          'kv' denotes entity_name/relation_name, id.
      train_file (str, optional):
          Filename of training data.
      valid_file (str, optional):
          Filename of validation data.
      test_file (str, optional):
          Filename of test data.
      ent_file (str, optional):
          Filename of entity_to_id dictionary.
      rel_file (str, optional):
          Filename of relation_to_id dictionary.
      delimiter (char, optional):
          The delimiter in files.
      map_to_id (bool, optional):
          Whether to map loaded elements into int ids.
      load_dict (bool, optional):
          Whether to load dictionaries from files.
      skip_head (bool, optional):
          Whether to ignore the first line of dictionary files.
class_docstr_tok: ["Load","knowledge","graph","data","from","files","Args",":","path","(","str",")",":","Directory","of","triplet","dataset",".","data_name","(","str",")",":","The","folder","name","of","triplet","dataset",".","hrt_mode","(","str",",","optional",")",":","The","order","of","head",",","relation","and","tail","per","line","in","triplet","file",".","Choices",":","'hrt","'",",","'htr","'",",","'trh","'",",","'thr","'",",","'rht","'",",","'rth","'",".","kv_mode","(","str",",","optional",")",":","The","order","of","string","names","and","ids","in","dictionary","files",".","'kv","'","denotes","entity_name\/relation_name",",","id",".","train_file","(","str",",","optional",")",":","Filename","of","training","data",".","valid_file","(","str",",","optional",")",":","Filename","of","validation","data",".","test_file","(","str",",","optional",")",":","Filename","of","test","data",".","ent_file","(","str",",","optional",")",":","Filename","of","entity_to_id","dictionary",".","rel_file","(","str",",","optional",")",":","Filename","of","relation_to_id","dictionary",".","delimiter","(","char",",","optional",")",":","The","delimiter","in","files",".","map_to_id","(","bool",",","optional",")",":","Whether","to","map","loaded","elements","into","int","ids",".","load_dict","(","bool",",","optional",")",":","Whether","to","load","dictionaries","from","files",".","skip_head","(","bool",",","optional",")",":","Whether","to","ignore","the","first","line","of","dictionary","files","."]
docstr: Load triplets from file, a triplet per line.
          
docstr_tok: ["Load","triplets","from","file",",","a","triplet","per","line","."]
code: def load_triplet(path, hrt_idx, delimiter="\t", skip_head=False):
      """Load triplets from file, a triplet per line."""
      if not os.path.exists(path):
          raise ValueError("there is no triplet file in %s" % path)
      map_fn = lambda x: [x[hrt_idx[i]] for i in range(3)]
      with open(path, "r") as rp:
          rp.readline() if skip_head else None
          data = [
              map_fn(l.strip().split(delimiter)) for l in rp.readlines()
          ]
      return data
  
imports: import os
  import time
  import numpy
  import paddle.distributed
  from dataset.trigraph import TriGraph
  from utils import timer_wrapper
label_desc: Use image node_id 4 for calling the TripletDataset obj's underlying member method code with example usage: obj.load_triplet(path, hrt_idx, delimiter, skip_head) and returns: data