-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged version1.2.5 into the master branch.
- Loading branch information
Showing
89 changed files
with
5,090 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,6 @@ gerbil_data | |
*.log | ||
google*.html | ||
export | ||
datadump.nt | ||
datadump.nt | ||
indexes | ||
dependency-reduced-pom.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/org/aksw/gerbil/annotator/RT2KBAnnotator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -52,8 +53,8 @@ | |
* @author Michael Röder ([email protected]) | ||
* | ||
*/ | ||
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); | ||
|
||
|
@@ -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: | ||
|
@@ -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); | ||
|
@@ -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); | ||
|
@@ -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); | ||
|
@@ -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); | ||
|
@@ -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; | ||
|
||
|
Oops, something went wrong.