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

java.lang.Object
  extended by de.tudarmstadt.ukp.jwktl.api.entry.AbstractWiktionary
      extended by de.tudarmstadt.ukp.jwktl.api.entry.WiktionaryCollection
All Implemented Interfaces:
IWiktionary, IWiktionaryCollection

public class WiktionaryCollection
extends AbstractWiktionary
implements IWiktionaryCollection

Default implementation of the IWiktionaryCollection interface. The implementation can be initialized with multiple IWiktionaryEditions in order to access parsed Wiktionary information of multiple language editions.

Author:
Christian M. Meyer

Field Summary
protected  List<IWiktionaryEdition> editions
           
 
Constructor Summary
WiktionaryCollection()
          Initializes the Wiktionary collection.
 
Method Summary
 void addEdition(IWiktionaryEdition edition)
          Add the specified Wiktionary language edition to the current collection.
 void close()
          Disconnects from the database.
 IWiktionaryIterator<IWiktionaryEntry> getAllEntries(IWiktionaryEntryFilter filter, boolean sortByTitle, boolean normalize)
          Returns an iterator over all IWiktionaryEntrys within the Wiktionary edition.
 IWiktionaryIterator<IWiktionaryPage> getAllPages(IWiktionaryPageFilter filter, boolean sortByTitle, boolean normalize)
          Returns an iterator over all IWiktionaryPages within the Wiktionary edition.
 IWiktionaryIterator<IWiktionarySense> getAllSenses(IWiktionarySenseFilter filter, boolean sortByTitle, boolean normalize)
          Returns an iterator over all IWiktionaryEntrys within the Wiktionary edition.
 Iterable<IWiktionaryEdition> getEditions()
          Returns a list of all Wiktionary langauge editions in this collection.
 List<IWiktionaryEntry> getEntriesForWord(String word, IWiktionaryEntryFilter filter, boolean normalize)
          Returns a list of IWiktionaryEntrys encoded on a page with the given title.
 IWiktionaryPage getPageForId(long id, ILanguage entryLanguage)
          Returns the page of the specified Wiktionary language edition with the given unique id.
 List<IWiktionaryPage> getPagesForId(long id)
          Returns the pages with the given (edition-specific) unique id.
 List<IWiktionaryPage> getPagesForWord(String word)
          Returns all pages with the given title.
 List<IWiktionaryPage> getPagesForWord(String word, IWiktionaryPageFilter filter)
          Returns all pages with the given title.
 List<IWiktionaryPage> getPagesForWord(String word, IWiktionaryPageFilter filter, boolean normalize)
          Returns the page with the given title.
 IWiktionarySense getSenseForKey(String key, ILanguage language)
          Returns the word sense with the given (edition-specific) unique id.
 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 true if the database connection has already been closed using the IWiktionary.close() method.
 void removeEdition(IWiktionaryEdition edition)
          Removes the specified edition from the collection.
 
Methods inherited from class de.tudarmstadt.ukp.jwktl.api.entry.AbstractWiktionary
getAllEntries, getAllEntries, getAllEntries, getAllEntries, getAllEntries, getAllPages, getAllPages, getAllPages, getAllPages, getAllPages, getAllSenses, getAllSenses, getAllSenses, getAllSenses, getAllSenses, getEntriesForWord, getEntriesForWord, getEntriesForWord, 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.IWiktionary
getAllEntries, getAllEntries, getAllEntries, getAllEntries, getAllEntries, getAllPages, getAllPages, getAllPages, getAllPages, getAllPages, getAllSenses, getAllSenses, getAllSenses, getAllSenses, getAllSenses, getEntriesForWord, getEntriesForWord, getEntriesForWord, getPagesForWord, getSensesForWord, getSensesForWord, getSensesForWord
 

Field Detail

editions

protected List<IWiktionaryEdition> editions
Constructor Detail

WiktionaryCollection

public WiktionaryCollection()
Initializes the Wiktionary collection.

