Skip to content

Instantly share code, notes, and snippets.

@damianoporta
Created December 6, 2015 14:28
Show Gist options
  • Save damianoporta/7ca0601f3f2a07e26fa8 to your computer and use it in GitHub Desktop.
Save damianoporta/7ca0601f3f2a07e26fa8 to your computer and use it in GitHub Desktop.
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