Skip to content

Commit

Permalink
Merged with v1.2.6 and up to Jena3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
TortugaAttack committed Mar 2, 2018
2 parents 87901c8 + 52833d5 commit a14b330
Show file tree
Hide file tree
Showing 54 changed files with 2,493 additions and 1,246 deletions.
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<junit.version>4.11</junit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>3.2.17.RELEASE</spring.version>
<jena.version>2.13.0</jena.version>
<jena.version>3.1.0</jena.version>
<jsonld-java-jena.version>0.4.1</jsonld-java-jena.version>
</properties>

Expand Down Expand Up @@ -53,11 +53,6 @@

<dependencies>
<!-- NIF transfer lib -->
<dependency>
<groupId>org.aksw</groupId>
<artifactId>gerbil.nif.transfer</artifactId>
<version>1.2.3</version>
</dependency>
<!-- Jena for using JSON-LD -->
<dependency>
<groupId>org.apache.jena</groupId>
Expand Down Expand Up @@ -316,6 +311,11 @@
<artifactId>lucene-analyzers-common</artifactId>
<version>6.2.0</version>
</dependency>
<dependency>
<groupId>org.aksw</groupId>
<artifactId>gerbil.nif.transfer</artifactId>
<version>1.2.5-jena3.1-SNAPSHOT</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
<groups>
<group>
<title>SPARQL Query and Update</title>
<packages>com.hp.hpl.jena.query:com.hp.hpl.jena.update</packages>
<packages>org.apache.jena.query:org.apache.jena.update</packages>
</group>
<group>
<title>RIOT</title>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,23 +145,23 @@
<windowtitle>Apache Jena</windowtitle>
<doctitle>Apache Jena Core ${project.version}</doctitle>
<bottom>Licenced under the Apache License, Version 2.0</bottom>
<excludePackageNames>com.hp.hpl.jena.shared.*:*.impl:com.hp.hpl.jena.assembler.assemblers:*.exceptions:*.regexptrees:com.hp.hpl.jena.mem:com.hp.hpl.jena.mem.*:com.hp.hpl.jena.n3:com.hp.hpl.jena.n3.*:com.hp.hpl.jena.rdf.arp.*:com.hp.hpl.jena.util.*:jena.cmdline:jena.util</excludePackageNames>
<excludePackageNames>org.apache.jena.shared.*:*.impl:org.apache.jena.assembler.assemblers:*.exceptions:*.regexptrees:org.apache.jena.mem:org.apache.jena.mem.*:org.apache.jena.n3:org.apache.jena.n3.*:org.apache.jena.rdf.arp.*:org.apache.jena.util.*:jena.cmdline:jena.util</excludePackageNames>
<groups>
<group>
<title>API - Application Programming Interface</title>
<packages>com.hp.hpl.jena.db:com.hp.hpl.jena.rdf.model:com.hp.hpl.jena.rdf.listeners:com.hp.hpl.jena.rdf.arp:com.hp.hpl.jena.rdf.arp.lang:com.hp.hpl.jena.datatypes:com.hp.hpl.jena.datatypes.xsd:com.hp.hpl.jena.rdql:com.hp.hpl.jena.shared:com.hp.hpl.jena.vocabulary:com.hp.hpl.jena.xmloutput:com.hp.hpl.jena.ontology:com.hp.hpl.jena.ontology.daml:com.hp.hpl.jena.reasoner:com.hp.hpl.jena.reasoner.rulesys:com.hp.hpl.jena.reasoner.rulesys.builtins:com.hp.hpl.jena.reasoner.transitiveReasoner:com.hp.hpl.jena.reasoner.dig</packages>
<packages>org.apache.jena.db:org.apache.jena.rdf.model:org.apache.jena.rdf.listeners:org.apache.jena.rdf.arp:org.apache.jena.rdf.arp.lang:org.apache.jena.datatypes:org.apache.jena.datatypes.xsd:org.apache.jena.rdql:org.apache.jena.shared:org.apache.jena.vocabulary:org.apache.jena.xmloutput:org.apache.jena.ontology:org.apache.jena.ontology.daml:org.apache.jena.reasoner:org.apache.jena.reasoner.rulesys:org.apache.jena.reasoner.rulesys.builtins:org.apache.jena.reasoner.transitiveReasoner:org.apache.jena.reasoner.dig</packages>
</group>
<group>
<title>SPI - System Programming Interface</title>
<packages>com.hp.hpl.jena.enhanced:com.hp.hpl.jena.graph:com.hp.hpl.jena.graph.compose:com.hp.hpl.jena.graph.query:com.hp.hpl.jena.util:com.hp.hpl.jena.util.iterator</packages>
<packages>org.apache.jena.enhanced:org.apache.jena.graph:org.apache.jena.graph.compose:org.apache.jena.graph.query:org.apache.jena.util:org.apache.jena.util.iterator</packages>
</group>
<group>
<title>Command line tools</title>
<packages>jena</packages>
</group>
<group>
<title>Other Packages</title>
<packages>com.hp.hpl.jena.assembler</packages>
<packages>org.apache.jena.assembler</packages>
</group>
</groups>
</configuration>
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/org/aksw/gerbil/annotator/OKE2018Task4Annotator.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.Marking;

