Author: rwesten Date: Sun Apr 8 16:40:23 2012 New Revision: 1311038 URL: http://svn.apache.org/viewvc?rev=1311038&view=rev Log: Faild build 858: Reverted changes related to the unreleased LDpath version 0.9.6 including the fix for ldpath#7 [1] while keeping the changes related to the new ContentItemFactory.
[1] http://code.google.com/p/ldpath/issues/detail?id=7 Modified: incubator/stanbol/trunk/enhancer/ldpath/pom.xml incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/function/ContentFunction.java incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/function/ContentItemFunction.java incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/function/PathFunction.java incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/function/SuggestionFunction.java incubator/stanbol/trunk/enhancer/ldpath/src/test/java/org/apache/stanbol/enhancer/ldpath/ContentItemBackendTest.java incubator/stanbol/trunk/enhancer/ldpath/src/test/java/org/apache/stanbol/enhancer/ldpath/UsageExamples.java Modified: incubator/stanbol/trunk/enhancer/ldpath/pom.xml URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/ldpath/pom.xml?rev=1311038&r1=1311037&r2=1311038&view=diff ============================================================================== --- incubator/stanbol/trunk/enhancer/ldpath/pom.xml (original) +++ incubator/stanbol/trunk/enhancer/ldpath/pom.xml Sun Apr 8 16:40:23 2012 @@ -106,12 +106,12 @@ <dependency> <groupId>at.newmedialab.ldpath</groupId> <artifactId>ldpath-api</artifactId> - <version>0.9.6-SNAPSHOT</version> + <!-- version>0.9.6-SNAPSHOT</version> --> </dependency> <dependency> <groupId>at.newmedialab.ldpath</groupId> <artifactId>ldpath-core-bundle</artifactId> - <version>0.9.6-SNAPSHOT</version> + <!-- version>0.9.6-SNAPSHOT</version> --> </dependency> <dependency> <groupId>org.apache.stanbol</groupId> Modified: incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/function/ContentFunction.java URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/function/ContentFunction.java?rev=1311038&r1=1311037&r2=1311038&view=diff ============================================================================== --- incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/function/ContentFunction.java (original) +++ incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/function/ContentFunction.java Sun Apr 8 16:40:23 2012 @@ -56,7 +56,7 @@ public class ContentFunction extends Con } @Override - public Collection<Resource> apply(ContentItemBackend backend, Resource context, Collection<Resource>... args) throws IllegalArgumentException { + public Collection<Resource> apply(ContentItemBackend backend, Collection<Resource>... args) throws IllegalArgumentException { ContentItem ci = ((ContentItemBackend)backend).getContentItem(); // Collection<Resource> contexts = args[0]; Set<String> mimeTypes; Modified: incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/function/ContentItemFunction.java URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/function/ContentItemFunction.java?rev=1311038&r1=1311037&r2=1311038&view=diff ============================================================================== --- incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/function/ContentItemFunction.java (original) +++ incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/function/ContentItemFunction.java Sun Apr 8 16:40:23 2012 @@ -44,10 +44,10 @@ public abstract class ContentItemFunctio } this.name = name; } - @Override - public final Collection<Resource> apply(RDFBackend<Resource> backend, Resource context, Collection<Resource>... args) throws IllegalArgumentException { + + public final Collection<Resource> apply(RDFBackend<Resource> backend, Collection<Resource>... args) throws IllegalArgumentException { if(backend instanceof ContentItemBackend){ - return apply((ContentItemBackend)backend, context, args); + return apply((ContentItemBackend)backend, args); } else { throw new IllegalArgumentException("This ContentFunction can only be " + "used in combination with an RDFBackend of type '"+ @@ -56,7 +56,7 @@ public abstract class ContentItemFunctio } }; - public abstract Collection<Resource> apply(ContentItemBackend backend,Resource context,Collection<Resource>... args); + public abstract Collection<Resource> apply(ContentItemBackend backend,Collection<Resource>... args); @Override public String getPathExpression(RDFBackend<Resource> backend) { Modified: incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/function/PathFunction.java URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/function/PathFunction.java?rev=1311038&r1=1311037&r2=1311038&view=diff ============================================================================== --- incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/function/PathFunction.java (original) +++ incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/function/PathFunction.java Sun Apr 8 16:40:23 2012 @@ -17,13 +17,9 @@ package org.apache.stanbol.enhancer.ldpath.function; import java.util.Collection; -import java.util.Collections; import java.util.HashSet; import java.util.Set; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import at.newmedialab.ldpath.api.backend.RDFBackend; import at.newmedialab.ldpath.api.functions.SelectorFunction; import at.newmedialab.ldpath.api.selectors.NodeSelector; @@ -37,8 +33,6 @@ import at.newmedialab.ldpath.api.selecto */ public class PathFunction<Node> implements SelectorFunction<Node> { - private final static Logger log = LoggerFactory.getLogger(PathFunction.class); - private final String name; private final NodeSelector<Node> selector; @@ -62,18 +56,15 @@ public class PathFunction<Node> implemen } @Override - public Collection<Node> apply(RDFBackend<Node> backend, Node context, Collection<Node>... args) throws IllegalArgumentException { - final Collection<Node> nodes; - if(args == null || args.length < 1 || args[0] == null){ - nodes = Collections.singleton(context); - log.debug("no arguments - use context {}",context); - } else { - nodes = args[0]; - log.debug("use parsed context {}",nodes); + public Collection<Node> apply(RDFBackend<Node> backend, Collection<Node>... args) throws IllegalArgumentException { + if(args == null || args.length < 1 || args[0] == null || args[0].isEmpty()){ + throw new IllegalArgumentException("The 'fn:"+name+"' function " + + "requires at least a single none empty parameter (the context). Use 'fn:" + + name+"(.)' to execute it on the path context!"); } Set<Node> selected = new HashSet<Node>(); - for(Node node : nodes){ - selected.addAll(selector.select(backend, node)); + for(Node context : args[0]){ + selected.addAll(selector.select(backend, context)); } return selected; } Modified: incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/function/SuggestionFunction.java URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/function/SuggestionFunction.java?rev=1311038&r1=1311037&r2=1311038&view=diff ============================================================================== --- incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/function/SuggestionFunction.java (original) +++ incubator/stanbol/trunk/enhancer/ldpath/src/main/java/org/apache/stanbol/enhancer/ldpath/function/SuggestionFunction.java Sun Apr 8 16:40:23 2012 @@ -91,27 +91,13 @@ public class SuggestionFunction implemen } @Override - public Collection<Resource> apply(final RDFBackend<Resource> backend, Resource context,Collection<Resource>... args) throws IllegalArgumentException { - final Collection<Resource> contexts; - final int paramOffset; - if(args == null || args.length<1 || args[0] == null){ - contexts = Collections.singleton(context); - paramOffset = 0; - } else if(args[0].isEmpty()){ - return Collections.emptyList(); //empty context -> empty result - } else if(!backend.isLiteral(args[0].iterator().next())){ - contexts = args[0]; //param[0] contains references -> use this as context - paramOffset = 1; //start parsing parameters at position 1 - } else { //literal parameter at param index 0 -> - contexts = Collections.singleton(context); //use context - paramOffset = 0; //start parsing parameters at position 0 - } - Integer limit = parseParamLimit(backend, args,paramOffset+0); + public Collection<Resource> apply(final RDFBackend<Resource> backend, Collection<Resource>... args) throws IllegalArgumentException { + Integer limit = parseParamLimit(backend, args,1); // final String processingMode = parseParamProcessingMode(backend, args,2); - final int missingConfidenceMode = parseParamMissingConfidenceMode(backend, args,paramOffset+1); + final int missingConfidenceMode = parseParamMissingConfidenceMode(backend, args,2); List<Resource> result = new ArrayList<Resource>(); // if(processingMode.equals(ANNOTATION_PROCESSING_MODE_UNION)){ - processAnnotations(backend, contexts, limit, missingConfidenceMode, result); + processAnnotations(backend, args[0], limit, missingConfidenceMode, result); // } else { // for(Resource context : args[0]){ // processAnnotations(backend, singleton(context), Modified: incubator/stanbol/trunk/enhancer/ldpath/src/test/java/org/apache/stanbol/enhancer/ldpath/ContentItemBackendTest.java URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/ldpath/src/test/java/org/apache/stanbol/enhancer/ldpath/ContentItemBackendTest.java?rev=1311038&r1=1311037&r2=1311038&view=diff ============================================================================== --- incubator/stanbol/trunk/enhancer/ldpath/src/test/java/org/apache/stanbol/enhancer/ldpath/ContentItemBackendTest.java (original) +++ incubator/stanbol/trunk/enhancer/ldpath/src/test/java/org/apache/stanbol/enhancer/ldpath/ContentItemBackendTest.java Sun Apr 8 16:40:23 2012 @@ -187,7 +187,7 @@ public class ContentItemBackendTest { } @Test public void testTextAnnotationFunction() throws LDPathParseException { - String path = "fn:textAnnotation()/fise:selected-text"; + String path = "fn:textAnnotation(.)/fise:selected-text"; Collection<Resource> result = ldpath.pathQuery(ci.getUri(), path, null); assertNotNull(result); assertFalse(result.isEmpty()); @@ -203,7 +203,7 @@ public class ContentItemBackendTest { //test with a filter for the type //same as the 1st example bat rather using an ld-path construct for //filtering for TextAnnotations representing persons - path = "fn:textAnnotation()[dc:type is dbpedia-ont:Person]/fise:selected-text"; + path = "fn:textAnnotation(.)[dc:type is dbpedia-ont:Person]/fise:selected-text"; result = ldpath.pathQuery(ci.getUri(), path, null); assertNotNull(result); assertFalse(result.isEmpty()); @@ -215,7 +215,7 @@ public class ContentItemBackendTest { } @Test public void testEntityAnnotation() throws LDPathParseException { - String path = "fn:entityAnnotation()/fise:entity-reference"; + String path = "fn:entityAnnotation(.)/fise:entity-reference"; Collection<Resource> result = ldpath.pathQuery(ci.getUri(), path, null); assertNotNull(result); assertFalse(result.isEmpty()); @@ -233,7 +233,7 @@ public class ContentItemBackendTest { } assertTrue(expectedValues.isEmpty()); //and with a filter - path = "fn:entityAnnotation()[fise:entity-type is dbpedia-ont:Person]/fise:entity-reference"; + path = "fn:entityAnnotation(.)[fise:entity-type is dbpedia-ont:Person]/fise:entity-reference"; result = ldpath.pathQuery(ci.getUri(), path, null); assertNotNull(result); assertFalse(result.isEmpty()); @@ -242,7 +242,7 @@ public class ContentItemBackendTest { } @Test public void testEnhancements() throws LDPathParseException { - String path = "fn:enhancement()"; + String path = "fn:enhancement(.)"; Collection<Resource> result = ldpath.pathQuery(ci.getUri(), path, null); assertNotNull(result); assertFalse(result.isEmpty()); @@ -252,13 +252,13 @@ public class ContentItemBackendTest { log.info("Entity: {}",r); } //and with a filter - path = "fn:enhancement()[rdf:type is fise:TextAnnotation]"; + path = "fn:enhancement(.)[rdf:type is fise:TextAnnotation]"; result = ldpath.pathQuery(ci.getUri(), path, null); assertNotNull(result); assertFalse(result.isEmpty()); assertTrue(result.size() == 3); // assertTrue(result.contains(new UriRef("http://dbpedia.org/resource/Bob_Marley"))); - path = "fn:enhancement()/dc:language"; + path = "fn:enhancement(.)/dc:language"; result = ldpath.pathQuery(ci.getUri(), path, null); assertNotNull(result); assertFalse(result.isEmpty()); @@ -276,7 +276,7 @@ public class ContentItemBackendTest { // Because this test checks first that all three suggestions for Paris // are returned and later that a limit of 2 only returns the two top // most. - String path = "fn:textAnnotation()[dc:type is dbpedia-ont:Place]/fn:suggestion()"; + String path = "fn:textAnnotation(.)[dc:type is dbpedia-ont:Place]/fn:suggestion(.)"; Collection<Resource> result = ldpath.pathQuery(ci.getUri(), path, null); assertNotNull(result); assertFalse(result.isEmpty()); @@ -296,7 +296,7 @@ public class ContentItemBackendTest { } } assertNotNull(lowestConfidenceSuggestion); - path = "fn:textAnnotation()[dc:type is dbpedia-ont:Place]/fn:suggestion(\"2\")"; + path = "fn:textAnnotation(.)[dc:type is dbpedia-ont:Place]/fn:suggestion(.,\"2\")"; Collection<Resource> result2 = ldpath.pathQuery(ci.getUri(), path, null); assertNotNull(result2); assertFalse(result2.isEmpty()); @@ -312,7 +312,7 @@ public class ContentItemBackendTest { //(1) get the {limit} top rated linked Entities per parsed context // In this example we parse all TextAnnotations //NOTE: '.' MUST BE used as first argument in this case - String path = "fn:textAnnotation()/fn:suggestedEntity(\"1\")"; + String path = "fn:textAnnotation(.)/fn:suggestedEntity(.,\"1\")"; Collection<Resource> result = ldpath.pathQuery(ci.getUri(), path, null); assertNotNull(result); assertFalse(result.isEmpty()); @@ -332,7 +332,7 @@ public class ContentItemBackendTest { // as the first argument //NOTE: the selector parsing all Annotations MUST BE used as first // argument - path = "fn:suggestedEntity(fn:textAnnotation(),\"1\")"; + path = "fn:suggestedEntity(fn:textAnnotation(.),\"1\")"; result = ldpath.pathQuery(ci.getUri(), path, null); assertNotNull(result); assertFalse(result.isEmpty()); Modified: incubator/stanbol/trunk/enhancer/ldpath/src/test/java/org/apache/stanbol/enhancer/ldpath/UsageExamples.java URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/ldpath/src/test/java/org/apache/stanbol/enhancer/ldpath/UsageExamples.java?rev=1311038&r1=1311037&r2=1311038&view=diff ============================================================================== --- incubator/stanbol/trunk/enhancer/ldpath/src/test/java/org/apache/stanbol/enhancer/ldpath/UsageExamples.java (original) +++ incubator/stanbol/trunk/enhancer/ldpath/src/test/java/org/apache/stanbol/enhancer/ldpath/UsageExamples.java Sun Apr 8 16:40:23 2012 @@ -127,17 +127,17 @@ public class UsageExamples { @Test public void exampleExtractedPersons() throws LDPathParseException { StringBuilder program = new StringBuilder(); - program.append("personMentions = fn:textAnnotation()" + + program.append("personMentions = fn:textAnnotation(.)" + "[dc:type is dbpedia-ont:Person]/fise:selected-text :: xsd:string;"); //this uses the labels of suggested person with the highest confidence //but also the selected-text as fallback if no entity is suggested. - program.append("personNames = fn:textAnnotation()" + - "[dc:type is dbpedia-ont:Person]/fn:first(fn:suggestion(\"1\")/fise:entity-label,fise:selected-text) :: xsd:string;"); - program.append("linkedPersons = fn:textAnnotation()" + - "[dc:type is dbpedia-ont:Person]/fn:suggestedEntity(\"1\") :: xsd:anyURI;"); + program.append("personNames = fn:textAnnotation(.)" + + "[dc:type is dbpedia-ont:Person]/fn:first(fn:suggestion(.,\"1\")/fise:entity-label,fise:selected-text) :: xsd:string;"); + program.append("linkedPersons = fn:textAnnotation(.)" + + "[dc:type is dbpedia-ont:Person]/fn:suggestedEntity(.,\"1\") :: xsd:anyURI;"); //this selects only linked Artists - program.append("linkedArtists = fn:textAnnotation()" + - "[dc:type is dbpedia-ont:Person]/fn:suggestion()" + + program.append("linkedArtists = fn:textAnnotation(.)" + + "[dc:type is dbpedia-ont:Person]/fn:suggestion(.)" + "[fise:entity-type is dbpedia-ont:Artist]/fise:entity-reference :: xsd:anyURI;"); Program<Resource> personProgram = ldpath.parseProgram(new StringReader(program.toString())); log.info("- - - - - - - - - - - - - "); @@ -172,17 +172,17 @@ public class UsageExamples { @Test public void exampleExtractedPlaces() throws LDPathParseException { StringBuilder program = new StringBuilder(); - program.append("locationMentions = fn:textAnnotation()" + + program.append("locationMentions = fn:textAnnotation(.)" + "[dc:type is dbpedia-ont:Place]/fise:selected-text :: xsd:string;"); //this uses the labels of suggested places with the highest confidence //but also the selected-text as fallback if no entity is suggested. - program.append("locationNames = fn:textAnnotation()" + - "[dc:type is dbpedia-ont:Place]/fn:first(fn:suggestion(\"1\")/fise:entity-label,fise:selected-text) :: xsd:string;"); - program.append("linkedPlaces = fn:textAnnotation()" + - "[dc:type is dbpedia-ont:Place]/fn:suggestedEntity(\"1\") :: xsd:anyURI;"); + program.append("locationNames = fn:textAnnotation(.)" + + "[dc:type is dbpedia-ont:Place]/fn:first(fn:suggestion(.,\"1\")/fise:entity-label,fise:selected-text) :: xsd:string;"); + program.append("linkedPlaces = fn:textAnnotation(.)" + + "[dc:type is dbpedia-ont:Place]/fn:suggestedEntity(.,\"1\") :: xsd:anyURI;"); //this selects only linked Artists - program.append("linkedCountries = fn:textAnnotation()" + - "[dc:type is dbpedia-ont:Place]/fn:suggestion()" + + program.append("linkedCountries = fn:textAnnotation(.)" + + "[dc:type is dbpedia-ont:Place]/fn:suggestion(.)" + "[fise:entity-type is dbpedia-ont:Country]/fise:entity-reference :: xsd:anyURI;"); Program<Resource> personProgram = ldpath.parseProgram(new StringReader(program.toString())); log.info("- - - - - - - - - - - - -"); @@ -200,18 +200,18 @@ public class UsageExamples { @Test public void exampleExtractedOrganization() throws LDPathParseException { StringBuilder program = new StringBuilder(); - program.append("orgMentions = fn:textAnnotation()" + + program.append("orgMentions = fn:textAnnotation(.)" + "[dc:type is dbpedia-ont:Organisation]/fise:selected-text :: xsd:string;"); //this uses the labels of suggested organisations with the highest confidence //but also the selected-text as fallback if no entity is suggested. - program.append("orgNames = fn:textAnnotation()" + - "[dc:type is dbpedia-ont:Organisation]/fn:first(fn:suggestion(\"1\")/fise:entity-label,fise:selected-text) :: xsd:string;"); - program.append("linkedOrgs = fn:textAnnotation()" + - "[dc:type is dbpedia-ont:Organisation]/fn:suggestedEntity(\"1\") :: xsd:anyURI;"); + program.append("orgNames = fn:textAnnotation(.)" + + "[dc:type is dbpedia-ont:Organisation]/fn:first(fn:suggestion(.,\"1\")/fise:entity-label,fise:selected-text) :: xsd:string;"); + program.append("linkedOrgs = fn:textAnnotation(.)" + + "[dc:type is dbpedia-ont:Organisation]/fn:suggestedEntity(.,\"1\") :: xsd:anyURI;"); //this selects only linked education organisations - //NOTE: this does not use a limit on suggestion()! - program.append("linkedEducationOrg = fn:textAnnotation()" + - "[dc:type is dbpedia-ont:Organisation]/fn:suggestion()" + + //NOTE: this does not use a limit on suggestion(.)! + program.append("linkedEducationOrg = fn:textAnnotation(.)" + + "[dc:type is dbpedia-ont:Organisation]/fn:suggestion(.)" + "[fise:entity-type is dbpedia-ont:EducationalInstitution]/fise:entity-reference :: xsd:anyURI;"); Program<Resource> personProgram = ldpath.parseProgram(new StringReader(program.toString())); log.info("- - - - - - - - - - - - -"); @@ -229,11 +229,11 @@ public class UsageExamples { @Test public void exampleExtractedConcepts() throws LDPathParseException { StringBuilder program = new StringBuilder(); - program.append("conceptNames = fn:entityAnnotation()" + + program.append("conceptNames = fn:entityAnnotation(.)" + "[fise:entity-type is skos:Concept]/fise:entity-label :: xsd:anyURI;"); //this uses the labels of suggested person with the highest confidence //but also the selected-text as fallback if no entity is suggested. - program.append("linkedConcepts = fn:entityAnnotation()" + + program.append("linkedConcepts = fn:entityAnnotation(.)" + "[fise:entity-type is skos:Concept]/fise:entity-reference :: xsd:anyURI;"); Program<Resource> personProgram = ldpath.parseProgram(new StringReader(program.toString())); log.info("- - - - - - - - - - - - -");
