ABL4J (Alignment Based Learning for Java) - 0.9.7

org.schwiebert.abl4j.data.impl.abl
Class Sentence<T>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<IWord<T>>
              extended by org.schwiebert.abl4j.data.impl.abl.Sentence<T>
Type Parameters:
T -
All Implemented Interfaces:
Serializable, Cloneable, Iterable<IWord<T>>, Collection<IWord<T>>, List<IWord<T>>, RandomAccess, ISentence<T>
Direct Known Subclasses:
Tree

public class Sentence<T>
extends ArrayList<IWord<T>>
implements ISentence<T>

Represents a Sentence as a List of IWord objects.

Author:
sschwieb
See Also:
Serialized Form

Field Summary
private  String commentLine
          An optional comment line
private  int sentenceId
          storing the sentence ID
private static long serialVersionUID
           
private  Set<Integer> similars
          keeping track of sentences to compare with
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
Sentence()
           
 
Method Summary
 void addWords(List<IWord<T>> words)
          Adds all IWord stored in words to this sentence, as in List.addAll(java.util.Collection).
 void buildSimilarSentencesSet()
          This procedure considers each word in the sentence and fills the set "similars" with sentences to compare with as these sentences have at least one word in common.
 String getCommentLine()
          Returns the commentLine
 int getSequenceId()
          This procedure returns the sentence ID
 String getSequenceText()
          Returns a string representation of this sequence.
 List<IWord<T>> getWords()
          Returns the list of all IWords in this sentence.
 int indexOf(IWord<T> elem, int index)
          Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.
 boolean isSimilarTo(int id)
          This procedure returns true if the current sentence has in its "similars" set the sentence specified with argument "id", and returns false if it has not, or if the map of similar sentences has not been created (Because ISentence.buildSimilarSentencesSet() has not been called).
 void registerWordsInSentence()
          This procedure considers each word in the sentence and registers its appearance in the current sentence to facilitate future decisions on which sentences to compare with.
 void setCommentLine(String commentLine)
          Sets the commentLine
 void setSequenceId(int id)
          This procedure sets the sentence ID
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.schwiebert.abl4j.data.ISentence
get, size, subList
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

sentenceId

private int sentenceId
storing the sentence ID


similars

private Set<Integer> similars
keeping track of sentences to compare with


commentLine

private String commentLine
An optional comment line

Constructor Detail

Sentence

public Sentence()
Method Detail

setCommentLine

public void setCommentLine(String commentLine)
Description copied from interface: ISentence
Sets the commentLine

Specified by:
setCommentLine in interface ISentence<T>

getCommentLine

public String getCommentLine()
Description copied from interface: ISentence
Returns the commentLine

Specified by:
getCommentLine in interface ISentence<T>
Returns:

setSequenceId

public void setSequenceId(int id)
Description copied from interface: ISentence
This procedure sets the sentence ID

Specified by:
setSequenceId in interface ISentence<T>

getSequenceId

public int getSequenceId()
Description copied from interface: ISentence
This procedure returns the sentence ID

Specified by:
getSequenceId in interface ISentence<T>

registerWordsInSentence

public void registerWordsInSentence()
Description copied from interface: ISentence
This procedure considers each word in the sentence and registers its appearance in the current sentence to facilitate future decisions on which sentences to compare with. It should be called while reading in the full treebank line by line.

Specified by:
registerWordsInSentence in interface ISentence<T>

buildSimilarSentencesSet

public void buildSimilarSentencesSet()
Description copied from interface: ISentence
This procedure considers each word in the sentence and fills the set "similars" with sentences to compare with as these sentences have at least one word in common.

Specified by:
buildSimilarSentencesSet in interface ISentence<T>

isSimilarTo

public boolean isSimilarTo(int id)
Description copied from interface: ISentence
This procedure returns true if the current sentence has in its "similars" set the sentence specified with argument "id", and returns false if it has not, or if the map of similar sentences has not been created (Because ISentence.buildSimilarSentencesSet() has not been called).

Specified by:
isSimilarTo in interface ISentence<T>

getSequenceText

public String getSequenceText()
Description copied from interface: ISentence
Returns a string representation of this sequence.

Specified by:
getSequenceText in interface ISentence<T>
Returns:

indexOf

public int indexOf(IWord<T> elem,
                   int index)
Description copied from interface: ISentence
Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.

Specified by:
indexOf in interface ISentence<T>
Parameters:
elem - an object.
index - the non-negative index to start searching from.
Returns:
the index of the first occurrence of the object argument in this sequence at position index or later in the sequence, that is, the smallest value k such that elem.equals(elementData[k]) && (k >= index) is true; returns -1 if the object is not found. (Returns -1 if index >= the current size of this sequence.)
See Also:
Object.equals(Object), List.indexOf(Object)

getWords

public List<IWord<T>> getWords()
Description copied from interface: ISentence
Returns the list of all IWords in this sentence.

Specified by:
getWords in interface ISentence<T>
Returns:
the list of words

addWords

public void addWords(List<IWord<T>> words)
Description copied from interface: ISentence
Adds all IWord stored in words to this sentence, as in List.addAll(java.util.Collection).

Specified by:
addWords in interface ISentence<T>

ABL4J (Alignment Based Learning for Java) - 0.9.7

© 2007 Stephan Schwiebert