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: # Parameters
  
  vocabulary : `Vocabulary`, required.
      A vocabulary containing the tag namespace.
  
  tag_namespace : `str`, required.
      This metric assumes that a BIO format is used in which the
      labels are of the format: ["B-LABEL", "I-LABEL"].
  
  ignore_classes : `List[str]`, optional.
      Span labels which will be ignored when computing span metrics.
      A "span label" is the part that comes after the BIO label, so it
      would be "ARG1" for the tag "B-ARG1". For example by passing:
  
       `ignore_classes=["V"]`
      the following sequence would not consider the "V" span at index (2, 3)
      when computing the precision, recall and F1 metrics.
  
      ["O", "O", "B-V", "I-V", "B-ARG1", "I-ARG1"]
  
      This is helpful for instance, to avoid computing metrics for "V"
      spans in a BIO tagging scheme which are typically not included.
  
  label_encoding : `str`, optional (default = `"BIO"`)
      The encoding used to specify label span endpoints in the sequence.
      Valid options are "BIO", "IOB1", "BIOUL" or "BMES".
  
  tags_to_spans_function : `Callable`, optional (default = `None`)
      If `label_encoding` is `None`, `tags_to_spans_function` will be
      used to generate spans.
docstr_tok: ["#","Parameters","vocabulary",":","`","Vocabulary","`",",","required",".","A","vocabulary","containing","the","tag","namespace",".","tag_namespace",":","`","str","`",",","required",".","This","metric","assumes","that","a","BIO","format","is","used","in","which","the","labels","are","of","the","format",":","[","``","B-LABEL","''",",","``","I-LABEL","''","]",".","ignore_classes",":","`","List","[","str","]","`",",","optional",".","Span","labels","which","will","be","ignored","when","computing","span","metrics",".","A","``","span","label","''","is","the","part","that","comes","after","the","BIO","label",",","so","it","would","be","``","ARG1","''","for","the","tag","``","B-ARG1","''",".","For","example","by","passing",":","`","ignore_classes=","[","``","V","''","]","`","the","following","sequence","would","not","consider","the","``","V","''","span","at","index","(","2",",","3",")","when","computing","the","precision",",","recall","and","F1","metrics",".","[","``","O","''",",","``","O","''",",","``","B-V","''",",","``","I-V","''",",","``","B-ARG1","''",",","``","I-ARG1","''","]","This","is","helpful","for","instance",",","to","avoid","computing","metrics","for","``","V","''","spans","in","a","BIO","tagging","scheme","which","are","typically","not","included",".","label_encoding",":","`","str","`",",","optional","(","default","=","`","``","BIO","''","`",")","The","encoding","used","to","specify","label","span","endpoints","in","the","sequence",".","Valid","options","are","``","BIO","''",",","``","IOB1","''",",","``","BIOUL","''","or","``","BMES","''",".","tags_to_spans_function",":","`","Callable","`",",","optional","(","default","=","`","None","`",")","If","`","label_encoding","`","is","`","None","`",",","`","tags_to_spans_function","`","will","be","used","to","generate","spans","."]
code: def __init__(
      self,
      vocabulary: Vocabulary,
      tag_namespace: str = "tags",
      ignore_classes: List[str] = None,
      label_encoding: Optional[str] = "BIO",
      tags_to_spans_function: Optional[
          TAGS_TO_SPANS_FUNCTION_TYPE
      ] = None,
  ) -> None:
      """
      # Parameters
  
      vocabulary : `Vocabulary`, required.
          A vocabulary containing the tag namespace.
  
      tag_namespace : `str`, required.
          This metric assumes that a BIO format is used in which the
          labels are of the format: ["B-LABEL", "I-LABEL"].
  
      ignore_classes : `List[str]`, optional.
          Span labels which will be ignored when computing span metrics.
          A "span label" is the part that comes after the BIO label, so it
          would be "ARG1" for the tag "B-ARG1". For example by passing:
  
           `ignore_classes=["V"]`
          the following sequence would not consider the "V" span at index (2, 3)
          when computing the precision, recall and F1 metrics.
  
          ["O", "O", "B-V", "I-V", "B-ARG1", "I-ARG1"]
  
          This is helpful for instance, to avoid computing metrics for "V"
          spans in a BIO tagging scheme which are typically not included.
  
      label_encoding : `str`, optional (default = `"BIO"`)
          The encoding used to specify label span endpoints in the sequence.
          Valid options are "BIO", "IOB1", "BIOUL" or "BMES".
  
      tags_to_spans_function : `Callable`, optional (default = `None`)
          If `label_encoding` is `None`, `tags_to_spans_function` will be
          used to generate spans.
      """
      if label_encoding and tags_to_spans_function:
          raise ConfigurationError(
              "Both label_encoding and tags_to_spans_function are provided. "
              'Set "label_encoding=None" explicitly to enable tags_to_spans_function.'
          )
      if label_encoding:
          if label_encoding not in ["BIO", "IOB1", "BIOUL", "BMES"]:
              raise ConfigurationError(
                  "Unknown label encoding - expected 'BIO', 'IOB1', 'BIOUL', 'BMES'."
              )
      elif tags_to_spans_function is None:
          raise ConfigurationError(
              "At least one of the (label_encoding, tags_to_spans_function) should be provided."
          )
  
      self._label_encoding = label_encoding
      self._tags_to_spans_function = tags_to_spans_function
      self._label_vocabulary = vocabulary.get_index_to_token_vocabulary(
          tag_namespace
      )
      self._ignore_classes: List[str] = ignore_classes or []
  
      # These will hold per label span counts.
      self._true_positives: Dict[str, int] = defaultdict(int)
      self._false_positives: Dict[str, int] = defaultdict(int)
      self._false_negatives: Dict[str, int] = defaultdict(int)
  
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 1 to create a new SpanBasedF1Measure object from inherited base classes: Metric with example: obj = SpanBasedF1Measure(vocabulary, tag_namespace, ignore_classes, label_encoding, tags_to_spans_function)