public class IOBUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static boolean |
countEntityResults(java.util.List<? extends CoreMap> doc,
Counter<java.lang.String> entityTP,
Counter<java.lang.String> entityFP,
Counter<java.lang.String> entityFN,
java.lang.String background)
For a sequence labeling task with multi-token entities, like NER,
this works out TP, FN, FP counts that can be used for entity-level
F1 results.
|
static <TOK extends CoreMap> |
entitySubclassify(java.util.List<TOK> tokens,
java.lang.Class<? extends TypesafeMap.Key<java.lang.String>> key,
java.lang.String backgroundLabel,
java.lang.String style,
boolean intern)
This can be used to map from any IOB-style (i.e., "I-PERS" style labels)
or just categories representation to any other.
|
static boolean |
isDifferentEntityBoundary(java.lang.String beforeEntity,
java.lang.String afterEntity) |
static boolean |
isEntityBoundary(java.lang.String beforeEntity,
char beforePrefix,
java.lang.String afterEntity,
char afterPrefix) |
static boolean |
isSameEntityBoundary(java.lang.String beforeEntity,
char beforePrefix,
java.lang.String afterEntity,
char afterPrefix) |
static void |
main(java.lang.String[] args)
Converts entity representation of a file.
|
public static <TOK extends CoreMap> void entitySubclassify(java.util.List<TOK> tokens, java.lang.Class<? extends TypesafeMap.Key<java.lang.String>> key, java.lang.String backgroundLabel, java.lang.String style, boolean intern)
tokens
- List of tokens (each a CoreLabel) in some stylekey
- The key in the CoreLabel to change, commonly CoreAnnotations.AnswerAnnotation.classbackgroundLabel
- The background label, which gets special treatmentstyle
- Output style; one of iob[12], ioe[12], io, sbieo/iobes, noprefixintern
- Whether to String-intern the new labels (may as well, small number!)public static boolean isEntityBoundary(java.lang.String beforeEntity, char beforePrefix, java.lang.String afterEntity, char afterPrefix)
public static boolean isSameEntityBoundary(java.lang.String beforeEntity, char beforePrefix, java.lang.String afterEntity, char afterPrefix)
public static boolean isDifferentEntityBoundary(java.lang.String beforeEntity, java.lang.String afterEntity)
public static boolean countEntityResults(java.util.List<? extends CoreMap> doc, Counter<java.lang.String> entityTP, Counter<java.lang.String> entityFP, Counter<java.lang.String> entityFN, java.lang.String background)
doc
- The document (with Answer and GoldAnswer annotations) to scoreentityTP
- Counter from entity type to count of true positivesentityFP
- Counter from entity type to count of false positivesentityFN
- Counter from entity type to count of false negativesbackground
- The background symbol. Normally it isn't counted in entity-level
F1 scores. If you want it counted, pass in null for this.public static void main(java.lang.String[] args)