jmrc
Class LexicalDatabase

java.lang.Object
  extended by jmrc.LexicalDatabase
Direct Known Subclasses:
MRCDatabase

public class LexicalDatabase
extends java.lang.Object

Implementation fo a general lexical database, associating a word, part-of-speech and field to an integer value. Based on a LinkedHashMap.

Author:
Francois Mairesse, http://www.dcs.shef.ac.uk/~francois

Constructor Summary
LexicalDatabase()
          Construct a new lexical database.
LexicalDatabase(int size)
          Construct a new lexical database, allocating the specified number of entries.
 
Method Summary
 void addEntriesFrom(LexicalDatabase db)
          Copies entries from the argument into the database, without overwriting existing entries.
 boolean containsEntry(java.lang.String word, java.lang.String pos, java.lang.String field)
          Returns true if the word (lower-case), part-of-speech and field are associated with a value in the database.
 boolean containsField(Field field)
          Returns true if database contains the field.
 boolean containsField(java.lang.String field)
          Returns true if database contains the field.
 java.util.List<Field> getFields()
           
 java.util.Comparator getLexiconComparator(Field field, PoS pos)
          Returns a string comparator for based on the database values of a given field and for a given PoS tag.
 java.util.Map<java.lang.String,java.util.Map<PoS,java.util.Map<Field,java.lang.Integer>>> getMap()
          Returns the underlying mapping of the database.
 int getValue(java.lang.String word, Field field)
          Returns an integer feature value from the database for any random PoS of the input word.
 int getValue(java.lang.String word, PoS pos, Field field)
          Returns an integer feature value from the database.
 int getValue(java.lang.String word, PoS pos, java.lang.String field)
          Returns an integer feature value from the database.
 int getValue(java.lang.String word, java.lang.String field)
          Returns an integer feature value from the database for any random PoS of the input word.
 java.util.List<java.lang.String> getWords(Field field, PoS pos, double min, double max)
          Returns all words in the database with values within the [min,max] interval specified (linear search).
 java.util.List<java.lang.String> getWords(Field field, PoS pos, int inputValue)
          Returns all words in the database with the exact specified integer value (linear search).
 void putValue(java.lang.String word, PoS pos, Field field, int value)
          Insert a value in the lexical database.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LexicalDatabase

public LexicalDatabase()
Construct a new lexical database.


LexicalDatabase

public LexicalDatabase(int size)
Construct a new lexical database, allocating the specified number of entries.

Method Detail

containsField

public boolean containsField(java.lang.String field)
Returns true if database contains the field.

Parameters:
field - String value of a database field.
Returns:

containsField

public boolean containsField(Field field)
Returns true if database contains the field.

Parameters:
field - database field.
Returns:

containsEntry

public boolean containsEntry(java.lang.String word,
                             java.lang.String pos,
                             java.lang.String field)
Returns true if the word (lower-case), part-of-speech and field are associated with a value in the database.

Parameters:
word - word to look-up.
pos - part-of-speech.
field - field to look-up.
Returns:

getLexiconComparator

public java.util.Comparator getLexiconComparator(Field field,
                                                 PoS pos)
Returns a string comparator for based on the database values of a given field and for a given PoS tag. All values must be defined or the ordering won't be total, therefore not garranteed.

Parameters:
field - database field.
pos - part-of-speech.
Returns:

getWords

public java.util.List<java.lang.String> getWords(Field field,
                                                 PoS pos,
                                                 double min,
                                                 double max)
Returns all words in the database with values within the [min,max] interval specified (linear search).

Parameters:
field - database field.
pos - part-of-speech.
min - minimum value (included).
max - maximum value (included).
Returns:

getWords

public java.util.List<java.lang.String> getWords(Field field,
                                                 PoS pos,
                                                 int inputValue)
Returns all words in the database with the exact specified integer value (linear search).

Parameters:
field - database field.
pos - part-of-speech.
inputValue - input value to match.
Returns:

getValue

public int getValue(java.lang.String word,
                    PoS pos,
                    java.lang.String field)
             throws QueryException
Returns an integer feature value from the database.

Parameters:
word - word to look-up.
pos - part-of-speech to look up.
field - field of the database.
Returns:
Throws:
QueryException

getValue

public int getValue(java.lang.String word,
                    java.lang.String field)
             throws QueryException
Returns an integer feature value from the database for any random PoS of the input word.

Parameters:
word -
field -
Returns:
Throws:
QueryException

getFields

public java.util.List<Field> getFields()

getValue

public int getValue(java.lang.String word,
                    PoS pos,
                    Field field)
             throws QueryException
Returns an integer feature value from the database.

Parameters:
word - word to look-up.
pos - part-of-speech to look up.
field - field of the database.
Returns:
Throws:
QueryException

getValue

public int getValue(java.lang.String word,
                    Field field)
             throws QueryException
Returns an integer feature value from the database for any random PoS of the input word.

Parameters:
word -
pos -
field -
Returns:
Throws:
QueryException

putValue

public void putValue(java.lang.String word,
                     PoS pos,
                     Field field,
                     int value)
Insert a value in the lexical database.

Parameters:
word - word to insert value for.
pos - part-of-speech of the word.
field - Type of value.
value - Integer value to be added.

getMap

public java.util.Map<java.lang.String,java.util.Map<PoS,java.util.Map<Field,java.lang.Integer>>> getMap()
Returns the underlying mapping of the database.

Returns:

addEntriesFrom

public void addEntriesFrom(LexicalDatabase db)
Copies entries from the argument into the database, without overwriting existing entries.

Parameters:
db - database to copy entries from.