public class BerkeleyDBWiktionaryEdition extends WiktionaryEdition
IWiktionaryEdition
interface, which makes
use of a Berkeley DB to store and retrieve the parsed Wiktionary
information.Modifier and Type | Class and Description |
---|---|
static class |
BerkeleyDBWiktionaryEdition.WiktionaryEntryProxy
Proxy object for referencing to a
IWiktionaryEntry . |
static class |
BerkeleyDBWiktionaryEdition.WiktionarySenseProxy
Proxy object for referencing to a
IWiktionarySense . |
Modifier and Type | Field and Description |
---|---|
static String |
DATABASE_NAME
The internal name of the parsed Wiktionary database.
|
protected File |
dbPath |
protected com.sleepycat.persist.SecondaryIndex<Long,String,BerkeleyDBWiktionaryEdition.WiktionaryEntryProxy> |
entryById |
protected com.sleepycat.persist.PrimaryIndex<String,BerkeleyDBWiktionaryEdition.WiktionaryEntryProxy> |
entryByKey |
protected com.sleepycat.je.Environment |
env |
protected ILanguage |
language |
protected Set<com.sleepycat.persist.EntityCursor<?>> |
openCursors |
protected com.sleepycat.persist.PrimaryIndex<Long,WiktionaryPage> |
pageById |
protected com.sleepycat.persist.SecondaryIndex<String,Long,WiktionaryPage> |
pageByNormalizedTitle |
protected com.sleepycat.persist.SecondaryIndex<String,Long,WiktionaryPage> |
pageByTitle |
protected Properties |
properties |
static String |
PROPERTY_FILE_NAME
The name of the property file containing info about the parsed DB.
|
protected com.sleepycat.persist.PrimaryIndex<String,BerkeleyDBWiktionaryEdition.WiktionarySenseProxy> |
senseByKey |
protected com.sleepycat.persist.EntityStore |
store |
isClosed
Modifier | Constructor and Description |
---|---|
|
BerkeleyDBWiktionaryEdition(File dbPath)
Connects to the parsed Wiktionary contained in the specified directory.
|
protected |
BerkeleyDBWiktionaryEdition(File parsedWiktionaryDump,
boolean isReadOnly,
boolean allowCreateNew,
boolean overwriteExisting,
Long cacheSize)
Configures the database adapter and connects to the DB files at the
specified path.
|
|
BerkeleyDBWiktionaryEdition(File dbPath,
Long cacheSize)
Connects to the parsed Wiktionary contained in the specified directory.
|
Modifier and Type | Method and Description |
---|---|
protected void |
connect(boolean isReadOnly,
boolean allowCreateNew,
boolean overwriteExisting,
Long cacheSize) |
static void |
deleteParsedWiktionary(File targetDirectory)
Removes all files belonging to a previously parsed Wiktionary database
from the given target directory.
|
protected void |
doClose()
Hotspot for closing the connection.
|
WiktionaryIterator<IWiktionaryPage> |
getAllPages(IWiktionaryPageFilter filter,
boolean sortByTitle,
boolean normalize)
Returns an iterator over all
IWiktionaryPage s within
the Wiktionary edition. |
String |
getDBName()
Returns the internal name of the Berkeley DB.
|
File |
getDBPath()
Returns the file path of the parsed database.
|
IWiktionaryEntry |
getEntryForId(long entryId)
Returns the
IWiktionaryEntry with the given entry id. |
ILanguage |
getLanguage()
Returns the language of the Wiktionary edition, which is equivalent
to the entry language of the contained entries.
|
WiktionaryPage |
getPageForId(long id)
Returns the page with the given unique id.
|
WiktionaryPage |
getPageForWord(String word)
Returns the page with the given title.
|
List<IWiktionaryPage> |
getPagesForWord(String word,
IWiktionaryPageFilter filter,
boolean normalize)
Returns the page with the given title.
|
IWiktionarySense |
getSenseForKey(String key)
Returns the word sense with the given unique id.
|
protected WiktionaryPage |
loadPage(WiktionaryPage page,
IWiktionaryPageFilter filter) |
protected void |
prepareTargetDirectory(File targetDirectory,
boolean overwriteExisting)
Creates the given target dictionary if necessary.
|
close, ensureOpen, getAllEntries, getAllSenses, getEntriesForWord, getEntryForId, getEntryForWord, getSenseForId, getSenseForId, getSensesForWord, getSensesForWord, getSensesForWord, isClosed
getAllEntries, getAllEntries, getAllEntries, getAllEntries, getAllEntries, getAllPages, getAllPages, getAllPages, getAllPages, getAllPages, getAllSenses, getAllSenses, getAllSenses, getAllSenses, getAllSenses, getEntriesForWord, getEntriesForWord, getEntriesForWord, getPagesForWord, getSensesForWord, getSensesForWord, getSensesForWord
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAllEntries, getAllEntries, getAllEntries, getAllEntries, getAllEntries, getAllPages, getAllPages, getAllPages, getAllPages, getAllPages, getAllSenses, getAllSenses, getAllSenses, getAllSenses, getAllSenses, getEntriesForWord, getEntriesForWord, getEntriesForWord, getPagesForWord, getSensesForWord, getSensesForWord, getSensesForWord
public static final String DATABASE_NAME
public static final String PROPERTY_FILE_NAME
protected com.sleepycat.je.Environment env
protected com.sleepycat.persist.EntityStore store
protected File dbPath
protected Properties properties
protected ILanguage language
protected com.sleepycat.persist.PrimaryIndex<Long,WiktionaryPage> pageById
protected com.sleepycat.persist.SecondaryIndex<String,Long,WiktionaryPage> pageByTitle
protected com.sleepycat.persist.SecondaryIndex<String,Long,WiktionaryPage> pageByNormalizedTitle
protected com.sleepycat.persist.PrimaryIndex<String,BerkeleyDBWiktionaryEdition.WiktionaryEntryProxy> entryByKey
protected com.sleepycat.persist.SecondaryIndex<Long,String,BerkeleyDBWiktionaryEdition.WiktionaryEntryProxy> entryById
protected com.sleepycat.persist.PrimaryIndex<String,BerkeleyDBWiktionaryEdition.WiktionarySenseProxy> senseByKey
protected Set<com.sleepycat.persist.EntityCursor<?>> openCursors
public BerkeleyDBWiktionaryEdition(File dbPath)
dbPath
- the path of the database files.WiktionaryException
- if the connection could not
be established.public BerkeleyDBWiktionaryEdition(File dbPath, Long cacheSize)
dbPath
- the path of the database files.cacheSize
- the memory (in Bytes) that is used as database
cache, which can be used to speed up the DB access. Use
null as a default value.WiktionaryException
- if the connection could not
be established.protected BerkeleyDBWiktionaryEdition(File parsedWiktionaryDump, boolean isReadOnly, boolean allowCreateNew, boolean overwriteExisting, Long cacheSize)
parsedWiktionaryDump
- the path of the database files.isReadOnly
- controls write permissions on the DB files.allowCreateNew
- if true, a new DB will be created if none
exists at the specified path.cacheSize
- the memory (in Bytes) that is used as database
cache, which can be used to speed up the DB access. Use
null as a default value.WiktionaryException
- if the connection could not
be established.protected void connect(boolean isReadOnly, boolean allowCreateNew, boolean overwriteExisting, Long cacheSize) throws com.sleepycat.je.DatabaseException
com.sleepycat.je.DatabaseException
protected void prepareTargetDirectory(File targetDirectory, boolean overwriteExisting) throws WiktionaryException
WiktionaryException
- if the target dictionary is not empty
and overwriteExisting was set to false.public static void deleteParsedWiktionary(File targetDirectory)
public WiktionaryPage getPageForId(long id)
IWiktionaryEdition
public WiktionaryPage getPageForWord(String word)
IWiktionaryEdition
IWiktionary.getPagesForWord(String, boolean)
for case insensitive and
string-normalized matching.public List<IWiktionaryPage> getPagesForWord(String word, IWiktionaryPageFilter filter, boolean normalize)
IWiktionary
IWiktionaryPageFilter
, unwanted pages can be ignored.getPagesForWord
in interface IWiktionary
getPagesForWord
in class AbstractWiktionary
public WiktionaryIterator<IWiktionaryPage> getAllPages(IWiktionaryPageFilter filter, boolean sortByTitle, boolean normalize)
IWiktionary
IWiktionaryPage
s within
the Wiktionary edition. Using the given IWiktionaryPageFilter
,
unwanted pages can be ignored.getAllPages
in interface IWiktionary
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).protected WiktionaryPage loadPage(WiktionaryPage page, IWiktionaryPageFilter filter)
public IWiktionaryEntry getEntryForId(long entryId)
IWiktionaryEdition
IWiktionaryEntry
with the given entry id. Note
that this id is only stable over the same XML dump and JWKTL version.public IWiktionarySense getSenseForKey(String key)
IWiktionaryEdition
public String getDBName()
public File getDBPath()
IWiktionaryEdition
public ILanguage getLanguage()
IWiktionaryEdition
protected void doClose()
doClose
in class WiktionaryEdition
WiktionaryException
- if the connection could not be closed.Copyright © 2011-2016 Ubiquitous Knowledge Processing (UKP) Lab. All Rights Reserved.