class_docstr: The Conll SRL metrics are based on exact span matching. This metric
  implements span-based precision and recall metrics for a BIO tagging
  scheme. It will produce precision, recall and F1 measures per tag, as
  well as overall statistics. Note that the implementation of this metric
  is not exactly the same as the perl script used to evaluate the CONLL 2005
  data - particularly, it does not consider continuations or reference spans
  as constituents of the original span. However, it is a close proxy, which
  can be helpful for judging model performance during training. This metric
  works properly when the spans are unlabeled (i.e., your labels are
  simply "B", "I", "O" if using the "BIO" label encoding).
class_docstr_tok: ["The","Conll","SRL","metrics","are","based","on","exact","span","matching",".","This","metric","implements","span-based","precision","and","recall","metrics","for","a","BIO","tagging","scheme",".","It","will","produce","precision",",","recall","and","F1","measures","per","tag",",","as","well","as","overall","statistics",".","Note","that","the","implementation","of","this","metric","is","not","exactly","the","same","as","the","perl","script","used","to","evaluate","the","CONLL","2005","data","-","particularly",",","it","does","not","consider","continuations","or","reference","spans","as","constituents","of","the","original","span",".","However",",","it","is","a","close","proxy",",","which","can","be","helpful","for","judging","model","performance","during","training",".","This","metric","works","properly","when","the","spans","are","unlabeled","(","i.e.",",","your","labels","are","simply","``","B","''",",","``","I","''",",","``","O","''","if","using","the","``","BIO","''","label","encoding",")","."]
docstr: The official CONLL 2012 evaluation script for SRL treats continued spans (i.e spans which
  have a `C-` prepended to another valid tag) as part of the span that they are continuing.
  This is basically a massive hack to allow SRL models which produce a linear sequence of
  predictions to do something close to structured prediction. However, this means that to
  compute the metric, these continuation spans need to be merged into the span to which
  they refer. The way this is done is to simply consider the span for the continued argument
  to start at the start index of the first occurrence of the span and end at the end index
  of the last occurrence of the span. Handling this is important, because predicting continued
  spans is difficult and typically will effect overall average F1 score by ~ 2 points.
  
  # Parameters
  
  spans : `List[TypedStringSpan]`, required.
      A list of (label, (start, end)) spans.
  
  # Returns
  
  A `List[TypedStringSpan]` with continued arguments replaced with a single span.
docstr_tok: ["The","official","CONLL","2012","evaluation","script","for","SRL","treats","continued","spans","(","i.e","spans","which","have","a","`","C-","`","prepended","to","another","valid","tag",")","as","part","of","the","span","that","they","are","continuing",".","This","is","basically","a","massive","hack","to","allow","SRL","models","which","produce","a","linear","sequence","of","predictions","to","do","something","close","to","structured","prediction",".","However",",","this","means","that","to","compute","the","metric",",","these","continuation","spans","need","to","be","merged","into","the","span","to","which","they","refer",".","The","way","this","is","done","is","to","simply","consider","the","span","for","the","continued","argument","to","start","at","the","start","index","of","the","first","occurrence","of","the","span","and","end","at","the","end","index","of","the","last","occurrence","of","the","span",".","Handling","this","is","important",",","because","predicting","continued","spans","is","difficult","and","typically","will","effect","overall","average","F1","score","by","~","2","points",".","#","Parameters","spans",":","`","List","[","TypedStringSpan","]","`",",","required",".","A","list","of","(","label",",","(","start",",","end",")",")","spans",".","#","Returns","A","`","List","[","TypedStringSpan","]","`","with","continued","arguments","replaced","with","a","single","span","."]
code: def _handle_continued_spans(
      spans: List[TypedStringSpan],
  ) -> List[TypedStringSpan]:
      """
      The official CONLL 2012 evaluation script for SRL treats continued spans (i.e spans which
      have a `C-` prepended to another valid tag) as part of the span that they are continuing.
      This is basically a massive hack to allow SRL models which produce a linear sequence of
      predictions to do something close to structured prediction. However, this means that to
      compute the metric, these continuation spans need to be merged into the span to which
      they refer. The way this is done is to simply consider the span for the continued argument
      to start at the start index of the first occurrence of the span and end at the end index
      of the last occurrence of the span. Handling this is important, because predicting continued
      spans is difficult and typically will effect overall average F1 score by ~ 2 points.
  
      # Parameters
  
      spans : `List[TypedStringSpan]`, required.
          A list of (label, (start, end)) spans.
  
      # Returns
  
      A `List[TypedStringSpan]` with continued arguments replaced with a single span.
      """
      span_set: Set[TypedStringSpan] = set(spans)
      continued_labels: List[str] = [
          label[2:]
          for (label, span) in span_set
          if label.startswith("C-")
      ]
      for label in continued_labels:
          continued_spans = {
              span for span in span_set if label in span[0]
          }
  
          span_start = min(span[1][0] for span in continued_spans)
          span_end = max(span[1][1] for span in continued_spans)
          replacement_span: TypedStringSpan = (
              label,
              (span_start, span_end),
          )
  
          span_set.difference_update(continued_spans)
          span_set.add(replacement_span)
  
      return list(span_set)
  
file_path: allennlp/allennlp/training/metrics/span_based_f1_measure.py
imports: from typing import Dict, List, Optional, Set, Callable
  from collections import defaultdict
  import torch
  from allennlp.common.util import is_distributed
  from allennlp.common.checks import ConfigurationError
  from allennlp.nn.util import get_lengths_from_binary_sequence_mask
  from allennlp.data.vocabulary import Vocabulary
  from allennlp.training.metrics.metric import Metric
  from allennlp.data.dataset_readers.dataset_utils.span_utils import bio_tags_to_spans, bioul_tags_to_spans, iob1_tags_to_spans, bmes_tags_to_spans, TypedStringSpan
label_desc: Use image node_id 3 for calling the SpanBasedF1Measure obj's underlying member method code with example usage: obj._handle_continued_spans(spans) and returns: list