You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by jo...@apache.org on 2014/10/29 20:15:24 UTC
svn commit: r1635261 -
/opennlp/addons/geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/GeoEntityLinker.java
Author: joern
Date: Wed Oct 29 19:15:23 2014
New Revision: 1635261
URL: http://svn.apache.org/r1635261
Log:
OPENNLP-579 Updated the Entity Linker interface
Modified:
opennlp/addons/geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/GeoEntityLinker.java
Modified: opennlp/addons/geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/GeoEntityLinker.java
URL: http://svn.apache.org/viewvc/opennlp/addons/geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/GeoEntityLinker.java?rev=1635261&r1=1635260&r2=1635261&view=diff
==============================================================================
--- opennlp/addons/geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/GeoEntityLinker.java (original)
+++ opennlp/addons/geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/GeoEntityLinker.java Wed Oct 29 19:15:23 2014
@@ -49,7 +49,7 @@ public class GeoEntityLinker implements
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 @@ public class GeoEntityLinker implements
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 @@ public class GeoEntityLinker implements
}
@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");
}
}