org.apache.uima.annotator.dict_annot.dictionary.impl
Class HashMapDictionary

java.lang.Object
  extended by org.apache.uima.annotator.dict_annot.dictionary.impl.HashMapDictionary
All Implemented Interfaces:
Dictionary

public class HashMapDictionary
extends java.lang.Object
implements Dictionary

HashMap dictionary implementation. Implements the Dictionary interface using a simple HashMap for the lookup. Each word added to the dictionary is added to the main dictionary HashMap with some additional meta data information. In case of multi-words the multi word parts are added as tree to the dictionary.


Constructor Summary
HashMapDictionary(boolean caseNormalization)
          Creates a new HashMapDictionary object with an initial capacity of 100 entries.
 
Method Summary
 int addMultiWord(java.lang.String[] multiWord)
          Adds a new multi-word to the dictionary
 int addWord(java.lang.String word)
          Adds a new word to the dictionary.
 boolean contains(java.lang.String word)
          Checks if the given word is available in the dictionary.
 boolean contains(java.lang.String[] multiWord)
          Checks if the given multi word is available in the dictionary.
 int getEntryCount()
          Returns the number of entries that are stored in the dictionary.
 java.lang.String getLanguage()
          Returns the language of this dictionary
 java.lang.String getTypeName()
          Returns the type name which should use to create annotations
 DictionaryMatch matchEntry(int pos, org.apache.uima.cas.text.AnnotationFS[] annotFSs, FeaturePathInfo featPathInfo)
          Checks if at the current position in the token array a match in the dictionary is found.
 void printDictionary(java.io.Writer out)
          print the dictionary content either to an Writer object or if not output is specified to the command line.
 void setDictionaryLanguage(java.lang.String language)
          set the dictionary language
 void setTypeName(java.lang.String typeName)
          set the dictionary type name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashMapDictionary

public HashMapDictionary(boolean caseNormalization)
Creates a new HashMapDictionary object with an initial capacity of 100 entries.

Method Detail

contains

public boolean contains(java.lang.String word)
Description copied from interface: Dictionary
Checks if the given word is available in the dictionary.

Specified by:
contains in interface Dictionary
Parameters:
word - word to look for
Returns:
returns true if the given word is available in the dictionary, otherwise false is returned

contains

public boolean contains(java.lang.String[] multiWord)
Description copied from interface: Dictionary
Checks if the given multi word is available in the dictionary.

Specified by:
contains in interface Dictionary
Parameters:
multiWord - multi word to look for
Returns:
returns true if the given multi word is available in the dictionary, otherwise false is returned

getTypeName

public java.lang.String getTypeName()
Description copied from interface: Dictionary
Returns the type name which should use to create annotations

Specified by:
getTypeName in interface Dictionary
Returns:
type name

getLanguage

public java.lang.String getLanguage()
Description copied from interface: Dictionary
Returns the language of this dictionary

Specified by:
getLanguage in interface Dictionary
Returns:
dictionary language

matchEntry

public DictionaryMatch matchEntry(int pos,
                                  org.apache.uima.cas.text.AnnotationFS[] annotFSs,
                                  FeaturePathInfo featPathInfo)
Description copied from interface: Dictionary
Checks if at the current position in the token array a match in the dictionary is found.

Specified by:
matchEntry in interface Dictionary
Parameters:
pos - current array position
annotFSs - input annotation FS array
featPathInfo - featurePath information for the matching
Returns:
returns a DictionaryMatch object in case a match was found. If no match was found, null is returned

getEntryCount

public int getEntryCount()
Description copied from interface: Dictionary
Returns the number of entries that are stored in the dictionary.

Specified by:
getEntryCount in interface Dictionary
Returns:
number of entries

addWord

public int addWord(java.lang.String word)
Adds a new word to the dictionary.

Parameters:
word - word that should be added to the dictionary
Returns:
ID that was generated for this entry

addMultiWord

public int addMultiWord(java.lang.String[] multiWord)
Adds a new multi-word to the dictionary

Parameters:
multiWord - multi-word that should be added to the dictionary
Returns:
ID that was generated for this entry

printDictionary

public void printDictionary(java.io.Writer out)
                     throws java.io.IOException
print the dictionary content either to an Writer object or if not output is specified to the command line.

Parameters:
out - Writer object to write the content to
Throws:
java.io.IOException

setDictionaryLanguage

public void setDictionaryLanguage(java.lang.String language)
set the dictionary language

Parameters:
language - dictionary language

setTypeName

public void setTypeName(java.lang.String typeName)
set the dictionary type name

Parameters:
typeName - dictionary type name


Copyright © 2011. All Rights Reserved.