Skip to content

Commit

Permalink
Merged version1.2.5 into the master branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelRoeder committed Mar 2, 2017
2 parents a3ee71e + 07a2fe7 commit b3608fb
Show file tree
Hide file tree
Showing 89 changed files with 5,090 additions and 315 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ gerbil_data
*.log
google*.html
export
datadump.nt
datadump.nt
indexes
dependency-reduced-pom.xml
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ language: java
before_install:
- cp src/main/properties/log4j.properties src/test/resources/log4j.properties
- mkdir -p "gerbil_data"
- curl --retry 4 -L -o "gerbil_data/gerbil_data.zip" "https://github.com/AKSW/gerbil/releases/download/v1.2.4/gerbil_data.zip"
- curl --retry 4 -L -o "gerbil_data/gerbil_data.zip" "https://github.com/AKSW/gerbil/releases/download/v1.2.5/gerbil_data.zip"
- unzip "gerbil_data/gerbil_data.zip"
- touch src/main/properties/gerbil_keys.properties
install:
- mvn clean compile -DskipTests=true -Dmaven.javadoc.skip=true -B -V
script:
Expand Down
29 changes: 29 additions & 0 deletions index.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
mkdir dbpedia_dump
cd dbpedia_dump

wget -r --no-parent -R "*.txt, *.html, *.json" -A "*.nt, *.ttl, *.nt.bz2, *.ttl.bz2" http://downloads.dbpedia.org/2016-04/core-i18n/en/
cd downloads.dbpedia.org/2016-04/core-i18n/en/

wget http://www.l3s.de/~minack/rdf2rdf/downloads/rdf2rdf-1.0.1-2.3.1.jar


rm *.json
rm *.txt
rm index.html

for i in *.bz2; do
bzip2 -vd $i
done

for i in *.ttl; do
java -jar rdf2rdf-1.0.1-2.3.1.jar $i .nt
done

rm *.ttl
rm rdf2rdf-1.0.1-2.3.1.jar

cd ../../../../../../

mvn exec:java -Dexec.mainClass="org.aksw.gerbil.tools.InitialIndexTool" -Dexec.args="dbpedia_dump/downloads.dbpedia.org/2016-04/core-i18n/en/"

rm -rf dbpedia_dump/
15 changes: 10 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.aksw</groupId>
<artifactId>gerbil</artifactId>
<version>1.2.4</version>
<artifactId>gerbil</artifactId>
<version>1.2.5</version>
<name>General Entity Annotator Benchmark</name>
<description>This project is a benchmark for entity annotation and disambiguation tools.</description>
<inceptionYear>2014</inceptionYear>
Expand Down Expand Up @@ -55,8 +55,8 @@
<!-- NIF transfer lib -->
<dependency>
<groupId>org.aksw</groupId>
<artifactId>gerbil.nif.transfer</artifactId>
<version>1.2.2</version>
<artifactId>gerbil.nif.transfer</artifactId>
<version>1.2.3</version>
</dependency>
<!-- Jena for using JSON-LD -->
<dependency>
Expand Down Expand Up @@ -142,7 +142,7 @@
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>2.9.1</version>
<version>6.2.0</version>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
Expand Down Expand Up @@ -311,6 +311,11 @@
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<version>6.2.0</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.aksw.gerbil.transfer.nif.Document;
import org.aksw.gerbil.transfer.nif.data.TypedNamedEntity;

