0
我試圖將JWKTL庫安裝到Java項目中。 JWKTL Getting startedJWKTL - 無法連接到數據庫
現在我按照說明下載了轉儲文件,並將其解析到一個新的目錄中。
我的代碼是:
package main;
import java.io.File;
import java.util.List;
import de.tudarmstadt.ukp.jwktl.JWKTL;
import de.tudarmstadt.ukp.jwktl.api.IWiktionaryEdition;
import de.tudarmstadt.ukp.jwktl.api.IWiktionaryEntry;
import de.tudarmstadt.ukp.jwktl.api.IWiktionaryPage;
import de.tudarmstadt.ukp.jwktl.api.IWiktionaryRelation;
import de.tudarmstadt.ukp.jwktl.api.PartOfSpeech;
import de.tudarmstadt.ukp.jwktl.api.RelationType;
public class Main {
final static String PATH_TO_DUMP_FILE = "/GetWords/enwiktionary-20160601-pages-articles-multistream.xml";
final static String TARGET_DIRECTORY = "/GetWords/";
final static boolean OVERWRITE_EXISTING_FILES = true;
/**
* Simple example which parses an English dump file and prints the entries for the word <i>Wiktionary</i>
* @param args name of the dump file, output directory for parsed data, ISO language code of the Wiktionary entry language (en/de), boolean value that specifies if existing parsed data should be deleted
*/
public static void main(String[] args) throws Exception {
File dumpFile = new File(PATH_TO_DUMP_FILE);
File outputDirectory = new File(TARGET_DIRECTORY);
boolean overwriteExisting = OVERWRITE_EXISTING_FILES;
JWKTL.parseWiktionaryDump(dumpFile, outputDirectory, overwriteExisting);
IWiktionaryEdition wkt = JWKTL.openEdition(TARGET_DIRECTORY);
//TODO: Query the data you need.
// Close the database connection.
wkt.close();
}
}
但行:IWiktionaryEdition wkt = JWKTL.openEdition(TARGET_DIRECTORY);
拋出一個錯誤:The method openEdition(File) in the type JWKTL is not applicable for the arguments (String)
,當我試圖進入dump_file作爲 java.io.File的
該程序引發以下錯誤:
Exception in thread "main" de.tudarmstadt.ukp.jwktl.api.WiktionaryException: Unable to establish a db connection
at de.tudarmstadt.ukp.jwktl.api.entry.BerkeleyDBWiktionaryEdition.<init>(BerkeleyDBWiktionaryEdition.java:228)
at de.tudarmstadt.ukp.jwktl.api.entry.BerkeleyDBWiktionaryEdition.<init>(BerkeleyDBWiktionaryEdition.java:205)
at de.tudarmstadt.ukp.jwktl.JWKTL.openEdition(JWKTL.java:98)
at de.tudarmstadt.ukp.jwktl.JWKTL.openEdition(JWKTL.java:89)
at main.Main.main(Main.java:31)
Caused by: java.lang.IllegalArgumentException: Malformed \uxxxx encoding.
at java.util.Properties.loadConvert(Unknown Source)
at java.util.Properties.load0(Unknown Source)
at java.util.Properties.load(Unknown Source)
at com.sleepycat.je.dbi.DbConfigManager.applyFileConfig(DbConfigManager.java:388)
at com.sleepycat.je.Environment.setupHandleConfig(Environment.java:323)
at com.sleepycat.je.Environment.<init>(Environment.java:260)
at com.sleepycat.je.Environment.<init>(Environment.java:212)
at de.tudarmstadt.ukp.jwktl.api.entry.BerkeleyDBWiktionaryEdition.connect(BerkeleyDBWiktionaryEdition.java:241)
at de.tudarmstadt.ukp.jwktl.api.entry.BerkeleyDBWiktionaryEdition.<init>(BerkeleyDBWiktionaryEdition.java:224)
... 4 more
有沒有人知道如何解決這個問題?
我在Eclipse Mars中使用Java 8。
我安裝了這些庫:
- jwktl-1.0.1.jar
- JE-6.4.25.jar
- Apache的ANT-1.8.2.jar
謝謝!