You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2012/11/18 21:00:14 UTC

svn commit: r1410974 - in /jena: Experimental/riot-reader/src/main/java/dev/ Scratch/AFS/Dev/trunk/src-dev/dev/ trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/

Author: andy
Date: Sun Nov 18 20:00:10 2012
New Revision: 1410974

URL: http://svn.apache.org/viewvc?rev=1410974&view=rev
Log:
misc sync

Added:
    jena/Scratch/AFS/Dev/trunk/src-dev/dev/IsoMatcher.java
Modified:
    jena/Experimental/riot-reader/src/main/java/dev/MainWebReader.java
    jena/Experimental/riot-reader/src/main/java/dev/PROJECT_RiotReader.java
    jena/Scratch/AFS/Dev/trunk/src-dev/dev/RunAFS.java
    jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet.java

Modified: jena/Experimental/riot-reader/src/main/java/dev/MainWebReader.java
URL: http://svn.apache.org/viewvc/jena/Experimental/riot-reader/src/main/java/dev/MainWebReader.java?rev=1410974&r1=1410973&r2=1410974&view=diff
==============================================================================
--- jena/Experimental/riot-reader/src/main/java/dev/MainWebReader.java (original)
+++ jena/Experimental/riot-reader/src/main/java/dev/MainWebReader.java Sun Nov 18 20:00:10 2012
@@ -32,6 +32,10 @@ public class MainWebReader
     
     public static void main(String ... argv)
     {
+        
+        riotcmd.rdflangtest.main("--strict", "--earl", "/home/afs/Jena/jena-arq/testing/RIOT/Lang/Turtle/manifest.ttl") ;
+        System.exit(0) ;
+        
         //
         RIOT.init() ;
 

Modified: jena/Experimental/riot-reader/src/main/java/dev/PROJECT_RiotReader.java
URL: http://svn.apache.org/viewvc/jena/Experimental/riot-reader/src/main/java/dev/PROJECT_RiotReader.java?rev=1410974&r1=1410973&r2=1410974&view=diff
==============================================================================
--- jena/Experimental/riot-reader/src/main/java/dev/PROJECT_RiotReader.java (original)
+++ jena/Experimental/riot-reader/src/main/java/dev/PROJECT_RiotReader.java Sun Nov 18 20:00:10 2012
@@ -22,9 +22,9 @@ package dev;
 public class PROJECT_RiotReader
 {
     // Integration
-    //    Check used!
     //    Check AdaptiveFileManager
-    
+    //    TriG and NQ tests (need isomorpic tests for quads).
+    //    IsoMatcher
     
     // Work out the dependencies on ARQ for splitting out RIOT
     

Added: jena/Scratch/AFS/Dev/trunk/src-dev/dev/IsoMatcher.java
URL: http://svn.apache.org/viewvc/jena/Scratch/AFS/Dev/trunk/src-dev/dev/IsoMatcher.java?rev=1410974&view=auto
==============================================================================
--- jena/Scratch/AFS/Dev/trunk/src-dev/dev/IsoMatcher.java (added)
+++ jena/Scratch/AFS/Dev/trunk/src-dev/dev/IsoMatcher.java Sun Nov 18 20:00:10 2012
@@ -0,0 +1,174 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package dev ;
+
+import java.util.ArrayList ;
+import java.util.Collection ;
+import java.util.List ;
+
+import org.openjena.atlas.iterator.Iter ;
+
+import com.hp.hpl.jena.graph.Graph ;
+import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.graph.Triple ;
+import com.hp.hpl.jena.sparql.util.NodeUtils ;
+import com.hp.hpl.jena.sparql.util.NodeUtils.EqualityTest ;
+
+// Needs to be back tracking?
+
+/** Simple isomorphism testing */
+public class IsoMatcher
+{
+    private final Graph        graph1 ;
+    private final Graph        graph2 ;
+    private final EqualityTest nodeTest ;
+
+    static class Mapping
+    {
+        final Node    node1 ;
+        final Node    node2 ;
+        final Mapping parent ;
+
+        public Mapping(Mapping parent, Node node1, Node node2)
+        {
+            super() ;
+            this.parent = parent ;
+            this.node1 = node1 ;
+            this.node2 = node2 ;
+        }
+
+        public Node map(Node node)
+        {
+            Mapping mapping = this ;
+            while (mapping != null)
+            {
+                if (mapping.node1.equals(node)) return mapping.node2 ;
+                mapping = mapping.parent ;
+            }
+            return null ;
+        }
+    }
+
+    static class Cause
+    {
+        final Triple  triple ;
+        final Mapping mapping ;
+
+        public Cause(Triple triple, Mapping mapping)
+        {
+            super() ;
+            this.triple = triple ;
+            this.mapping = mapping ;
+        }
+    }
+
+    public static boolean isomorphic(Graph g1, Graph g2)
+    {
+        IsoMatcher matcher = new IsoMatcher(g1, g2, NodeUtils.sameTerm) ;
+        return matcher.match() ;
+    }
+
+    private IsoMatcher(Graph g1, Graph g2, EqualityTest nodeTest)
+    {
+        this.graph1 = g1 ;
+        this.graph2 = g2 ;
+        this.nodeTest = nodeTest ;
+    }
+
+    public boolean match()
+    {
+        // Mutated.
+        List<Triple> g1 = Iter.toList(graph1.find(null, null, null)) ;
+        List<Triple> g2 = Iter.toList(graph2.find(null, null, null)) ;
+        return match(g1, g2) ;
+    }
+
+    public boolean match(List<Triple> triples1, List<Triple> triples2)
+    {
+        
+        Triple t1 = triples1.remove(0) ;
+        List<Cause> causes = gen(t1, triples2) ;
+        
+        for ( Cause c : causes )
+        {
+            int idx = triples2.indexOf(c.triple) ;
+            triples2.remove(idx) ;
+            boolean b = match(triples1, triples2) ;
+            if ( b )
+                return true ;
+            triples2.add(idx, c.triple) ;
+        }
+        return false ;
+    }
+
+    private List<Cause> gen(Triple t1, Collection<Triple> g2)
+    {
+        List<Cause> matches = new ArrayList<Cause>() ;
+        for (Triple t2 : g2)
+        {
+            List<Cause> step = gen(t1, t2, nodeTest) ;
+            if (step != null) matches.addAll(step) ;
+        }
+        return matches ;
+    }
+
+    // -------------------------------
+    
+    // Maybe several mappings!
+    private static List<Cause> gen(Triple t1, Triple t2, EqualityTest test)
+    {
+        // Bnodes are either known, or not.
+
+        return null ;
+
+        // return test.equal(t1.getSubject(), t2.getSubject()) &&
+        // test.equal(t1.getPredicate(), t2.getPredicate()) &&
+        // test.equal(t1.getObject(), t2.getObject()) ;
+    }
+
+    // add must be bNode in ANY slots
+    public static List<Triple> findC(Collection<Triple> triples, Triple t)
+    {
+        if (t.isConcrete())
+        {
+            if (triples.contains(t))
+            {
+                List<Triple> matches = new ArrayList<Triple>() ;
+                matches.add(t) ;
+                return matches ;
+            }
+        }
+
+        Node s = t.getSubject() ;
+        Node p = t.getPredicate() ;
+        Node o = t.getObject() ;
+
+        if (!s.isConcrete()) s = Node.ANY ;
+        if (!p.isConcrete()) p = Node.ANY ;
+        if (!o.isConcrete()) o = Node.ANY ;
+
+        List<Triple> matches = new ArrayList<Triple>() ;
+        for (Triple t2 : triples)
+        {
+            if (t2.matches(s, p, o)) matches.add(t2) ;
+        }
+        return matches ;
+    }
+
+}

Modified: jena/Scratch/AFS/Dev/trunk/src-dev/dev/RunAFS.java
URL: http://svn.apache.org/viewvc/jena/Scratch/AFS/Dev/trunk/src-dev/dev/RunAFS.java?rev=1410974&r1=1410973&r2=1410974&view=diff
==============================================================================
--- jena/Scratch/AFS/Dev/trunk/src-dev/dev/RunAFS.java (original)
+++ jena/Scratch/AFS/Dev/trunk/src-dev/dev/RunAFS.java Sun Nov 18 20:00:10 2012
@@ -26,6 +26,10 @@ import org.apache.jena.iri.Violation ;
 import org.apache.jena.iri.ViolationCodes ;
 import org.openjena.atlas.logging.Log ;
 
+import com.hp.hpl.jena.graph.Graph ;
+import com.hp.hpl.jena.sparql.graph.GraphFactory ;
+import com.hp.hpl.jena.sparql.sse.SSE ;
+
 public class RunAFS
 {
     static { Log.setLog4j() ; }
@@ -39,6 +43,22 @@ public class RunAFS
     
     static public void main(String ... args) throws Exception
     { 
+        String x = "(_:a <p> _:b)" ;
+        
+        Graph g1 = GraphFactory.createGraphMem() ;
+        g1.add(SSE.parseTriple(x)) ;
+        //g1.add(SSE.parseTriple(x)) ;
+        
+        Graph g2 = GraphFactory.createGraphMem() ;
+        g2.add(SSE.parseTriple(x)) ;
+        
+        System.out.println("====") ;
+        SSE.write(g1) ;
+        System.out.println("====") ;
+        SSE.write(g2) ;
+        
+        boolean b = IsoMatcher.isomorphic(g1, g2) ;
+        System.out.println(b) ;
         
     }
     

Modified: jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet.java?rev=1410974&r1=1410973&r2=1410974&view=diff
==============================================================================
--- jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet.java (original)
+++ jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet.java Sun Nov 18 20:00:10 2012
@@ -123,7 +123,7 @@ public abstract class SPARQL_UberServlet
     @Override
     protected void validate(HttpServletRequest request)
     { 
-        // Left to the undeSPARQL_RESTrlying implementations.
+        // Left to the underlying implementations.
     }
 
     @Override