Class WiktionaryIndex
java.lang.Object
org.getalp.wiktionary.WiktionaryIndex
- All Implemented Interfaces:
WiktionaryPageSource
WiktionaryIndex is a Persistent HashMap designed to hold an index on a Wiktionary dump file.
- Author:
- serasset
-
Constructor Summary
ConstructorsConstructorDescriptionWiktionaryIndex(Path dump) Creates a WiktionaryIndex for the wiktionary dump whose path is passed as a parameter.WiktionaryIndex(Path dump, String lang, boolean fillMissingPages) Creates a WiktionaryIndex for the wiktionary dump whose path is passed as a parameter. -
Method Summary
Modifier and TypeMethodDescriptionstatic PathapiCacheFile(Path dump) returns Path of the persisted live-API fallback cache file corresponding to passed dump.voidclose()Free resource taken by the index.getFullXmlForPage(String key) getTextOfPage(String key) static Pathreturns Path of the index file corresponding to passed dump.
-
Constructor Details
-
WiktionaryIndex
Creates a WiktionaryIndex for the wiktionary dump whose path is passed as a parameter. The live MediaWiki API fallback is disabled.- Parameters:
dump- the path to file containing the wiktionary dump.- Throws:
WiktionaryIndexerException- thrown if any error occur during index initialization
-
WiktionaryIndex
public WiktionaryIndex(Path dump, String lang, boolean fillMissingPages) throws WiktionaryIndexerException Creates a WiktionaryIndex for the wiktionary dump whose path is passed as a parameter.MediaWiki's XML export is known to occasionally omit pages that do exist on the live wiki. If
fillMissingPagesis set, a title missing from the dump index is looked up on the live MediaWiki API instead of being reported as non existent; the outcome (found or confirmed missing) is cached in a file next to the dump so a title is never queried more than once, across runs.- Parameters:
dump- the path to file containing the wiktionary dump.lang- the language edition of the dump (used to reach the corresponding wiktionary API whenfillMissingPagesis set); may benulliffillMissingPagesisfalse.fillMissingPages- whether to fall back to the live MediaWiki API for titles missing from the dump.- Throws:
WiktionaryIndexerException- thrown if any error occur during index initialization
-
-
Method Details
-
indexFile
-
apiCacheFile
-
close
public void close()Free resource taken by the index. -
get
-
getTextOfPageWithRedirects
- Specified by:
getTextOfPageWithRedirectsin interfaceWiktionaryPageSource
-
getTextOfPage
- Specified by:
getTextOfPagein interfaceWiktionaryPageSource
-
getFullXmlForPage
- Specified by:
getFullXmlForPagein interfaceWiktionaryPageSource
-