public interface OKETask1Annotator extends A2KBAnnotator, EntityTyper {
public interface OKETask1Annotator extends A2KBAnnotator, RT2KBAnnotator {

public List<TypedNamedEntity> performTask1(Document document) throws GerbilException;
}
28 changes: 28 additions & 0 deletions src/main/java/org/aksw/gerbil/annotator/RT2KBAnnotator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* This file is part of General Entity Annotator Benchmark.
*
* General Entity Annotator Benchmark is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* General Entity Annotator Benchmark is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with General Entity Annotator Benchmark. If not, see <http://www.gnu.org/licenses/>.
*/
package org.aksw.gerbil.annotator;

import java.util.List;

import org.aksw.gerbil.exceptions.GerbilException;
import org.aksw.gerbil.transfer.nif.Document;
import org.aksw.gerbil.transfer.nif.TypedSpan;

public interface RT2KBAnnotator extends EntityRecognizer, EntityTyper {

public List<TypedSpan> performRT2KBTask(Document document) throws GerbilException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.aksw.gerbil.annotator.EntityTyper;
import org.aksw.gerbil.annotator.OKETask1Annotator;
import org.aksw.gerbil.annotator.OKETask2Annotator;
import org.aksw.gerbil.annotator.RT2KBAnnotator;
import org.aksw.gerbil.datatypes.ErrorTypes;
import org.aksw.gerbil.datatypes.ExperimentType;
import org.aksw.gerbil.evaluate.EvaluationResultContainer;
Expand All @@ -52,8 +53,8 @@
* @author Michael R&ouml;der (roeder@informatik.uni-leipzig.de)
*
*/
public abstract class ErrorCountingAnnotatorDecorator extends AbstractAnnotatorDecorator
implements Evaluator<Marking>, ErrorCounter {
public abstract class ErrorCountingAnnotatorDecorator extends AbstractAnnotatorDecorator implements Evaluator<Marking>,
ErrorCounter {

private static final Logger LOGGER = LoggerFactory.getLogger(ErrorCountingAnnotatorDecorator.class);

Expand Down Expand Up @@ -82,6 +83,8 @@ public static ErrorCountingAnnotatorDecorator createDecorator(ExperimentType typ
return new ErrorCountingOKETask1Annotator((OKETask1Annotator) annotator, maxErrors);
case OKE_Task2:
return new ErrorCountingOKETask2Annotator((OKETask2Annotator) annotator, maxErrors);
case RT2KB:
return new ErrorCountingRT2KBAnnotator((RT2KBAnnotator) annotator, maxErrors);
case Rc2KB:
break;
case Sa2KB:
Expand Down Expand Up @@ -125,8 +128,8 @@ public List<MeaningSpan> performD2KBTask(Document document) throws GerbilExcepti
}
}

private static class ErrorCountingEntityRecognizer extends ErrorCountingAnnotatorDecorator
implements EntityRecognizer {
private static class ErrorCountingEntityRecognizer extends ErrorCountingAnnotatorDecorator implements
EntityRecognizer {

public ErrorCountingEntityRecognizer(EntityRecognizer decoratedAnnotator, int maxErrors) {
super(decoratedAnnotator, maxErrors);
Expand Down Expand Up @@ -173,8 +176,24 @@ public List<TypedSpan> performTyping(Document document) throws GerbilException {
}
}

private static class ErrorCountingOKETask1Annotator extends ErrorCountingA2KBAnnotator
implements OKETask1Annotator {
private static class ErrorCountingRT2KBAnnotator extends ErrorCountingEntityRecognizer implements RT2KBAnnotator {

protected ErrorCountingRT2KBAnnotator(RT2KBAnnotator decoratedAnnotator, int maxErrors) {
super(decoratedAnnotator, maxErrors);
}

@Override
public List<TypedSpan> performTyping(Document document) throws GerbilException {
return ErrorCountingAnnotatorDecorator.performTyping(this, document);
}

@Override
public List<TypedSpan> performRT2KBTask(Document document) throws GerbilException {
return ErrorCountingAnnotatorDecorator.performRT2KBTask(this, document);
}
}

private static class ErrorCountingOKETask1Annotator extends ErrorCountingA2KBAnnotator implements OKETask1Annotator {

protected ErrorCountingOKETask1Annotator(OKETask1Annotator decoratedAnnotator, int maxErrors) {
super(decoratedAnnotator, maxErrors);
Expand All @@ -185,14 +204,19 @@ public List<TypedSpan> performTyping(Document document) throws GerbilException {
return ErrorCountingAnnotatorDecorator.performTyping(this, document);
}

@Override
public List<TypedSpan> performRT2KBTask(Document document) throws GerbilException {
return ErrorCountingAnnotatorDecorator.performRT2KBTask(this, document);
}

@Override
public List<TypedNamedEntity> performTask1(Document document) throws GerbilException {
return ErrorCountingAnnotatorDecorator.performOKETask1(this, document);
}
}

private static class ErrorCountingOKETask2Annotator extends ErrorCountingAnnotatorDecorator
implements OKETask2Annotator {
private static class ErrorCountingOKETask2Annotator extends ErrorCountingAnnotatorDecorator implements
OKETask2Annotator {

protected ErrorCountingOKETask2Annotator(OKETask2Annotator decoratedAnnotator, int maxErrors) {
super(decoratedAnnotator, maxErrors);
Expand Down Expand Up @@ -269,8 +293,8 @@ protected static List<MeaningSpan> performD2KBTask(ErrorCountingAnnotatorDecorat
return result;
}

protected static List<MeaningSpan> performExtraction(ErrorCountingAnnotatorDecorator errorCounter,
Document document) throws GerbilException {
protected static List<MeaningSpan> performExtraction(ErrorCountingAnnotatorDecorator errorCounter, Document document)
throws GerbilException {
List<MeaningSpan> result = null;
try {
result = ((A2KBAnnotator) errorCounter.getDecoratedAnnotator()).performA2KBTask(document);
Expand Down Expand Up @@ -384,6 +408,29 @@ protected static List<TypedNamedEntity> performOKETask2(ErrorCountingAnnotatorDe
return result;
}

public static List<TypedSpan> performRT2KBTask(ErrorCountingAnnotatorDecorator errorCounter, Document document)
throws GerbilException {
List<TypedSpan> result = null;
try {
result = ((RT2KBAnnotator) errorCounter.getDecoratedAnnotator()).performRT2KBTask(document);
} catch (Exception e) {
if (errorCounter.getErrorCount() == 0) {
// Log only the first exception completely
LOGGER.error("Got an Exception from the annotator (" + errorCounter.getName() + ")", e);
} else {
// Log only the Exception message without the stack trace
LOGGER.error("Got an Exception from the annotator (" + errorCounter.getName() + "): "
+ e.getLocalizedMessage());
}
errorCounter.increaseErrorCount();
return new ArrayList<TypedSpan>(0);
}
if (printDebugMsg && LOGGER.isDebugEnabled()) {
logResult(result, errorCounter.getName(), "TypedNamedEntity");
}
return result;
}

protected int errorCount = 0;
protected int maxErrors;

Expand Down

0 comments on commit b3608fb

Please sign in to comment.