You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2013/08/12 12:23:59 UTC

svn commit: r1513097 - /stanbol/trunk/enhancement-engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/NamedEntity.java

Author: rwesten
Date: Mon Aug 12 10:23:58 2013
New Revision: 1513097

URL: http://svn.apache.org/r1513097
Log:
STANBOL-1144: Basically applied the patch provided by Tom Lomax. Only made some adaptions to get better DEBUG level loggings.

Modified:
    stanbol/trunk/enhancement-engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/NamedEntity.java

Modified: stanbol/trunk/enhancement-engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/NamedEntity.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/NamedEntity.java?rev=1513097&r1=1513096&r2=1513097&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/NamedEntity.java (original)
+++ stanbol/trunk/enhancement-engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/NamedEntity.java Mon Aug 12 10:23:58 2013
@@ -22,6 +22,7 @@ import static org.apache.stanbol.enhance
 import org.apache.clerezza.rdf.core.NonLiteral;
 import org.apache.clerezza.rdf.core.TripleCollection;
 import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.commons.lang.StringUtils;
 import org.apache.stanbol.enhancer.servicesapi.helper.EnhancementEngineHelper;
 import org.apache.stanbol.enhancer.servicesapi.rdf.TechnicalClasses;
 import org.slf4j.Logger;
@@ -79,26 +80,33 @@ public final class NamedEntity {
      * text annotation is missing required information.
      */
     public static NamedEntity createFromTextAnnotation(TripleCollection graph, NonLiteral textAnnotation){
-        String name = EnhancementEngineHelper.getString(graph, textAnnotation, ENHANCER_SELECTED_TEXT);
-        if (name == null) {
+        String selected = EnhancementEngineHelper.getString(graph, textAnnotation, ENHANCER_SELECTED_TEXT);
+        if (selected == null) {
             log.debug("Unable to create NamedEntity for TextAnnotation {} "
                     + "because property {} is not present",textAnnotation,ENHANCER_SELECTED_TEXT);
             return null;
         }
-        name = name.trim();
+        String name = selected.trim();
         if(name.isEmpty()){
             log.debug("Unable to process TextAnnotation {} because its selects "
             		+ "an empty Stirng !",textAnnotation);
             return null;
         }
+        // remove punctuation form the search string
+        name = cleanupKeywords(name);
+        if(name.isEmpty()){
+            log.debug("Unable to process TextAnnotation {} because its selects "
+                    + "an stirng with punktations only (selected: {})!",
+                    textAnnotation, selected);
+            return null;
+        }
         UriRef type = EnhancementEngineHelper.getReference(graph, textAnnotation, DC_TYPE);
         if (type == null) {
             log.warn("Unable to process TextAnnotation {} because property {}"
                      + " is not present!",textAnnotation, DC_TYPE);
             return null;
         }
-        // remove punctuation form the search string
-        return new NamedEntity(textAnnotation,cleanupKeywords(name),type);
+        return new NamedEntity(textAnnotation,name,type);
     }        
     /**
      * Removes punctuation form a parsed string