gov.llnl.ontology.text
Class Sentence

java.lang.Object
  extended by edu.stanford.nlp.util.ArrayCoreMap
      extended by edu.stanford.nlp.pipeline.Annotation
          extended by gov.llnl.ontology.text.Sentence
All Implemented Interfaces:
edu.stanford.nlp.util.CoreMap, edu.stanford.nlp.util.TypesafeMap<edu.stanford.nlp.util.CoreMap>, Serializable, Iterable<edu.stanford.nlp.pipeline.Annotation>

public class Sentence
extends edu.stanford.nlp.pipeline.Annotation
implements Serializable, Iterable<edu.stanford.nlp.pipeline.Annotation>

An Annotation specificly designed for sentences. It represents a sentence as an array of other Annotations, each of which represents an Annotation for each word in the sentence. These word level Annotations can contain values for dependency parsing features, token features, and part of speech tags. If these features are available, the Sentence can be viewed as a series DependencyTreeNodes or a series of StringPairs.

Author:
Keith Stevens
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class edu.stanford.nlp.pipeline.Annotation
edu.stanford.nlp.pipeline.Annotation.OriginalStringPLAnnotation, edu.stanford.nlp.pipeline.Annotation.OriginalWordsPLAnnotation, edu.stanford.nlp.pipeline.Annotation.ParsePLAnnotation, edu.stanford.nlp.pipeline.Annotation.WordsPLAnnotation
 
Nested classes/interfaces inherited from interface edu.stanford.nlp.util.TypesafeMap
edu.stanford.nlp.util.TypesafeMap.Key<BASE,VALUE>
 
Constructor Summary
Sentence(int start, int end, int numTokens)
          Creates a new Sentence with the following initial attributes.
 
Method Summary
 void addAnnotation(int index, edu.stanford.nlp.pipeline.Annotation annotation)
          Sets annotation as the data for the ith token in the Sentence.
 edu.ucla.sspace.dependency.DependencyTreeNode[] dependencyParseTree()
          Returns an Iterator over DependencyTreeNodes for each token in the Sentence.
 int end()
          Returns the end index of this sentence.
 edu.stanford.nlp.pipeline.Annotation getAnnotation(int index)
          Returns the Annotation stored at index
 Iterator<edu.stanford.nlp.pipeline.Annotation> iterator()
          Returns an Iterator over Annotations for each token in the Sentence.
 int numTokens()
           
static List<Sentence> readSentences(String sentenceText, String tokenText)
          Reads a list of Sentences from the serialzied form of the Sentence meta-data and the Annotation meta-data for each token in the sentence.
 String sentenceText()
          Returns the raw text from the original document text for just the characters spanned by this Sentence.
 void setText(String text)
          Sets the raw document text associated with this Sentence.
 edu.stanford.nlp.util.IntPair span()
          Returns the IntPair recording the span of this Sentence.
 int start()
          Returns the start index of this sentence.
 StringPair[] taggedTokens()
          Returns an Iterator over StringPairs for each token in the Sentence.
static StringPair writeSentences(List<Sentence> sentences)
           
 
Methods inherited from class edu.stanford.nlp.pipeline.Annotation
copy, toString
 
Methods inherited from class edu.stanford.nlp.util.ArrayCoreMap
compact, containsKey, equals, get, has, hashCode, keySet, remove, set, setCapacity, size, toShorterString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Sentence

public Sentence(int start,
                int end,
                int numTokens)
Creates a new Sentence with the following initial attributes. numTokens dictates how many tokens were found in this sentence and cannot be modified.

Method Detail

setText

public void setText(String text)
Sets the raw document text associated with this Sentence. This must be called before calling sentenceText().


sentenceText

public String sentenceText()
Returns the raw text from the original document text for just the characters spanned by this Sentence.


addAnnotation

public void addAnnotation(int index,
                          edu.stanford.nlp.pipeline.Annotation annotation)
Sets annotation as the data for the ith token in the Sentence.


getAnnotation

public edu.stanford.nlp.pipeline.Annotation getAnnotation(int index)
Returns the Annotation stored at index


dependencyParseTree

public edu.ucla.sspace.dependency.DependencyTreeNode[] dependencyParseTree()
Returns an Iterator over DependencyTreeNodes for each token in the Sentence.


taggedTokens

public StringPair[] taggedTokens()
Returns an Iterator over StringPairs for each token in the Sentence.


iterator

public Iterator<edu.stanford.nlp.pipeline.Annotation> iterator()
Returns an Iterator over Annotations for each token in the Sentence.

Specified by:
iterator in interface Iterable<edu.stanford.nlp.pipeline.Annotation>

start

public int start()
Returns the start index of this sentence.


end

public int end()
Returns the end index of this sentence.


numTokens

public int numTokens()

span

public edu.stanford.nlp.util.IntPair span()
Returns the IntPair recording the span of this Sentence.


readSentences

public static List<Sentence> readSentences(String sentenceText,
                                           String tokenText)
Reads a list of Sentences from the serialzied form of the Sentence meta-data and the Annotation meta-data for each token in the sentence. This will leave text unset. Only output from #writeSentence is valid when calling readSentences(java.lang.String, java.lang.String).


writeSentences

public static StringPair writeSentences(List<Sentence> sentences)


Copyright © 2010-2011. All Rights Reserved.