Package com.hp.hpl.jena.reasoner

Examples of com.hp.hpl.jena.reasoner.TriplePattern


        }
    }
   
    /** Instantiate and record a matched subgoal */
    public void noteMatch(TriplePattern pattern, int pc) {
        TriplePattern match = pattern;
        int term = clause.termIndex(pc);  
        if (term >= 0) {                                
            matches[term] = match;
        }
    }
View Full Code Here


    /**
     * Helper - returns the (singleton) value for the given property on the given
     * root node in the data graph.
     */
    public static Node getPropValue(Node root, Node prop, Finder context) {
        return doGetPropValue(context.find(new TriplePattern(root, prop, null)));
    }
View Full Code Here

     * This implementation assumes that the underlying findWithContinuation
     * will have also consulted the raw data.
     */
    @Override
    public ExtendedIterator<Triple> graphBaseFind(Node subject, Node property, Node object) {
        return findWithContinuation(new TriplePattern(subject, property, object), null);
    }
View Full Code Here

     * This may different from the normal find operation in the base of hybrid reasoners
     * where we are side-stepping the backward deduction step.
     */
    @Override
    public ExtendedIterator<Triple> findDataMatches(Node subject, Node predicate, Node object) {
        return findWithContinuation(new TriplePattern(subject, predicate, object), null, false);
    }
View Full Code Here

    /**
     * Convert a triple into a triple pattern by converting var resources into
     * wildcard variables.
     */
    public static TriplePattern tripleToPattern(Triple t) {
        return new TriplePattern(
                        nodeToPattern(t.getSubject()),
                        nodeToPattern(t.getPredicate()),
                        nodeToPattern(t.getObject()));
    }
View Full Code Here

        Graph queryG = loadTestFile(test, queryP);
        Graph resultG = Factory.createGraphMem();

        Iterator<Triple> queries = queryG.find(null, null, null);
        while (queries.hasNext()) {
            TriplePattern query = tripleToPattern( queries.next() );
            logger.debug("Query: " + query);
            Iterator<Triple> answers = graph.find(query.asTripleMatch());
            while (answers.hasNext()) {
                Triple ans = answers.next();
                logger.debug("ans: " + TriplePattern.simplePrintString(ans));
                resultG.add(ans);
            }
View Full Code Here

       
        /**
         * Return the argument index of the given variable.
         */
        int aIndex(Node n) {
            TriplePattern tp = (TriplePattern)rule.getHeadElement(0);
            if (tp.getSubject() == n) {
                return 0;
            } else if (tp.getPredicate() == n) {
                return 1;
            } else if (tp.getObject() == n) {
                return 2;
            } else {
                return -1;
            }
        }
View Full Code Here

               
        /** Return an list of variables or nodes in a ClauseEntry, in flattened order */
        private List<Node> termVars(ClauseEntry term) {
            List<Node> result = new ArrayList<>();
            if (term instanceof TriplePattern) {
                TriplePattern goal = (TriplePattern)term;
                result.add(goal.getSubject());
                result.add(goal.getPredicate());
                Node obj = goal.getObject();
                if (Functor.isFunctor(obj)) {
                    result.add(obj);
                    result.addAll(termVars((Functor)obj.getLiteralValue()));
                } else {
                    result.add(obj);
View Full Code Here

        predicateVar = (p instanceof Node_RuleVariable) ? (Node_RuleVariable) p : null;
        Node o = LPInterpreter.deref(interpreter.argVars[2]);
        objectVar =    (o instanceof Node_RuleVariable) ? (Node_RuleVariable) o : null;
        if (Functor.isFunctor(o)) {
            objectFunctor = (Functor)o.getLiteralValue();
            goal = new TriplePattern(s, p, null);
        } else {
            objectFunctor = null;
            goal = new TriplePattern(s, p, o);
        }
    }
View Full Code Here

       
        Node_RuleVariable xh = new Node_RuleVariable("?x", 0);
        Node_RuleVariable yh = new Node_RuleVariable("?y", 1);
        Node_RuleVariable zh = new Node_RuleVariable("?z", 2);
       
        TriplePattern g1 = new TriplePattern(xg, p, yg);
        TriplePattern g2 = new TriplePattern(xg, p, xg);
        TriplePattern g3 = new TriplePattern( a, p, xg);
        TriplePattern g4 = new TriplePattern( a, p,  b);
       
        TriplePattern h1 = new TriplePattern(xh, p, yh);
        TriplePattern h2 = new TriplePattern(xh, p, xh);
        TriplePattern h3 = new TriplePattern( a, p, xh);
        TriplePattern h4 = new TriplePattern( a, p,  b);
        TriplePattern h5 = new TriplePattern(xh, p,  a);
       
        doTestUnify(g1, h1, true, new Node[] {null, null});
        doTestUnify(g1, h2, true, new Node[] {null, null});
        doTestUnify(g1, h3, true, new Node[] {null, null});
        doTestUnify(g1, h4, true, new Node[] {null, null});
        doTestUnify(g1, h5, true, new Node[] {null, null});
       
        doTestUnify(g2, h1, true, new Node[] {null, xh});
        doTestUnify(g2, h2, true, new Node[] {null, null});
        doTestUnify(g2, h3, true, new Node[] {a, null});
        doTestUnify(g2, h4, false, null);
        doTestUnify(g2, h5, true, new Node[] {a, null});
       
        doTestUnify(g3, h1, true, new Node[] {a, null});
        doTestUnify(g3, h2, true, new Node[] {a, null});
        doTestUnify(g3, h3, true, new Node[] {null, null});
        doTestUnify(g3, h4, true, new Node[] {null, null});
        doTestUnify(g3, h5, true, new Node[] {a, null});
       
        doTestUnify(g4, h1, true, new Node[] {a, b});
        doTestUnify(g4, h2, false, null);
        doTestUnify(g4, h3, true, new Node[] {b});
        doTestUnify(g4, h4, true, null);
        doTestUnify(g4, h5, false, null);
       
        // Recursive case
        doTestUnify(h1, h1, true, new Node[] {null, null});
       
        // Wildcard case
        doTestUnify(new TriplePattern(null, null, null), h2, true, new Node[] {null, null});

        // Test functor cases as well!
        TriplePattern gf = new TriplePattern(xg, p,
                                Functor.makeFunctorNode("f", new Node[]{xg, b}));
        TriplePattern hf1 = new TriplePattern(yh, p,
                                Functor.makeFunctorNode("f", new Node[]{zh, b}));
        TriplePattern hf2 = new TriplePattern(yh, p,
                                Functor.makeFunctorNode("f", new Node[]{a, yh}));
        TriplePattern hf3 = new TriplePattern(yh, p,
                                Functor.makeFunctorNode("f", new Node[]{b, yh}));
        doTestUnify(gf, hf1, true, new Node[] {null, null, yh});
        doTestUnify(gf, hf2, false, null);
        doTestUnify(gf, hf3, true, new Node[] {null, b});
       
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.reasoner.TriplePattern

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.