Method Detail

addEdition

public void addEdition(IWiktionaryEdition edition)
Description copied from interface: IWiktionaryCollection
Add the specified Wiktionary language edition to the current collection. Querying the collection will then aggregate information from all added editions.

Specified by:
addEdition in interface IWiktionaryCollection

getEditions

public Iterable<IWiktionaryEdition> getEditions()
Description copied from interface: IWiktionaryCollection
Returns a list of all Wiktionary langauge editions in this collection.

Specified by:
getEditions in interface IWiktionaryCollection

removeEdition

public void removeEdition(IWiktionaryEdition edition)
Description copied from interface: IWiktionaryCollection
Removes the specified edition from the collection. Note that the removed edition is still open. If you do not need it anymore, call additionally the IWiktionary.close() method.

Specified by:
removeEdition in interface IWiktionaryCollection

getPagesForId

public List<IWiktionaryPage> getPagesForId(long id)
Description copied from interface: IWiktionaryCollection
Returns the pages with the given (edition-specific) unique id.

Specified by:
getPagesForId in interface IWiktionaryCollection

getPageForId

public IWiktionaryPage getPageForId(long id,
                                    ILanguage entryLanguage)
Description copied from interface: IWiktionaryCollection
Returns the page of the specified Wiktionary language edition with the given unique id.

Specified by:
getPageForId in interface IWiktionaryCollection

getPagesForWord

public List<IWiktionaryPage> getPagesForWord(String word)
Description copied from interface: IWiktionaryCollection
Returns all pages with the given title. The method only returns the page if its title matches exactly. Use IWiktionary.getPagesForWord(String, boolean) for case insensitive and string-normalized matching.

Specified by:
getPagesForWord in interface IWiktionaryCollection

getPagesForWord

public List<IWiktionaryPage> getPagesForWord(String word,
                                             IWiktionaryPageFilter filter)
Description copied from interface: IWiktionaryCollection
Returns all pages with the given title. The method only returns the page if its title matches exactly. Use IWiktionary.getPagesForWord(String, boolean) for case insensitive and string-normalized matching. Using the given IWiktionaryPageFilter, unwanted pages can be ignored.

Specified by:
getPagesForWord in interface IWiktionaryCollection

getPagesForWord

public List<IWiktionaryPage> getPagesForWord(String word,
                                             IWiktionaryPageFilter filter,
                                             boolean normalize)
Description copied from interface: IWiktionary
Returns the page with the given title. The method returns also pages, whose title matches in a case insensitive or string-normalized manner. The latter means that strings are converted to lower case, and umlauts or accents are substituted by their canonical form. The word "prêt-à-porter" is, e.g., normalized to "pret-a-porter". Using the given IWiktionaryPageFilter, unwanted pages can be ignored.

Specified by:
getPagesForWord in interface IWiktionary
Specified by:
getPagesForWord in class AbstractWiktionary

getAllPages

public IWiktionaryIterator<IWiktionaryPage> getAllPages(IWiktionaryPageFilter filter,
                                                        boolean sortByTitle,
                                                        boolean normalize)
Description copied from interface: IWiktionary
Returns an iterator over all IWiktionaryPages within the Wiktionary edition. Using the given IWiktionaryPageFilter, unwanted pages can be ignored.

Specified by:
getAllPages in interface IWiktionary
Specified by:
getAllPages 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).

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).

getSenseForKey

public IWiktionarySense getSenseForKey(String key,
                                       ILanguage language)
Description copied from interface: IWiktionaryCollection
Returns the word sense with the given (edition-specific) unique id. Note that this id is only stable over the same XML dump and JWKTL version.

Specified by:
getSenseForKey in interface IWiktionaryCollection

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()
Description copied from interface: IWiktionary
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()
Description copied from interface: IWiktionary
Returns true if the database connection has already been closed using the IWiktionary.close() method.

Specified by:
isClosed in interface IWiktionary


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