public interface OKE2018Task4Annotator extends REAnnotator, A2KBAnnotator {

public List<Marking> performOKE2018Task4(Document document) throws GerbilException;
}
29 changes: 29 additions & 0 deletions src/main/java/org/aksw/gerbil/annotator/REAnnotator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* 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.Relation;
import org.aksw.gerbil.transfer.nif.Span;

public interface REAnnotator extends Annotator {

public List<Relation> performRETask(Document document) throws GerbilException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
import org.aksw.gerbil.annotator.D2KBAnnotator;
import org.aksw.gerbil.annotator.EntityRecognizer;
import org.aksw.gerbil.annotator.EntityTyper;
import org.aksw.gerbil.annotator.OKE2018Task4Annotator;
import org.aksw.gerbil.annotator.OKETask1Annotator;
import org.aksw.gerbil.annotator.OKETask2Annotator;
import org.aksw.gerbil.annotator.REAnnotator;
import org.aksw.gerbil.annotator.RT2KBAnnotator;
import org.aksw.gerbil.datatypes.ErrorTypes;
import org.aksw.gerbil.datatypes.ExperimentType;
Expand All @@ -38,6 +40,7 @@
import org.aksw.gerbil.transfer.nif.Marking;
import org.aksw.gerbil.transfer.nif.Meaning;
import org.aksw.gerbil.transfer.nif.MeaningSpan;
import org.aksw.gerbil.transfer.nif.Relation;
import org.aksw.gerbil.transfer.nif.Span;
import org.aksw.gerbil.transfer.nif.TypedSpan;
import org.aksw.gerbil.transfer.nif.data.TypedNamedEntity;
Expand Down Expand Up @@ -85,6 +88,10 @@ public static ErrorCountingAnnotatorDecorator createDecorator(ExperimentType typ
return new ErrorCountingOKETask2Annotator((OKETask2Annotator) annotator, maxErrors);
case RT2KB:
return new ErrorCountingRT2KBAnnotator((RT2KBAnnotator) annotator, maxErrors);
case RE:
return new ErrorCountingREAnnotator((REAnnotator) annotator, maxErrors);
case OKE2018Task4:
return new ErrorCountingOKE2018Task4Annotator((OKE2018Task4Annotator) annotator, maxErrors);
case Rc2KB:
break;
case Sa2KB:
Expand Down Expand Up @@ -141,6 +148,59 @@ public List<Span> performRecognition(Document document) throws GerbilException {
}
}

private static class ErrorCountingOKE2018Task4Annotator extends ErrorCountingAnnotatorDecorator implements OKE2018Task4Annotator {

protected ErrorCountingOKE2018Task4Annotator(Annotator decoratedAnnotator, int maxErrors) {
super(decoratedAnnotator, maxErrors);
}

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

@Override
public List<Span> performRecognition(Document document) throws GerbilException {
return ErrorCountingAnnotatorDecorator.performRecognition(this, document);

}

@Override
public List<Marking> performOKE2018Task4(Document document) throws GerbilException {
return ErrorCountingAnnotatorDecorator.performOKE2018Task4(this, document);

}

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

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

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

}

private static class ErrorCountingREAnnotator extends ErrorCountingAnnotatorDecorator implements REAnnotator {

protected ErrorCountingREAnnotator(Annotator decoratedAnnotator, int maxErrors) {
super(decoratedAnnotator, maxErrors);
}

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

}

private static class ErrorCountingA2KBAnnotator extends ErrorCountingD2KBAnnotator implements A2KBAnnotator {

public ErrorCountingA2KBAnnotator(A2KBAnnotator decoratedAnnotator, int maxErrors) {
Expand Down Expand Up @@ -247,7 +307,53 @@ protected static void logResult(List<? extends Marking> result, String annotator
LOGGER.debug(builder.toString());
}

protected static List<Meaning> performC2KB(ErrorCountingAnnotatorDecorator errorCounter, Document document)
public static List<Relation> performRE(ErrorCountingAnnotatorDecorator errorCounter,
Document document) throws GerbilException {
List<Relation> result = null;
try {
result = ((REAnnotator) errorCounter.getDecoratedAnnotator()).performRETask(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<Relation>(0);
}
if (printDebugMsg && LOGGER.isDebugEnabled()) {
logResult(result, errorCounter.getName(), "Relation");
}
return result;
}

public static List<Marking> performOKE2018Task4(ErrorCountingAnnotatorDecorator errorCounter,
Document document) throws GerbilException {
List<Marking> result = null;
try {
result = ((OKE2018Task4Annotator) errorCounter.getDecoratedAnnotator()).performOKE2018Task4(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<Marking>(0);
}
if (printDebugMsg && LOGGER.isDebugEnabled()) {
logResult(result, errorCounter.getName(), "Meaning");
}
return result;
}

protected static List<Meaning> performC2KB(ErrorCountingAnnotatorDecorator errorCounter, Document document)
throws GerbilException {
List<Meaning> result = null;
try {
Expand Down

0 comments on commit a14b330

Please sign in to comment.