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 2012/02/24 14:53:29 UTC

svn commit: r1293251 - in /incubator/stanbol/trunk/enhancer: generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/rdf/NamespaceEnum.java ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/EnhancerLDPath.java

Author: rwesten
Date: Fri Feb 24 13:53:28 2012
New Revision: 1293251

URL: http://svn.apache.org/viewvc?rev=1293251&view=rev
Log:
STANBOL-500: forgot to commit the EnhancerLDPath class; Added a "fise:" namespace prefix as alternative to "enhancer". The intension is that the "fise" prefix will always point to the currently used enhancement structure and the "enhancer" namespace will be changed as soon as we switch to the new one.

Added:
    incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/EnhancerLDPath.java   (with props)
Modified:
    incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/rdf/NamespaceEnum.java

Modified: incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/rdf/NamespaceEnum.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/rdf/NamespaceEnum.java?rev=1293251&r1=1293250&r2=1293251&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/rdf/NamespaceEnum.java (original)
+++ incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/rdf/NamespaceEnum.java Fri Feb 24 13:53:28 2012
@@ -37,8 +37,13 @@ public enum NamespaceEnum {
     /**
      * Namespace for the Stanbol Enhancer Execution Metadata ontology
      */
-    em("http://stanbol.apache.org/ontology/enhancer/executionMetadata#");
-
+    em("http://stanbol.apache.org/ontology/enhancer/executionMetadata#"),
+    /**
+     * The FISE namespace (1st version of the Enhancement Structure).
+     * Currently the same as {@link NamespaceEnum#enhancer}
+     */
+    fise("http://fise.iks-project.eu/ontology/");
+    
     String ns;
     String prefix;
 

Added: incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/EnhancerLDPath.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/EnhancerLDPath.java?rev=1293251&view=auto
==============================================================================
--- incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/EnhancerLDPath.java (added)
+++ incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/EnhancerLDPath.java Fri Feb 24 13:53:28 2012
@@ -0,0 +1,146 @@
+package org.apache.stanbol.enhancer.ldpath;
+
+import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.DC_RELATION;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_CONFIDENCE;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_ENTITY_REFERENCE;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_EXTRACTED_FROM;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.RDF_TYPE;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.TechnicalClasses.ENHANCER_ENHANCEMENT;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.TechnicalClasses.ENHANCER_ENTITYANNOTATION;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.TechnicalClasses.ENHANCER_TEXTANNOTATION;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.TechnicalClasses.ENHANCER_TOPICANNOTATION;
+
+import org.apache.clerezza.rdf.core.Resource;
+import org.apache.stanbol.enhancer.ldpath.function.ContentFunction;
+import org.apache.stanbol.enhancer.ldpath.function.PathFunction;
+import org.apache.stanbol.enhancer.ldpath.function.SuggestionFunction;
+import org.apache.stanbol.enhancer.ldpath.utils.Utils;
+import org.apache.stanbol.enhancer.servicesapi.rdf.NamespaceEnum;
+
+import at.newmedialab.ldpath.api.functions.SelectorFunction;
+import at.newmedialab.ldpath.api.selectors.NodeSelector;
+import at.newmedialab.ldpath.model.Constants;
+import at.newmedialab.ldpath.parser.Configuration;
+import at.newmedialab.ldpath.parser.DefaultConfiguration;
+import at.newmedialab.ldpath.parser.ParseException;
+
+/**
+ * Defines defaults for LDPath
+ */
+public final class EnhancerLDPath {
+    
+    private EnhancerLDPath(){}
+    
+    private static Configuration<Resource> CONFIG;
+    
+    /**
+     * The LDPath configuration including the <ul>
+     * <li> Namespaces defined by the {@link NamespaceEnum}
+     * <li> the LDPath functions for the Stanbol Enhancement Structure
+     * </ul>
+     * @return the LDPath configuration for the Stanbol Enhancer
+     */
+    public static final Configuration<Resource> getConfig(){
+        if(CONFIG == null){
+            CONFIG = new DefaultConfiguration<Resource>();
+            //add the namespaces
+            for(NamespaceEnum ns : NamespaceEnum.values()){
+                CONFIG.addNamespace(ns.getPrefix(), ns.getNamespace());
+            }
+            //now add the functions
+            addFunction(CONFIG, new ContentFunction());
+            String path;
+            NodeSelector<Resource> selector;
+            //TextAnnotations
+            path = String.format("^%s[%s is %s]",
+                ENHANCER_EXTRACTED_FROM,RDF_TYPE,ENHANCER_TEXTANNOTATION);
+            try {
+                selector = Utils.parseSelector(path);
+            } catch (ParseException e) {
+                throw new IllegalStateException("Unable to parse the ld-path selector '" +
+                        path + "'used to select all TextAnnotations of a contentItem!", e);
+            }
+            addFunction(CONFIG, new PathFunction<Resource>(
+                    "textAnnotation",selector));
+            
+            //EntityAnnotations
+            path = String.format("^%s[%s is %s]",
+                ENHANCER_EXTRACTED_FROM,RDF_TYPE,ENHANCER_ENTITYANNOTATION);
+            try {
+                selector = Utils.parseSelector(path);
+            } catch (ParseException e) {
+                throw new IllegalStateException("Unable to parse the ld-path selector '" +
+                        path + "'used to select all EntityAnnotations of a contentItem!", e);
+            }
+            addFunction(CONFIG,new PathFunction<Resource>(
+                    "entityAnnotation", selector));
+            
+            //TopicAnnotations
+            path = String.format("^%s[%s is %s]",
+                ENHANCER_EXTRACTED_FROM,RDF_TYPE,ENHANCER_TOPICANNOTATION);
+            try {
+                selector = Utils.parseSelector(path);
+            } catch (ParseException e) {
+                throw new IllegalStateException("Unable to parse the ld-path selector '" +
+                        path + "'used to select all TopicAnnotations of a contentItem!", e);
+            }
+            addFunction(CONFIG,new PathFunction<Resource>(
+                    "topicAnnotation",selector));
+            //Enhancements
+            path = String.format("^%s[%s is %s]",
+                ENHANCER_EXTRACTED_FROM,RDF_TYPE,ENHANCER_ENHANCEMENT);
+            try {
+                selector = Utils.parseSelector(path);
+            } catch (ParseException e) {
+                throw new IllegalStateException("Unable to parse the ld-path selector '" +
+                        path + "'used to select all Enhancements of a contentItem!", e);
+            }
+            addFunction(CONFIG,new PathFunction<Resource>(
+                    "enhancement",selector));
+            
+            //Suggested EntityAnnotations for Text/TopicAnnotations
+            
+            //(1) to select the suggestions
+            NodeSelector<Resource> linkedEntityAnnotations;
+            path = String.format("^%s[%s is %s]",
+                DC_RELATION,RDF_TYPE,ENHANCER_ENTITYANNOTATION,ENHANCER_CONFIDENCE);
+            try {
+                linkedEntityAnnotations = Utils.parseSelector(path);
+            } catch (ParseException e) {
+                throw new IllegalStateException("Unable to parse the ld-path selector '" +
+                        path + "'used to select all entity suggestions for an Enhancement!", e);
+            }
+            //(2) to select the confidence value of Enhancements
+            NodeSelector<Resource> confidenceSelector;
+            path = ENHANCER_CONFIDENCE.toString();
+            try {
+                confidenceSelector = Utils.parseSelector(path);
+            } catch (ParseException e) {
+                throw new IllegalStateException("Unable to parse the ld-path selector '" +
+                        path + "'used to select the confidence of suggestions!", e);
+            }
+            //The resultSelector is NULL because this directly returns the EntityAnnotations
+            addFunction(CONFIG,new SuggestionFunction("suggestion",linkedEntityAnnotations,confidenceSelector,null));
+            
+            //Suggested Entities for Text/TopicAnnotations
+            
+            //The suggestion and confidence selectors can be the same as above,
+            //but we need an additional result selector
+            NodeSelector<Resource> entityReferenceSelector;
+            path = ENHANCER_ENTITY_REFERENCE.toString();
+            try {
+                entityReferenceSelector = Utils.parseSelector(path);
+            } catch (ParseException e) {
+                throw new IllegalStateException("Unable to parse the ld-path selector '" +
+                        path + "'used to select the entity referenced by a EntityAnnotation!", e);
+            }
+            addFunction(CONFIG, new SuggestionFunction("suggestedEntity",
+                linkedEntityAnnotations,confidenceSelector,entityReferenceSelector));
+            
+        }
+        return CONFIG;
+    }
+    private static <Node> void addFunction(Configuration<Node> config, SelectorFunction<Node> function) {
+        config.addFunction(Constants.NS_LMF_FUNCS + function.getPathExpression(null), function);
+    }
+}

Propchange: incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/EnhancerLDPath.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain