OPENNLP-579 Updated the Entity Linker interface
diff --git a/geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/GeoEntityLinker.java b/geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/GeoEntityLinker.java
index c9edc64..b6a8c1c 100644
--- a/geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/GeoEntityLinker.java
+++ b/geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/GeoEntityLinker.java
@@ -49,7 +49,7 @@
private List<LinkedEntityScorer<AdminBoundaryContext>> scorers = new ArrayList<>();
@Override
- public List<LinkedSpan> find(String doctext, Span[] sentences, String[][] tokensBySentence, Span[][] namesBySentence) {
+ public List<LinkedSpan> find(String doctext, Span[] sentences, Span[][] tokensBySentence, Span[][] namesBySentence) {
ArrayList<LinkedSpan> spans = new ArrayList<LinkedSpan>();
if (linkerProperties == null) {
@@ -59,7 +59,10 @@
AdminBoundaryContext context = countryContext.getContext(doctext);
for (int s = 0; s < sentences.length; s++) {
Span[] names = namesBySentence[s];
- String[] tokens = tokensBySentence[s];
+
+ Span[] tokenSpans = tokensBySentence[s];
+ String[] tokens = Span.spansToStrings(tokenSpans, sentences[s].getCoveredText(doctext));
+
String[] matches = Span.spansToStrings(names, tokens);
for (int i = 0; i < matches.length; i++) {
@@ -202,17 +205,9 @@
}
@Override
- public List<LinkedSpan> find(String text, Span[] sentences, Span[] tokens, Span[] nameSpans) {
- throw new UnsupportedOperationException("The GeoEntityLinker requires the entire document for proper scoring. This method is unsupported"); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public List<LinkedSpan> find(String text, Span[] sentences, Span[] tokens, Span[] nameSpans, int sentenceIndex) {
- throw new UnsupportedOperationException("The GeoEntityLinker requires the entire document for proper scoring. This method is unsupported"); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public List<LinkedSpan> find(String text, Span[] sentences, String[] tokens, Span[] nameSpans) {
- throw new UnsupportedOperationException("The GeoEntityLinker requires the entire document for proper scoring. This method is unsupported"); //To change body of generated methods, choose Tools | Templates.
+ public List<LinkedSpan> find(String doctext, Span[] sentences, Span[][] tokensBySentence,
+ Span[][] namesBySentence, int sentenceIndex) {
+ throw new UnsupportedOperationException("The GeoEntityLinker requires the entire document "
+ + "for proper scoring. This method is unsupported");
}
}