textmaven.dictionaries
Class DBDictionary

java.lang.Object
  extended bytextmaven.dictionaries.BaseDictionary
      extended bytextmaven.dictionaries.Dictionary
          extended bytextmaven.dictionaries.DBDictionary
All Implemented Interfaces:
Globals, IBaseDictionary, IDictionary, IDictionarySource, IDictionaryWriter, IModifiableDictionary

public class DBDictionary
extends Dictionary
implements IModifiableDictionary, Globals

Implements a database backed dictionary. The current implementation is tested with MySQL. For supporting a different database it should be sufficient to overwrite the methods:

  • @see #getTranslationStatement()
  • @see #getLookupStatement()
  • @see #getWildcard()
  • Further the configuration has to be adapted appropriately.

    Author:
    krebtho

    Field Summary
    static java.lang.String[] NDX_DIR_LIST
               
     
    Fields inherited from interface textmaven.Globals
    C_ATTR_CLASSNAME, C_DICT_BASE_TYPE, C_DICT_TYPE, C_SERVER_BASE_TYPE, C_STEMMER_BASE_TYPE, C_WRITER_BASE_TYPE, CONFIG_FILE, DEFAULT_SENTENCES, DEFAULT_SEPARATOR, NEW_PARA, T_COL_DICTIONARY, T_COL_HOMONYMID, T_COL_ID, T_COL_LEXKEY, T_COL_TRANSLATION, T_COL_WORDCLASS, VERBOSE
     
    Constructor Summary
    DBDictionary()
              Constructor
     
    Method Summary
     void close()
              Performs close operations on the source.
     boolean containsKey(java.lang.String key)
              Checks whether a key is contained in the dictionary.
     java.lang.String getIndexFile()
               
     IDatabaseServer getServer()
              Gets server used when accessing the database.
     java.lang.String getTableName()
               
     boolean isAutoCommit()
               
     java.util.Iterator keys()
              Returns all keys as specified in dictionary.
     java.util.Iterator keysWithPrefix(java.lang.String prefix)
              Returns all keys starting with the specified prefix
     void open()
              Opens connection to datasource
     void setAutoCommit(java.lang.String autoCommit)
               
     void setIndexFile(java.lang.String indexFileName)
               
     void setServer(IDatabaseServer server)
              Sets server which is to be used for database lookups
     void setTableName(java.lang.String tableName)
               
     java.util.Iterator translations()
              Returns all translations available in the dictionary.
     java.util.Iterator translations(java.lang.String word)
              Retrieves available translations for a given word.
     void write(Translation t)
              Writes translation to database.
     
    Methods inherited from class textmaven.dictionaries.Dictionary
    getStemmer, keys, setStemmer
     
    Methods inherited from class textmaven.dictionaries.BaseDictionary
    getDescription, getId, getLanguage, setDescription, setId, setLanguage, toString
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
     
    Methods inherited from interface textmaven.dictionaries.IDictionary
    keys
     
    Methods inherited from interface textmaven.dictionaries.IBaseDictionary
    getDescription, getId, getLanguage, setDescription, setId, setLanguage
     

    Field Detail

    NDX_DIR_LIST

    public static final java.lang.String[] NDX_DIR_LIST
    Constructor Detail

    DBDictionary

    public DBDictionary()
    Constructor

    Method Detail

    getServer

    public IDatabaseServer getServer()
    Gets server used when accessing the database.

    Returns:
    Returns the server.

    setServer

    public void setServer(IDatabaseServer server)
    Sets server which is to be used for database lookups

    Parameters:
    server - The server to set.

    getIndexFile

    public java.lang.String getIndexFile()
    Returns:
    Returns the indexFileName.

    setIndexFile

    public void setIndexFile(java.lang.String indexFileName)
    Parameters:
    indexFileName - The indexFileName to set.

    getTableName

    public java.lang.String getTableName()
    Returns:
    Returns the tableName.

    setTableName

    public void setTableName(java.lang.String tableName)
    Parameters:
    tableName - The tableName to set.

    write

    public void write(Translation t)
    Writes translation to database. First an update is tried assuming that the entry already exists.

    Specified by:
    write in interface IDictionaryWriter
    See Also:
    IDictionaryWriter.write(textmaven.dictionaries.Translation)

    translations

    public java.util.Iterator translations(java.lang.String word)
    Description copied from interface: IDictionary
    Retrieves available translations for a given word.

    The word is retrieved from the dictionary as passed in as parameter. If no translation is found, an empty iterator.

    Specified by:
    translations in interface IDictionary
    Specified by:
    translations in class Dictionary

    translations

    public java.util.Iterator translations()
    Description copied from interface: IDictionary
    Returns all translations available in the dictionary.

    Specified by:
    translations in interface IDictionary
    Returns:
    Iterator returning translations Translation

    containsKey

    public boolean containsKey(java.lang.String key)
    Description copied from interface: IDictionary
    Checks whether a key is contained in the dictionary.

    Specified by:
    containsKey in interface IDictionary
    Specified by:
    containsKey in class Dictionary

    keys

    public java.util.Iterator keys()
    Description copied from interface: IDictionary
    Returns all keys as specified in dictionary.

    Specified by:
    keys in interface IDictionary
    Specified by:
    keys in class Dictionary

    keysWithPrefix

    public java.util.Iterator keysWithPrefix(java.lang.String prefix)
    Description copied from interface: IDictionary
    Returns all keys starting with the specified prefix

    Specified by:
    keysWithPrefix in interface IDictionary
    Parameters:
    prefix -
    Returns:
    Iterator returning all keys (String) starting with prefix

    open

    public void open()
    Description copied from interface: IBaseDictionary
    Opens connection to datasource

    Specified by:
    open in interface IBaseDictionary
    Specified by:
    open in class Dictionary

    close

    public void close()
    Description copied from interface: IBaseDictionary
    Performs close operations on the source. The source cannot be used after closing it.

    Specified by:
    close in interface IBaseDictionary
    Specified by:
    close in class Dictionary

    isAutoCommit

    public boolean isAutoCommit()
    Returns:
    Returns the autoCommit.

    setAutoCommit

    public void setAutoCommit(java.lang.String autoCommit)
    Parameters:
    autoCommit - The autoCommit to set.


    Copyright © 2002-2005 Sourceforge. All Rights Reserved.