de.tudarmstadt.ukp.jwktl.api.entry
Class WiktionaryEdition

java.lang.Object
  extended by de.tudarmstadt.ukp.jwktl.api.entry.AbstractWiktionary
      extended by de.tudarmstadt.ukp.jwktl.api.entry.WiktionaryEdition
All Implemented Interfaces:
IWiktionary, IWiktionaryEdition
Direct Known Subclasses:
BerkeleyDBWiktionaryEdition

public abstract class WiktionaryEdition
extends AbstractWiktionary
implements IWiktionaryEdition

Abstract base class for implementations of IWiktionaryEditions.

Author:
Christian M. Meyer

Field Summary
protected  boolean isClosed
           
 
Constructor Summary
WiktionaryEdition()
          Initializes the Wiktionary edition.
 
Method Summary
 void close()
          Disconnects from the database.
protected abstract  void doClose()
           
protected  void ensureOpen()
           
 IWiktionaryIterator<IWiktionaryEntry> getAllEntries(IWiktionaryEntryFilter filter, boolean sortByTitle, boolean normalize)
          Returns an iterator over all IWiktionaryEntrys within the Wiktionary edition.
 IWiktionaryIterator<IWiktionarySense> getAllSenses(IWiktionarySenseFilter filter, boolean sortByTitle, boolean normalize)
          Returns an iterator over all IWiktionaryEntrys within the Wiktionary edition.
 List<IWiktionaryEntry> getEntriesForWord(String word, IWiktionaryEntryFilter filter, boolean normalize)
          Returns a list of IWiktionaryEntrys encoded on a page with the given title.
 IWiktionaryEntry getEntryForId(long pageId, int entryIdx)
          Returns the IWiktionaryEntry with the given page id and entry index.
 IWiktionaryEntry getEntryForWord(String word, int entryIdx)
          Returns the IWiktionaryEntry encoded on a page with the given title and being part of an entry with the specified entry index.
 IWiktionarySense getSenseForId(long entryId, int senseIdx)
          Returns the word sense with the given entry id and sense index.
 IWiktionarySense getSenseForId(long pageId, int entryIdx, int senseIdx)
          Returns the word sense with the given page id, entry index, and sense index.
 List<IWiktionarySense> getSensesForWord(String word, int entryIdx)
          Returns a list of IWiktionarySenses encoded on a page with the given title and being part of an entry with the specified entry index.
 IWiktionarySense getSensesForWord(String word, int entryIdx, int senseIdx)
          Returns the IWiktionarySense encoded on the page with the given title and being part of the entry with the specified entry index at the specified sense index.
 List<IWiktionarySense> getSensesForWord(String word, IWiktionarySenseFilter filter, boolean normalize)
          Returns a list of IWiktionarySenses encoded on a page with the given title.
 boolean isClosed()
          Returns if the connection has already been closed.
 
Methods inherited from class de.tudarmstadt.ukp.jwktl.api.entry.AbstractWiktionary
getAllEntries, getAllEntries, getAllEntries, getAllEntries, getAllEntries, getAllPages, getAllPages, getAllPages, getAllPages, getAllPages, getAllPages, getAllSenses, getAllSenses, getAllSenses, getAllSenses, getAllSenses, getEntriesForWord, getEntriesForWord, getEntriesForWord, getPagesForWord, getPagesForWord, getSensesForWord, getSensesForWord, getSensesForWord
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.tudarmstadt.ukp.jwktl.api.IWiktionaryEdition
getDBPath, getEntryForId, getLanguage, getPageForId, getPageForWord, getSenseForKey
 
Methods inherited from interface de.tudarmstadt.ukp.jwktl.api.IWiktionary
getAllEntries, getAllEntries, getAllEntries, getAllEntries, getAllEntries, getAllPages, getAllPages, getAllPages, getAllPages, getAllPages, getAllPages, getAllSenses, getAllSenses, getAllSenses, getAllSenses, getAllSenses, getEntriesForWord, getEntriesForWord, getEntriesForWord, getPagesForWord, getPagesForWord, getSensesForWord, getSensesForWord, getSensesForWord
 

Field Detail

isClosed

protected boolean isClosed
Constructor Detail

WiktionaryEdition

public WiktionaryEdition()
Initializes the Wiktionary edition.

Method Detail

getEntryForId

public IWiktionaryEntry getEntryForId(long pageId,
                                      int entryIdx)
Description copied from interface: IWiktionaryEdition
Returns the IWiktionaryEntry with the given page id and entry index. Note that this id combination is only stable over the same XML dump and JWKTL version.

Specified by:
getEntryForId in interface IWiktionaryEdition

getEntryForWord

public IWiktionaryEntry getEntryForWord(String word,
                                        int entryIdx)
Description copied from interface: IWiktionaryEdition
Returns the IWiktionaryEntry encoded on a page with the given title and being part of an entry with the specified entry index. The method only returns the entries if the page title matches exactly.

Specified by:
getEntryForWord in interface IWiktionaryEdition

getEntriesForWord

