com.languagecomputer.api.text
Interface Document

All Superinterfaces:
Text
All Known Implementing Classes:
DefaultDocument

public interface Document
extends Text

Representation of an unstructured document after processing by the DocumentService and containing results of processing through the annotation services. Provides access to all internal Text objects.

Since:
1.0
Author:
Kirk Roberts

Field Summary
static AnnotationType<Document> TYPE
           
 
Method Summary
 void addAnnotation(Text annotation)
          Adds a Text to this Document.
 void addMetaData(String key, String value)
          Adds meta information about the Document using a key-value pair.
 void addService(String serviceName)
          Adds the serviceName to the list of Services that have been processed this Document.
 Collection<Text> getAllAnnotations()
          Returns all the annotations on this Document.
 Map<String,Collection<String>> getAllMetaData()
          Returns all the meta-data values attached to this Document.
<T extends Text>
Collection<T>
getAnnotations(AnnotationType<T> type)
          Returns all the annotations on this Document that correspond to the given AnnotationType.
 String getDocumentID()
          Returns the ID of this Document.
 Collection<String> getMetaData(String key)
          Returns the meta-data values for the given meta-data key.
 List<String> getServices()
          Returns the names of the Services that have processed this Document.
 
Methods inherited from interface com.languagecomputer.api.text.Text
getAnnotationType, getCongruentAnnotations, getDocument, getEndCharOffset, getIntersectingAnnotations, getRawString, getStartCharOffset, getSubAnnotations, getSuperAnnotations
 

Field Detail

TYPE

static final AnnotationType<Document> TYPE
Method Detail

getDocumentID

String getDocumentID()
Returns the ID of this Document. The document ID is a unique identifier that can be used to retrieve the document from caches such as the DocumentService.

Specified by:
getDocumentID in interface Text
Returns:
The ID of this Document.

getAllAnnotations

Collection<Text> getAllAnnotations()
Returns all the annotations on this Document.

Returns:
A Collection of all Text objects that are attached to this Document. The annotations will be in a semi-sorted order. This means that non-intersecting objects will be sorted by their order in the document. No guarantee will be placed on the order of intersecting objects.

getAnnotations

<T extends Text> Collection<T> getAnnotations(AnnotationType<T> type)
Returns all the annotations on this Document that correspond to the given AnnotationType.

Type Parameters:
T - The Text sub-class corresponding to the given AnnotationType.
Parameters:
type - The AnnotationType that all returned items will match.
Returns:
A Collection of objects matching the given AnnotationType. The annotations will be in a semi-sorted order. This means that non-intersecting objects will be sorted by their order in the document. No guarantee will be placed on the order of intersecting objects.

addAnnotation

void addAnnotation(Text annotation)
Adds a Text to this Document.

Parameters:
annotation - The Text annotation to add.
See Also:
getAllAnnotations()

addService

void addService(String serviceName)
Adds the serviceName to the list of Services that have been processed this Document. Services should not need to be run more than once, so this allows the Document to know which services it has been processed by. See Service#getName for the convention on naming services.

Parameters:
serviceName - String name for a Service.
See Also:
Service#getName, getServices()

getServices

List<String> getServices()
Returns the names of the Services that have processed this Document. Services should not need to be run more than once, so they can check this list to prevent redundant work. See Service#getName for the convention on naming services.

Returns:
List of Service names that have processed this Document.
See Also:
Service#getName, addService(String)

addMetaData

void addMetaData(String key,
                 String value)
Adds meta information about the Document using a key-value pair. A Document may have multiple values for the same key.

Parameters:
key - The identifier for the meta-data.
value - The value for the corresponding meta-data key.
See Also:
getMetaData(String), getAllMetaData()

getMetaData

Collection<String> getMetaData(String key)
Returns the meta-data values for the given meta-data key. Multiple values may be associated with a given key, but the values are guaranteed to be neither ordered or unique.

Parameters:
key - The identifier for the meta-data.
Returns:
A Collection of meta-data values that correspond to the given key. Returns null if the given key has no values.
See Also:
addMetaData(String,String), getAllMetaData()

getAllMetaData

Map<String,Collection<String>> getAllMetaData()
Returns all the meta-data values attached to this Document. Note that meta-data may be used to provide information to the end user or to share information about the document between Services. Consumers of meta-data should therefore be mindful of how meta-data is used in a particular use case.

Returns:
A Map of every meta-data key to its corresponding Collection of meta-data values.
See Also:
addMetaData(String,String), getMetaData(String)


Copyright © 2009. All Rights Reserved.