-
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.
Merge pull request #437 from dice-group/IndQNERDataset
added indqNER dataset
- Loading branch information
Showing
10 changed files
with
319 additions
and
157 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
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
38 changes: 38 additions & 0 deletions
38
src/main/java/org/aksw/gerbil/dataset/impl/indqner/IndQNERDataset.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,38 @@ | ||
package org.aksw.gerbil.dataset.impl.indqner; | ||
|
||
import org.aksw.gerbil.dataset.impl.conll.CoNLLTypeRetriever; | ||
import org.aksw.gerbil.dataset.impl.conll.GenericCoNLLDataset; | ||
|
||
/** | ||
* Implementation of the IndQNERDataset class, which represents an | ||
* InitializableDataset for the IndQNER dataset. | ||
* | ||
* @author Neha | ||
* @author Michael Röder ([email protected]) | ||
* | ||
*/ | ||
public class IndQNERDataset extends GenericCoNLLDataset { | ||
|
||
private static final int ANNOTATION_COLUMN = 1; | ||
private static final int URI_COLUMN = -1; | ||
private static final CoNLLTypeRetriever TYPE_TAGS = new CoNLLTypeRetriever("GeographicalLocation", null, null, null, | ||
null, "Person", null, null, null, null); | ||
|
||
public IndQNERDataset(String file) { | ||
super(file, ANNOTATION_COLUMN, URI_COLUMN, TYPE_TAGS); | ||
TYPE_TAGS.addTypeURI("AfterlifeLocation", "https://corpus.quran.com/concept.jsp?id=afterlife-location"); | ||
TYPE_TAGS.addTypeURI("Allah", "https://corpus.quran.com/concept.jsp?id=allah"); | ||
TYPE_TAGS.addTypeURI("Angel", "https://github.com/dice-group/IndQNER/Angel"); // TODO: replace | ||
TYPE_TAGS.addTypeURI("Artifact", "https://corpus.quran.com/concept.jsp?id=artifact"); | ||
TYPE_TAGS.addTypeURI("AstronomicalBody", "https://corpus.quran.com/concept.jsp?id=astronomical-body"); | ||
TYPE_TAGS.addTypeURI("Color", "https://corpus.quran.com/concept.jsp?id=color"); | ||
TYPE_TAGS.addTypeURI("Event", "https://corpus.quran.com/concept.jsp?id=event"); | ||
TYPE_TAGS.addTypeURI("Food", "https://github.com/dice-group/IndQNER/Food"); // TODO: replace | ||
TYPE_TAGS.addTypeURI("HolyBook", "https://corpus.quran.com/concept.jsp?id=holy-book"); | ||
TYPE_TAGS.addTypeURI("Language", "https://corpus.quran.com/concept.jsp?id=language"); | ||
TYPE_TAGS.addTypeURI("Messenger", "https://github.com/dice-group/IndQNER/Messenger"); // TODO: replace | ||
TYPE_TAGS.addTypeURI("Prophet", "https://github.com/dice-group/IndQNER/Prophet"); // TODO: replace | ||
TYPE_TAGS.addTypeURI("Religion", "https://corpus.quran.com/concept.jsp?id=religion"); | ||
TYPE_TAGS.addTypeURI("Throne", "https://corpus.quran.com/concept.jsp?id=allah%27s-throne"); | ||
} | ||
} |
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
69 changes: 69 additions & 0 deletions
69
src/test/java/org/aksw/gerbil/dataset/impl/conll/AbstractGenericCoNLLDatasetTest.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,69 @@ | ||
/** | ||
* 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.dataset.impl.conll; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import org.aksw.gerbil.dataset.InitializableDataset; | ||
import org.aksw.gerbil.exceptions.GerbilException; | ||
import org.aksw.gerbil.transfer.nif.Document; | ||
import org.aksw.gerbil.transfer.nif.Marking; | ||
import org.apache.commons.io.FileUtils; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public abstract class AbstractGenericCoNLLDatasetTest { | ||
|
||
private String fileContent; | ||
private String text; | ||
private Marking expectedMarking; | ||
private int documentId; | ||
private int markingId; | ||
|
||
public AbstractGenericCoNLLDatasetTest(String fileContent, String text, Marking expectedMarking, int documentId, | ||
int markingId) { | ||
this.fileContent = fileContent; | ||
this.text = text; | ||
this.expectedMarking = expectedMarking; | ||
this.documentId = documentId; | ||
this.markingId = markingId; | ||
} | ||
|
||
@Test | ||
public void test() throws IOException, GerbilException { | ||
// Create temporary file with given text | ||
File file = File.createTempFile("test-dataset-", ".tsv"); | ||
FileUtils.write(file, fileContent); | ||
|
||
InitializableDataset dataset = createDataset(file); | ||
dataset.init(); | ||
List<Document> documents = dataset.getInstances(); | ||
Assert.assertNotNull(documents); | ||
Assert.assertTrue(documents.size() > documentId); | ||
Assert.assertEquals(text, documents.get(documentId).getText()); | ||
List<Marking> markings = documents.get(documentId).getMarkings(); | ||
Assert.assertNotNull(markings); | ||
Assert.assertTrue(markings.size() > markingId); | ||
Assert.assertEquals(expectedMarking, markings.get(markingId)); | ||
dataset.close(); | ||
} | ||
|
||
public abstract InitializableDataset createDataset(File file); | ||
|
||
} |
Oops, something went wrong.