opennlp.tools.postag
Class POSDictionary

java.lang.Object
  extended by opennlp.tools.postag.POSDictionary
All Implemented Interfaces:
java.lang.Iterable<java.lang.String>, TagDictionary

public class POSDictionary
extends java.lang.Object
implements java.lang.Iterable<java.lang.String>, TagDictionary

Provides a means of determining which tags are valid for a particular word based on a tag dictionary read from a file.


Constructor Summary
POSDictionary()
           
POSDictionary(java.io.BufferedReader reader, boolean caseSensitive)
          Deprecated. Use create(InputStream) instead, old format might removed.
POSDictionary(java.lang.String file)
          Deprecated. Use create(InputStream) instead, old format might removed.
POSDictionary(java.lang.String file, boolean caseSensitive)
          Deprecated. Use create(InputStream) instead, old format might removed.
POSDictionary(java.lang.String file, java.lang.String encoding, boolean caseSensitive)
          Deprecated. Use create(InputStream) instead, old format might removed.
 
Method Summary
static POSDictionary create(java.io.InputStream in)
          Creates a new POSDictionary from a provided InputStream.
 boolean equals(java.lang.Object o)
           
 java.lang.String[] getTags(java.lang.String word)
          Returns a list of valid tags for the specified word.
 java.util.Iterator<java.lang.String> iterator()
           
static void main(java.lang.String[] args)
           
 void serialize(java.io.OutputStream out)
          Writes the POSDictionary to the given OutputStream; After the serialization is finished the provided OutputStream remains open.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

POSDictionary

public POSDictionary()

POSDictionary

@Deprecated
public POSDictionary(java.lang.String file)
              throws java.io.IOException
Deprecated. Use create(InputStream) instead, old format might removed.

Creates a tag dictionary with contents of specified file.

Parameters:
file - The file name for the tag dictionary.
Throws:
java.io.IOException - when the specified file can not be read.

POSDictionary

@Deprecated
public POSDictionary(java.lang.String file,
                                boolean caseSensitive)
              throws java.io.IOException
Deprecated. Use create(InputStream) instead, old format might removed.

Creates a tag dictionary with contents of specified file and using specified case to determine how to access entries in the tag dictionary.

Parameters:
file - The file name for the tag dictionary.
caseSensitive - Specifies whether the tag dictionary is case sensitive or not.
Throws:
java.io.IOException - when the specified file can not be read.

POSDictionary

@Deprecated
public POSDictionary(java.lang.String file,
                                java.lang.String encoding,
                                boolean caseSensitive)
              throws java.io.IOException
Deprecated. Use create(InputStream) instead, old format might removed.

Creates a tag dictionary with contents of specified file and using specified case to determine how to access entries in the tag dictionary.

Parameters:
file - The file name for the tag dictionary.
encoding - The encoding of the tag dictionary file.
caseSensitive - Specifies whether the tag dictionary is case sensitive or not.
Throws:
java.io.IOException - when the specified file can not be read.

POSDictionary

@Deprecated
public POSDictionary(java.io.BufferedReader reader,
                                boolean caseSensitive)
              throws java.io.IOException
Deprecated. Use create(InputStream) instead, old format might removed.

Create tag dictionary object with contents of specified file and using specified case to determine how to access entries in the tag dictionary.

Parameters:
reader - A reader for the tag dictionary.
caseSensitive - Specifies whether the tag dictionary is case sensitive or not.
Throws:
java.io.IOException - when the specified file can not be read.
Method Detail

getTags

public java.lang.String[] getTags(java.lang.String word)
Returns a list of valid tags for the specified word.

Specified by:
getTags in interface TagDictionary
Parameters:
word - The word.
Returns:
A list of valid tags for the specified word or null if no information is available for that word.

iterator

public java.util.Iterator<java.lang.String> iterator()
Specified by:
iterator in interface java.lang.Iterable<java.lang.String>

serialize

public void serialize(java.io.OutputStream out)
               throws java.io.IOException
Writes the POSDictionary to the given OutputStream; After the serialization is finished the provided OutputStream remains open.

Parameters:
out - the OutputStream to write the dictionary into.
Throws:
java.io.IOException - if writing to the OutputStream fails

equals

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

toString

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

create

public static POSDictionary create(java.io.InputStream in)
                            throws java.io.IOException,
                                   InvalidFormatException
Creates a new POSDictionary from a provided InputStream. After creation is finished the provided InputStream is closed.

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

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        InvalidFormatException
Throws:
java.io.IOException
InvalidFormatException


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.