DocumentSample (Apache OpenNLP Tools 1.9.5 API)
Date: 2026-06-18

opennlp.tools.doccat

## Class DocumentSample

- java.lang.Object
- - opennlp.tools.doccat.DocumentSample

- All Implemented Interfaces:
    Serializable

      public class DocumentSample
      extends Object
      implements Serializable

  Class which holds a classified document and its category.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DocumentSample(String category, String[] text)`
    `DocumentSample(String category, String[] text, Map<String,Object> extraInformation)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object obj)`
    `String` | `getCategory()`
    `Map<String,Object>` | `getExtraInformation()`
    `String[]` | `getText()`
    `int` | `hashCode()`
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### DocumentSample

          public DocumentSample(String category,
                                String[] text)

    - #### DocumentSample

          public DocumentSample(String category,
                                String[] text,
                                Map<String,Object> extraInformation)

  - ### Method Detail

    - #### getCategory

          public String getCategory()

    - #### getText

          public String[] getText()

    - #### getExtraInformation

          public Map<String,Object> getExtraInformation()

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

Copyright © 2026 The Apache Software Foundation. All rights reserved.