class_docstr: This metric is a generalisation of the `SpanFMeasure`,            particularly suitable for measuring entity prediction scores
  in SLU tasks. A distance function is used to smooth the negative            contribution of wrong transcription. In particular,
  for every label match, the lexical distance between gold and predicted            fillers contributes to FPs and FNs count.
  For more information, please see `SLURP: A Spoken Language Understanding            Resource Package` by Bastianelli, Vanzo,
  Swietojanski, and Rieser.
  
  :param average: This determines the type of averaging performed            on the data: 'micro' (calculate metrics globally
  by counting the total true positives, false negatives and false positives),            'macro' (calculate metrics for each
  label, and find their unweighted mean).
  :param distance: The distance function being applied.            `word` applies WER, whereas `char` applies the Levenshtein
  distance.
class_docstr_tok: ["This","metric","is","a","generalisation","of","the","`","SpanFMeasure","`",",","particularly","suitable","for","measuring","entity","prediction","scores","in","SLU","tasks",".","A","distance","function","is","used","to","smooth","the","negative","contribution","of","wrong","transcription",".","In","particular",",","for","every","label","match",",","the","lexical","distance","between","gold","and","predicted","fillers","contributes","to","FPs","and","FNs","count",".","For","more","information",",","please","see","`","SLURP",":","A","Spoken","Language","Understanding","Resource","Package","`","by","Bastianelli",",","Vanzo",",","Swietojanski",",","and","Rieser",".",":","param","average",":","This","determines","the","type","of","averaging","performed","on","the","data",":","'micro","'","(","calculate","metrics","globally","by","counting","the","total","true","positives",",","false","negatives","and","false","positives",")",",","'macro","'","(","calculate","metrics","for","each","label",",","and","find","their","unweighted","mean",")",".",":","param","distance",":","The","distance","function","being","applied",".","`","word","`","applies","WER",",","whereas","`","char","`","applies","the","Levenshtein","distance","."]
docstr: This method returns a tuple: the first element is the index of the                gold entity having the lowest distance with
  the predicted one, the second element is the corresponding distance.
  
  :param target_label: The label of the target predicted entity.
  :param target_span: The span of the target predicted entity.
  :param gold_labels: A list of label of the gold entities.                It is aligned with `gold_spans`.
  :param gold_spans: A list of span of the gold entities.                It is aligned with `gold_labels`.
  :return: A tuple with index and distance of the best gold candidate.
docstr_tok: ["This","method","returns","a","tuple",":","the","first","element","is","the","index","of","the","gold","entity","having","the","lowest","distance","with","the","predicted","one",",","the","second","element","is","the","corresponding","distance",".",":","param","target_label",":","The","label","of","the","target","predicted","entity",".",":","param","target_span",":","The","span","of","the","target","predicted","entity",".",":","param","gold_labels",":","A","list","of","label","of","the","gold","entities",".","It","is","aligned","with","`","gold_spans","`",".",":","param","gold_spans",":","A","list","of","span","of","the","gold","entities",".","It","is","aligned","with","`","gold_labels","`",".",":","return",":","A","tuple","with","index","and","distance","of","the","best","gold","candidate","."]
code: def _get_lowest_distance(
      self,
      target_label: str,
      target_span: str,
      gold_labels: List[str],
      gold_spans: List[str],
  ) -> Tuple[int, float]:
      """
          This method returns a tuple: the first element is the index of the\
                  gold entity having the lowest distance with
          the predicted one, the second element is the corresponding distance.
  
          :param target_label: The label of the target predicted entity.
          :param target_span: The span of the target predicted entity.
          :param gold_labels: A list of label of the gold entities.\
                  It is aligned with `gold_spans`.
          :param gold_spans: A list of span of the gold entities.\
                  It is aligned with `gold_labels`.
          :return: A tuple with index and distance of the best gold candidate.
          """
      index = 0
      lowest_distance = float("inf")
      for j, gold_label in enumerate(gold_labels):
          if target_label == gold_label:
              distance = self._distance(gold_spans[j], target_span)
              if distance < lowest_distance:
                  index = j
                  lowest_distance = distance
      return index, lowest_distance
  
imports: from collections import defaultdict
  from copy import copy
  from typing import Dict, List, Set, Tuple
  from .distance import Distance
label_desc: Use image node_id 3 for calling the SpanDistanceFMeasure obj's underlying member method code with example usage: obj._get_lowest_distance(target_label, target_span, gold_labels, gold_spans) and returns: index,  lowest_distance