Package com.hp.hpl.jena.reasoner.rulesys

Examples of com.hp.hpl.jena.reasoner.rulesys.Rule$Parser


    this.path = path;

    documentManager.attachToEditor(document, editor);

    Parser codeMirrorParser = CodeMirror2.getParser(path);
    parser = codeMirrorParser == null ? null
        : DocumentParser.create(document, codeMirrorParser, userActivityManager);

    LanguageHelper languageHelper = LanguageHelperResolver.getHelper(parser.getSyntaxType());
    RootActionExecutor actionExecutor = editor.getInput().getActionExecutor();
View Full Code Here


      parser.teardown();
      parser = null;
    }


    Parser codeMirrorParser = CodeMirror2.getParser(path);
    parser = DocumentParser.create(document, codeMirrorParser, userActivityManager);
    Preconditions.checkNotNull(parser);

    editor.setDocument(document);
    editor.addLineRenderer(diffRenderer);
View Full Code Here

        path, false, new MockIncrementalScheduler(), Document.createEmpty());
  }

  public static DocumentParser createDocumentParser(PathUtil path, boolean setupRealParser,
      IncrementalScheduler scheduler, Document document) {
    Parser parser = setupRealParser ? CodeMirror2.getParser(path)
        : new MockParser(SyntaxType.syntaxTypeByFilePath(path));
    return DocumentParser.create(document, parser, scheduler);
  }
View Full Code Here

    private static Model empty = ModelFactory.createDefaultModel();
   
    @Test public void testEmptyBlankNode()
        {
        Model m = ModelFactory.createDefaultModel();
        Resource r = new Parser( "[]" ).resourceIn( m );
        assertIsoModels( empty, m );
        assertTrue( r.isAnon() );
        }
View Full Code Here

        }
   
    @Test public void testResourceURI()
        {
        Model m = ModelFactory.createDefaultModel();
        Resource r = new Parser( "noProperties" ).resourceIn( m );
        assertIsoModels( empty, m );
        assertEquals( ModelTestBase.resource( "noProperties" ), r );
        }
View Full Code Here

        }
   
    private Resource parseAsResource( String modelString )
        {
        Model m = ModelFactory.createDefaultModel();
        return new Parser( modelString ).resourceIn( m );
        }
View Full Code Here

    protected Model m( String s )
        { return modelWithStatements( s ); }

    protected Model parse( String s )
        { Model m = createModel( ReificationStyle.Standard );
        Model mDash = new Parser( s ).parseInto( m );
        assertSame( m, mDash );
        return m; }
View Full Code Here

    protected OntModel ontModel( String facts )
        {
        OntModel result =  ModelFactory.createOntologyModel();
        result.setNsPrefixes( PrefixMapping.Extended );
        setRequiredPrefixes( result );
        new Parser( facts ).parseInto( result );
        return result;
        }
View Full Code Here

    /**
        Eyeball test models are constructed using the extended parser.
    */
    protected Model modelAddFacts( Model result, String s )
        { return new Parser( s ).parseInto( result ); }
View Full Code Here

   
    /**
     * Execute a single rule firing.
     */
    public static void execute(RETERuleContext context, boolean isAdd) {
        Rule rule = context.getRule();
        BindingEnvironment env = context.getEnv();
        ForwardRuleInfGraphI infGraph = (ForwardRuleInfGraphI)context.getGraph();
        if (infGraph.shouldTrace()) {
            logger.info("Fired rule: " + rule.toShortString());
        }
        RETEEngine engine = context.getEngine();
        engine.incRuleCount();
        List<Triple> matchList = null;
        if (infGraph.shouldLogDerivations() && isAdd) {
            // Create derivation record
            matchList = new ArrayList<Triple>(rule.bodyLength());
            for (int i = 0; i < rule.bodyLength(); i++) {
                Object clause = rule.getBodyElement(i);
                if (clause instanceof TriplePattern) {
                    matchList.add(env.instantiate((TriplePattern)clause));
                }
            }
        }
        for (int i = 0; i < rule.headLength(); i++) {
            Object hClause = rule.getHeadElement(i);
            if (hClause instanceof TriplePattern) {
                Triple t = env.instantiate((TriplePattern) hClause);
                // Used to filter out triples with literal subjects
                // but this is not necessary
                // if (!t.getSubject().isLiteral()) {
                    // Only add the result if it is legal at the RDF level.
                    // E.g. RDFS rules can create assertions about literals
                    // that we can't record in RDF
                    if (isAdd) {
                        if ( ! context.contains(t) ) {
                            engine.addTriple(t, true);
                            if (infGraph.shouldLogDerivations()) {
                                infGraph.logDerivation(t, new RuleDerivation(rule, t, matchList, infGraph));
                            }
                        }
                    } else {
                        if ( context.contains(t)) {
                            // Remove the generated triple
                            engine.deleteTriple(t, true);
                        }
                    }
              // }
            } else if (hClause instanceof Functor && isAdd) {
                Functor f = (Functor)hClause;
                Builtin imp = f.getImplementor();
                if (imp != null) {
                    imp.headAction(f.getBoundArgs(env), f.getArgLength(), context);
                } else {
                    throw new ReasonerException("Invoking undefined Functor " + f.getName() +" in " + rule.toShortString());
                }
            } else if (hClause instanceof Rule) {
                Rule r = (Rule)hClause;
                if (r.isBackward()) {
                    if (isAdd) {
                        infGraph.addBRule(r.instantiate(env));
                    } else {
                        infGraph.deleteBRule(r.instantiate(env));
                    }
                } else {
                    throw new ReasonerException("Found non-backward subrule : " + r);
                }
            }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.reasoner.rulesys.Rule$Parser

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.