Examples of KiWiTriple


Examples of org.apache.marmotta.kiwi.model.rdf.KiWiTriple

                    object = ((LiteralField)rule.getHead().getObject()).getLiteral();
                } else
                    throw new IllegalArgumentException("Object of rule head may only be a variable, a literal, or a resource; rule: "+rule);


                KiWiTriple triple = isail.addInferredStatement(subject, property, object);

                Justification justification = new Justification();
                justification.setTriple(triple);
                justification.getSupportingRules().add(rule);
                justification.getSupportingTriples().addAll(row.getJustifications());
View Full Code Here

Examples of org.apache.marmotta.kiwi.model.rdf.KiWiTriple

    protected Set<Justification> getBaseJustifications(KiWiReasoningConnection connection, Set<Justification> justifications) throws SQLException, ReasoningException {
        Set<Justification> baseJustifications = new HashSet<Justification>();
        Map<KiWiTriple,Collection<Justification>> justificationCache = StatementCommons.newQuadrupleMap();

        for(Justification justification : justifications) {
            KiWiTriple triple = justification.getTriple();

            Justification newJustification = new Justification();
            newJustification.setSupportingRules(justification.getSupportingRules());
            newJustification.setTriple(triple);
View Full Code Here

Examples of org.apache.marmotta.kiwi.model.rdf.KiWiTriple

            // 1) the expected inferred triple exists
            // 2) the inferred triple is properly justified (based on rule2 and on the triple contained in the transaction data)
            List<Statement> inferred = Iterations.asList(con.getStatements(object,property,subject, true));
            Assert.assertEquals("number of inferred triples differs from expected result",1,inferred.size());

            KiWiTriple triple = (KiWiTriple)inferred.get(0);
            List<Justification> justifications = Iterations.asList(rcon.listJustificationsForTriple(triple));
            Assert.assertEquals("number of justifications for triple differs from expected result",1,justifications.size());

            Justification j = justifications.get(0);
            Assert.assertEquals("number of supporting triples differs from expected result",1,j.getSupportingTriples().size());
View Full Code Here

Examples of org.apache.marmotta.kiwi.model.rdf.KiWiTriple

            // 1) the expected inferred triple exists (must be (ex:a ex:transitive ex:c) )
            // 2) the inferred triple is properly justified (based on rule2 and on the triple contained in the transaction data)
            List<Statement> inferred = Iterations.asList(con.getStatements(a,property,c, true));
            Assert.assertEquals("number of inferred triples differs from expected result",1,inferred.size());

            KiWiTriple triple = (KiWiTriple)inferred.get(0);
            List<Justification> justifications = Iterations.asList(rcon.listJustificationsForTriple(triple));
            Assert.assertEquals("number of justifications for triple differs from expected result",1,justifications.size());

            Justification j = justifications.get(0);
            Assert.assertEquals("number of supporting triples differs from expected result",2,j.getSupportingTriples().size());
View Full Code Here

Examples of org.apache.marmotta.kiwi.model.rdf.KiWiTriple

            Set<KiWiTriple> added = new HashSet<KiWiTriple>();
            for(Resource context : contextSet) {
                KiWiResource kcontext = valueFactory.convert(context);

                KiWiTriple triple = (KiWiTriple)valueFactory.createStatement(ksubj,kpred,kobj,kcontext, databaseConnection);
                triple.setInferred(inferred);

                if(databaseConnection.storeTriple(triple)) {
                    triplesAdded = true;
                    notifyStatementAdded(triple);
                }
View Full Code Here

Examples of org.apache.marmotta.kiwi.model.rdf.KiWiTriple

    @Override
    protected void removeStatementsInternal(Resource subj, URI pred, Value obj, Resource... contexts) throws SailException {
        try {
            CloseableIteration<? extends Statement, SailException> triples = getStatementsInternal(subj,pred,obj,true,contexts);
            while(triples.hasNext()) {
                KiWiTriple triple = (KiWiTriple)triples.next();
                if(triple.getId() != null) {
                    databaseConnection.deleteTriple(triple);
                    triplesRemoved = true;
                    notifyStatementRemoved(triple);
                }
                valueFactory.removeStatement(triple);
View Full Code Here

Examples of org.apache.marmotta.kiwi.model.rdf.KiWiTriple

    @Override
    public boolean removeInferredStatement(Resource subj, URI pred, Value obj, Resource... contexts) throws SailException {
        try {
            CloseableIteration<? extends Statement, SailException> triples = getStatementsInternal(subj,pred,obj,true,valueFactory.createURI(inferredContext));
            while(triples.hasNext()) {
                KiWiTriple triple = (KiWiTriple)triples.next();
                if(triple.getId() != null && triple.isInferred()) {
                    databaseConnection.deleteTriple(triple);
                    triplesRemoved = true;
                    notifyStatementRemoved(triple);
                }
                valueFactory.removeStatement(triple);
View Full Code Here

Examples of org.apache.marmotta.kiwi.model.rdf.KiWiTriple

            // we manually update the "inferred" flag for all inferred triples, since this is not possible through the
            // repository API
            PreparedStatement updateInferred = connection.getJDBCConnection().prepareStatement("UPDATE triples SET inferred = true WHERE id = ?");
            for(Statement stmt : infTriples) {
                KiWiTriple triple = (KiWiTriple)stmt;
                updateInferred.setLong(1,triple.getId());
                updateInferred.addBatch();
            }
            updateInferred.executeBatch();
            updateInferred.close();
View Full Code Here

Examples of org.apache.marmotta.kiwi.model.rdf.KiWiTriple

                    tjs.add(j);
                }
                result.append("[");

                for(Iterator<KiWiTriple> it = grouped.keySet().iterator(); it.hasNext(); ) {
                    KiWiTriple t = it.next();
                    result.append(formatJSON(t, grouped.get(t)));

                    if(it.hasNext()) {
                        result.append(",\n");
                    } else {
View Full Code Here

Examples of org.apache.marmotta.kiwi.model.rdf.KiWiTriple

        for(Iterator<Justification> justs = justifications.iterator(); justs.hasNext(); ) {
            Justification justification = justs.next();
            result.append("  {\n");
            result.append("    \"triples\": [\n");
            for(Iterator<KiWiTriple> it = justification.getSupportingTriples().iterator(); it.hasNext(); ) {
                KiWiTriple t = it.next();
                result.append("      " + formatJSON(t));
                if(it.hasNext()) {
                    result.append(",\n");
                } else {
                    result.append("\n");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.