ABL4J (Alignment Based Learning for Java) - 0.9.7

org.schwiebert.abl4j.util
Class WordMapping<T>

java.lang.Object
  extended by org.schwiebert.abl4j.util.WordMapping<T>
All Implemented Interfaces:
Serializable, IWordMapping<T>
Direct Known Subclasses:
StringMapping

public class WordMapping<T>
extends Object
implements Serializable, IWordMapping<T>

A helper class which provides word mappings. To map String objects, the default implementation StringMapping can be used.

Author:
sschwieb
See Also:
Serialized Form

Field Summary
private  Map<Integer,Vector<Integer>> indexToSentence
          mapping word index -> sentence index
private  Map<Integer,T> indexToWord
          mapping word index -> word string
private static long serialVersionUID
           
private  Map<T,Integer> wordToIndex
          mapping word string -> word index
 
Constructor Summary
WordMapping(Comparator<T> comparator)
           
 
Method Summary
 void addIndexToSentence(int index, int sentenceId)
          This method is called to register the use of the word wordId in sentence sentenceId.
 Vector<Integer> getSentencesOfIndex(int index)
          Returns a list of all sequences which contain the word with id wordId.
 T getWord(int index)
          Returns the word with id wordId
 int getWordIndexByObject(T data)
          Returns the word id of data
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

wordToIndex

private final Map<T,Integer> wordToIndex
mapping word string -> word index


indexToWord

private final Map<Integer,T> indexToWord
mapping word index -> word string


indexToSentence

private final Map<Integer,Vector<Integer>> indexToSentence
mapping word index -> sentence index

Constructor Detail

WordMapping

public WordMapping(Comparator<T> comparator)
Method Detail

addIndexToSentence

public void addIndexToSentence(int index,
                               int sentenceId)
Description copied from interface: IWordMapping
This method is called to register the use of the word wordId in sentence sentenceId.

Specified by:
addIndexToSentence in interface IWordMapping<T>

getSentencesOfIndex

public Vector<Integer> getSentencesOfIndex(int index)
Description copied from interface: IWordMapping
Returns a list of all sequences which contain the word with id wordId.

Specified by:
getSentencesOfIndex in interface IWordMapping<T>
Returns:

getWord

public T getWord(int index)
Description copied from interface: IWordMapping
Returns the word with id wordId

Specified by:
getWord in interface IWordMapping<T>
Returns:

getWordIndexByObject

public int getWordIndexByObject(T data)
Description copied from interface: IWordMapping
Returns the word id of data

Specified by:
getWordIndexByObject in interface IWordMapping<T>
Returns:

ABL4J (Alignment Based Learning for Java) - 0.9.7

© 2007 Stephan Schwiebert