public List<IWiktionaryEntry> getEntriesForWord(String word,
                                                IWiktionaryEntryFilter filter,
                                                boolean normalize)
Description copied from interface: IWiktionary
Returns a list of IWiktionaryEntrys encoded on a page with the given title. Using the given IWiktionaryEntryFilter, unwanted entries can be ignored.

Specified by:
getEntriesForWord in interface IWiktionary
Specified by:
getEntriesForWord in class AbstractWiktionary
normalize - if true, match the page title in a case insensitive manner.

getAllEntries

public IWiktionaryIterator<IWiktionaryEntry> getAllEntries(IWiktionaryEntryFilter filter,
                                                           boolean sortByTitle,
                                                           boolean normalize)
Description copied from interface: IWiktionary
Returns an iterator over all IWiktionaryEntrys within the Wiktionary edition. This is equivalent to iterating over all pages using IWiktionary.getAllPages(boolean, boolean) and then over the page's entries using IWiktionaryPage.getEntries(). The pages are sorted according to the method's parameters; the entries are sorted by their index. Using the given IWiktionaryEntryFilter, unwanted entries can be ignored.

Specified by:
getAllEntries in interface IWiktionary
Specified by:
getAllEntries in class AbstractWiktionary
sortByTitle - if true sort by page title; otherwise by page id.
normalize - if true sort case insensitive; otherwise case sensitive (only affects sorting by title).

getSenseForId

public IWiktionarySense getSenseForId(long entryId,
                                      int senseIdx)
Description copied from interface: IWiktionaryEdition
Returns the word sense with the given entry id and sense index. Note that this id combination is only stable over the same XML dump and JWKTL version.

Specified by:
getSenseForId in interface IWiktionaryEdition

getSenseForId

public IWiktionarySense getSenseForId(long pageId,
                                      int entryIdx,
                                      int senseIdx)
Description copied from interface: IWiktionaryEdition
Returns the word sense with the given page id, entry index, and sense index. Note that this id combination is only stable over the same XML dump and JWKTL version.

Specified by:
getSenseForId in interface IWiktionaryEdition

getSensesForWord

public List<IWiktionarySense> getSensesForWord(String word,
                                               int entryIdx)
Description copied from interface: IWiktionaryEdition
Returns a list of IWiktionarySenses encoded on a page with the given title and being part of an entry with the specified entry index. The method only returns the senses if the page title matches exactly.

Specified by:
getSensesForWord in interface IWiktionaryEdition

getSensesForWord

public IWiktionarySense getSensesForWord(String word,
                                         int entryIdx,
                                         int senseIdx)
Description copied from interface: IWiktionaryEdition
Returns the IWiktionarySense encoded on the page with the given title and being part of the entry with the specified entry index at the specified sense index. The method only returns the sense if the page title matches exactly.

Specified by:
getSensesForWord in interface IWiktionaryEdition

getSensesForWord

public List<IWiktionarySense> getSensesForWord(String word,
                                               IWiktionarySenseFilter filter,
                                               boolean normalize)
Description copied from interface: IWiktionary
Returns a list of IWiktionarySenses encoded on a page with the given title. Using the given IWiktionarySenseFilter, unwanted word senses can be ignored.

Specified by:
getSensesForWord in interface IWiktionary
Specified by:
getSensesForWord in class AbstractWiktionary
normalize - if true, match the page title in a case insensitive manner.

getAllSenses

public IWiktionaryIterator<IWiktionarySense> getAllSenses(IWiktionarySenseFilter filter,
                                                          boolean sortByTitle,
                                                          boolean normalize)
Description copied from interface: IWiktionary
Returns an iterator over all IWiktionaryEntrys within the Wiktionary edition. This is equivalent to iterating over all pages using IWiktionary.getAllPages(boolean, boolean) and then over the page's entries using IWiktionaryPage.getEntries() and then over the entry's senses using IWiktionaryEntry.getSenses(). The pages are sorted according to the method's parameters; the entries and senses are sorted by their index. Using the given IWiktionarySenseFilter, unwanted word senses can be ignored.

Specified by:
getAllSenses in interface IWiktionary
Specified by:
getAllSenses in class AbstractWiktionary
sortByTitle - if true sort by page title; otherwise by page id.
normalize - if true sort case insensitive; otherwise case sensitive (only affects sorting by title).

close

public void close()
Disconnects from the database. This is necessary to ensure the consistency of the data. No retrieval methods can be called after closing the connection, so this should be done prior to terminating the application. Nothing happens on calling the method more than once.

Specified by:
close in interface IWiktionary

isClosed

public boolean isClosed()
Returns if the connection has already been closed. If so, no retrieval method can be called anymore. To close an open connection, use the close() method.

Specified by:
isClosed in interface IWiktionary

doClose

protected abstract void doClose()

ensureOpen

protected void ensureOpen()
Throws:
IllegalStateException - if the connection has already been closed. This method is to be called from each retrieval method.


Copyright © 2011-2013 Ubiquitous Knowledge Processing (UKP) Lab. All Rights Reserved.