JWKTL - 无法连接到数据库
JWKTL - Can't connect to database
我正在尝试将 JWKTL 库安装到 Java 项目中。
JWKTL Getting started
现在我按照描述下载了转储文件,并将其解析到一个新目录中。
我的代码是:
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
谢谢!
我解决了...
太简单了:
解决方法是:
File f = new File(TARGET_DIRECTORY);
IWiktionaryEdition wkt = JWKTL.openEdition(f);
此致!
我正在尝试将 JWKTL 库安装到 Java 项目中。 JWKTL Getting started
现在我按照描述下载了转储文件,并将其解析到一个新目录中。
我的代码是:
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
谢谢!
我解决了... 太简单了:
解决方法是:
File f = new File(TARGET_DIRECTORY);
IWiktionaryEdition wkt = JWKTL.openEdition(f);
此致!