Class Layers

java.lang.Object
opennlp.tools.document.Layers

public final class Layers extends Object
The standard layer keys for the results the toolkit produces itself.

Every key defined here carries the opennlp: id prefix, which key(String, Class) and documentKey(String, Class) apply. Other producers define their keys in their own packages under their own prefix.

Since:
3.0.0
  • Field Details

    • SENTENCES

      public static final LayerKey<String> SENTENCES
      Sentence boundaries; each annotation covers one sentence and carries its text.
    • TOKENS

      public static final LayerKey<String> TOKENS
      Token boundaries; each annotation covers one token and carries its text.
    • POS_TAGS

      public static final LayerKey<String> POS_TAGS
      Part-of-speech tags; one annotation per token, aligned with TOKENS by position, carrying the tag.
    • ENTITIES

      public static final LayerKey<String> ENTITIES
      Named entities; each annotation covers one mention and carries the entity type as its value. The annotation's span carries offsets only.
  • Method Details

    • key

      public static <T> LayerKey<T> key(String name, Class<T> type)
      Creates a positional key in the toolkit's opennlp: namespace, for a layer the toolkit itself produces.
      Type Parameters:
      T - The type of the annotation values.
      Parameters:
      name - The layer name without a namespace, for example tokens. Must not be null, blank, or contain ':'.
      type - The class of the annotation values stored under the key. Must not be null.
      Returns:
      A key whose id is the name under the opennlp: prefix. Never null.
      Throws:
      IllegalArgumentException - Thrown if name is null, blank, or contains ':', or type is null.
    • documentKey

      public static <T> LayerKey<T> documentKey(String name, Class<T> type)
      Creates a document-scoped key in the toolkit's opennlp: namespace, for a whole-document value the toolkit itself produces.
      Type Parameters:
      T - The type of the annotation values.
      Parameters:
      name - The layer name without a namespace, for example language. Must not be null, blank, or contain ':'.
      type - The class of the annotation values stored under the key. Must not be null.
      Returns:
      A document-scoped key whose id is the name under the opennlp: prefix. Never null.
      Throws:
      IllegalArgumentException - Thrown if name is null, blank, or contains ':', or type is null.