Created
December 6, 2015 14:28
-
-
Save damianoporta/7ca0601f3f2a07e26fa8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package ner.extractor; | |
import java.util.Collection; | |
import opennlp.tools.util.Span; | |
import java.util.HashSet; | |
import parsercv.Extractor; | |
import parsercv.Setup; | |
import util.Search; | |
public class Birthdate implements Extractor { | |
private String name = "birthdate"; | |
private Setup setup; | |
public Birthdate(Setup setup) { | |
this.setup = setup; | |
} | |
@Override | |
public void extract() { | |
Collection<Span> annotations = new HashSet<>(); | |
Search search = new Search(); | |
for(Span result: this.setup.entities.get("date")) { | |
boolean r = search.proximity(this.setup.tokens, result, setup.labels.get("birthdates")); | |
if (r == true) { | |
Span annotation = new Span(result.getStart(), result.getEnd(), result.getType()); | |
annotations.add(annotation); | |
} | |
} | |
this.setup.extractions.put(this.name, annotations.toArray(new Span[annotations.size()])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment