opennlp.tools.dictionary
Class Dictionary

java.lang.Object
  extended by opennlp.tools.dictionary.Dictionary

public class Dictionary
extends java.lang.Object

This class is a dictionary.

Version:
$Revision: 1.7 $, $Date: 2008/04/19 12:26:46 $
Author:
Joern Kottmann

Constructor Summary
Dictionary()
          Initializes an empty Dictionary.
Dictionary(boolean caseSensitive)
           
Dictionary(java.io.InputStream in)
          Initializes the Dictionary from an existing dictionary resource.
Dictionary(java.io.InputStream in, boolean caseSensitive)
           
 
Method Summary
 boolean contains(TokenList tokens)
          Checks if this dictionary has the given entry.
 boolean equals(java.lang.Object obj)
           
 int hashCode()
           
 java.util.Iterator iterator()
          Retrieves an Iterator over all tokens.
static Dictionary parseOneEntryPerLine(java.io.Reader in)
          Reads a dictionary which has one entry per line.
 void put(TokenList tokens)
          Adds the tokens to the dictionary as one new entry.
 void remove(TokenList tokens)
          Removes the given tokens form the current instance.
 void serialize(java.io.OutputStream out)
          Writes the current instance to the given OutputStream.
 int size()
          Retrieves the number of tokens in the current instance.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Dictionary

public Dictionary()
Initializes an empty Dictionary.


Dictionary

public Dictionary(boolean caseSensitive)

Dictionary

public Dictionary(java.io.InputStream in)
           throws java.io.IOException,
                  InvalidFormatException
Initializes the Dictionary from an existing dictionary resource.

Parameters:
in -
Throws:
java.io.IOException
InvalidFormatException

Dictionary

public Dictionary(java.io.InputStream in,
                  boolean caseSensitive)
           throws java.io.IOException,
                  InvalidFormatException
Throws:
java.io.IOException
InvalidFormatException
Method Detail

put

public void put(TokenList tokens)
Adds the tokens to the dictionary as one new entry.

Parameters:
tokens - the new entry

contains

public boolean contains(TokenList tokens)
Checks if this dictionary has the given entry.

Parameters:
tokens -
Returns:
true if it contains the entry otherwise false

remove

public void remove(TokenList tokens)
Removes the given tokens form the current instance.

Parameters:
tokens -

iterator

public java.util.Iterator iterator()
Retrieves an Iterator over all tokens.

Returns:
token-Iterator

size

public int size()
Retrieves the number of tokens in the current instance.

Returns:
number of tokens

serialize

public void serialize(java.io.OutputStream out)
               throws java.io.IOException
Writes the current instance to the given OutputStream.

Parameters:
out -
Throws:
java.io.IOException

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

parseOneEntryPerLine

public static Dictionary parseOneEntryPerLine(java.io.Reader in)
                                       throws java.io.IOException
Reads a dictionary which has one entry per line. The tokens inside an entry are whitespace delimited.

Parameters:
in -
Returns:
the parsed dictionary
Throws:
java.io.IOException


Copyright 2008 Jason Baldridge, Gann Bierner, and Thomas Morton. All Rights Reserved.