textmaven.dictionaries
Class LuceneDictionary

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

public class LuceneDictionary
extends Dictionary
implements IModifiableDictionary

Author:
Peter Kolloch

Field Summary
static org.apache.lucene.analysis.Analyzer ANALYZER
           
static java.lang.String KEYWORD
          Lucene field used for the keyword of a word.
static java.lang.String MEANING
          Lucene field used for the meaning number of a word.
static java.lang.String SOURCE
          Lucene field used for the source of a word.
static java.lang.String STEM
          Lucene field used for the stemmed keyword of a word.
static java.lang.String TRANSLATION
          Lucene field used for the translation of a word.
 
Constructor Summary
LuceneDictionary()
           
 
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 getFile()
           
 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
static void main(java.lang.String[] args)
           
 DoublyLinkedList matchPrefix(java.lang.String prefix)
          This is quite slow!!!
 void open()
          Opens connection to datasource
 void setFile(java.lang.String fileBaseName)
           
 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)
           
 
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

KEYWORD

public static final java.lang.String KEYWORD
Lucene field used for the keyword of a word.

See Also:
Translation.getKey(), Constant Field Values

STEM

public static final java.lang.String STEM
Lucene field used for the stemmed keyword of a word.

See Also:
Constant Field Values

MEANING

public static final java.lang.String MEANING
Lucene field used for the meaning number of a word. This is used to number multiple translations of one keyword. It is always the String representation of a natural number, e.g. 0, 1, ...

See Also:
Constant Field Values

TRANSLATION

public static final java.lang.String TRANSLATION
Lucene field used for the translation of a word.

See Also:
Translation.getTranslation(), Constant Field Values

SOURCE

public static final java.lang.String SOURCE
Lucene field used for the source of a word.

See Also:
Translation.getSource(), Constant Field Values

ANALYZER

public static final org.apache.lucene.analysis.Analyzer ANALYZER
Constructor Detail

LuceneDictionary

public LuceneDictionary()
Method Detail

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
See Also:
IDictionary.translations()

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

write

public void write(Translation t)
Specified by:
write in interface IDictionaryWriter

getFile

public java.lang.String getFile()
Returns:
Returns the fileBaseName.

setFile

public void setFile(java.lang.String fileBaseName)
Parameters:
fileBaseName - The fileBaseName to set.

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
See Also:
IBaseDictionary.open()

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
See Also:
IBaseDictionary.close()

matchPrefix

public DoublyLinkedList matchPrefix(java.lang.String prefix)
This is quite slow!!! [compared to in-memory index]

See Also:
IDictionary.keysWithPrefix(java.lang.String)

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception


Copyright © 2002-2005 Sourceforge. All Rights Reserved.