dkpro / dkpro-jwktl

Java Wiktionary Library
http://dkpro.org/dkpro-jwktl/
Apache License 2.0
57 stars 26 forks source link

Can't connect to Database #33

Closed tschaefermedia closed 8 years ago

tschaefermedia commented 8 years ago

Hallo,

I can't figure out where I'm wrong, I used the "tutorial" on https://dkpro.github.io/dkpro-jwktl/documentation/getting-started/

My code is very simple:

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();
}
}

But the line: IWiktionaryEdition wkt = JWKTL.openEdition(TARGET_DIRECTORY); throws an error: The method openEdition(File) in the type JWKTL is not applicable for the arguments (String), when I try to enter the dump_file as

java.io.File the program throws the following error:

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

Can someone show me where I'm wrong, or take it as issue. 
I use these libs:

- jwktl-1.0.1.jar
- je-6.4.25.jar
- apache-ant-1.8.2.jar

Thank you!
tschaefermedia commented 8 years ago

# ADD:

The wiktionary.properties file entries are:

# JWKTL 1.0.1 parsed dump file.

wiktionary.language=eng
wiktionary.dumpfile=\GetWords\enwiktionary-20160601-pages-articles-multistream.xml

database.creation=2016-06-15 23:59
database.path=\GetWords
database.pages=4740505
database.entries=5351939
database.sense=12461749

jwktl.version=1.0.1
jwktl.parser_1=de.tudarmstadt.ukp.jwktl.parser.WiktionaryArticleParser
tschaefermedia commented 8 years ago

I solved it... It was too simple:

The sulution is:

File f = new File(TARGET_DIRECTORY);

IWiktionaryEdition wkt = JWKTL.openEdition(f);

Best regards!

chmeyer commented 8 years ago

Glad you found it out so fast! Changed the getting started page to make things more smoothly next time.

black13 commented 6 years ago

what wiktionary files have to be downloaded to be used with this example? specifically what German wiktionary files.

tschaefermedia commented 6 years ago

It was one year ago... I can't tell you anymore. I closed this project for me after some tests due to problems I faced with the underlying idea I had planned. Sorry, I can't help you there.

chmeyer commented 6 years ago

You need a pages-articles dump. For German, use, for example, dewiktionary-20171201-pages-articles.xml.bz2 from http://ftp.acc.umu.se/mirror/wikimedia.org/dumps/dewiktionary/20171201/