code: def span2str(triples, tokens):
      def _concat(token_list):
          result = ""
          for idx, t in enumerate(token_list):
              if idx == 0:
                  result = t
              elif t.startswith("##"):
                  result += t.lstrip("##")
              else:
                  result += " " + t
          return result
  
      output = []
      for triple in triples:
          rel = triple[-1]
          sub_tokens = tokens[triple[0][1] : triple[0][-1]]
          obj_tokens = tokens[triple[1][1] : triple[1][-1]]
          sub = _concat(sub_tokens)
          obj = _concat(obj_tokens)
          output.append((sub, obj, rel))
      return output
  
file_path: DeepKE/src/deepke/triple_extraction/PRGC/evaluate.py
imports: import json
  import logging
  import random
  import argparse
  from tqdm import tqdm
  import os
  import torch
  import numpy
  import pandas
  from .metrics import tag_mapping_nearest, tag_mapping_corres
  from .util import *
  from .dataloader import CustomDataLoader
label_desc: Use image node_id 2 for calling a global function with example usage: span2str(triples, tokens) and returns: output, result