Package org.apache.stanbol.rules.base.api.util

Examples of org.apache.stanbol.rules.base.api.util.RuleList


        UriRef recipeID = recipe.getRecipeID();
        String namespace = recipeID.toString().substring(1, recipeID.toString().length() - 1) + "/";
       
        log.info("Rule Namespace is " + namespace);
        RuleList ruleList = RuleParserImpl.parse(namespace, rulesStream).getRuleList();

        for (Rule rule : ruleList) {
            recipe = addRuleToRecipe(recipe, rule, description);
        }
View Full Code Here


    public Recipe addRulesToRecipe(Recipe recipe, String stanbolRule, String description) {

        UriRef recipeID = recipe.getRecipeID();
        String namespace = recipeID.toString().substring(1, recipeID.toString().length() - 1) + "/";

        RuleList ruleList = RuleParserImpl.parse(namespace, stanbolRule).getRuleList();

        for (Rule rule : ruleList) {
            recipe = addRuleToRecipe(recipe, rule, description);
        }
View Full Code Here

                stanbolRulesBuilder.append(stanbolSyntax);
            }

            String stanbolSyntax = stanbolRulesBuilder.toString();

            RuleList ruleList = null;
            if (!stanbolSyntax.isEmpty()) {
                String namespace = recipeID.toString().substring(1, recipeID.toString().length() - 1) + "/";
                ruleList = RuleParserImpl.parse(namespace, stanbolSyntax).getRuleList();
            }
View Full Code Here

            tripleCollections[i] = tcManager.getMGraph(recipeIDs.get(i));
        }

        UnionMGraph unionMGraph = new UnionMGraph(tripleCollections);

        RuleList matchingRules = new RuleList();

        try {

            SelectQuery query = (SelectQuery) QueryParser.getInstance().parse(sparql);

            ResultSet resultSet = tcManager.executeSparqlQuery(query, unionMGraph);

            while (resultSet.hasNext()) {
                SolutionMapping solutionMapping = resultSet.next();
                UriRef recipeID = (UriRef) solutionMapping.get("recipe");
                UriRef ruleID = (UriRef) solutionMapping.get("rule");
                Literal description = (Literal) solutionMapping.get("description");

                try {
                    Recipe recipe = getRecipe(recipeID);
                    Rule rule = new RecipeRule(recipe, getRule(recipe, ruleID));
                    if (description != null) {
                        rule.setDescription(description.getLexicalForm());
                    }

                    matchingRules.add(rule);
                } catch (NoSuchRecipeException e) {
                    // in this case go on in the iteration by fetching other matching recipes
                } catch (RecipeConstructionException e) {
                    // in this case go on in the iteration by fetching other matching recipes
                } catch (NoSuchRuleInRecipeException e) {
View Full Code Here

            tripleCollections[i] = tcManager.getMGraph(recipeIDs.get(i));
        }

        UnionMGraph unionMGraph = new UnionMGraph(tripleCollections);

        RuleList matchingRules = new RuleList();

        try {

            SelectQuery query = (SelectQuery) QueryParser.getInstance().parse(sparql);

            ResultSet resultSet = tcManager.executeSparqlQuery(query, unionMGraph);

            while (resultSet.hasNext()) {
                SolutionMapping solutionMapping = resultSet.next();
                UriRef recipeID = (UriRef) solutionMapping.get("recipe");
                UriRef ruleID = (UriRef) solutionMapping.get("rule");
                Literal description = (Literal) solutionMapping.get("description");

                try {
                    Recipe recipe = getRecipe(recipeID);
                    Rule rule = new RecipeRule(recipe, getRule(recipe, ruleID));
                    if (description != null) {
                        rule.setDescription(description.getLexicalForm());
                    }

                    matchingRules.add(rule);
                } catch (NoSuchRecipeException e) {
                    // in this case go on in the iteration by fetching other matching recipes
                } catch (RecipeConstructionException e) {
                    // in this case go on in the iteration by fetching other matching recipes
                } catch (NoSuchRuleInRecipeException e) {
View Full Code Here

       
        InputStream inputStream;
        try {
            inputStream = new FileInputStream(new File("/Users/mac/Desktop/domain.rule"));
           
            RuleList ruleList = RuleParserImpl.parse("http://www.prova.it/", inputStream).getRuleList();

            for (Rule rule : ruleList) {
               
            }
        } catch (FileNotFoundException e) {
View Full Code Here

        List<com.hp.hpl.jena.reasoner.rulesys.Rule> jenaRules = null;

        if (type == com.hp.hpl.jena.reasoner.rulesys.Rule.class) {

            RuleList ruleList = recipe.getRuleList();
            Iterator<Rule> ruleIterator = ruleList.iterator();

            jenaRules = new ArrayList<com.hp.hpl.jena.reasoner.rulesys.Rule>();
            for (int i = 0; ruleIterator.hasNext(); i++) {
                jenaRules.add((com.hp.hpl.jena.reasoner.rulesys.Rule) adaptRuleTo(ruleIterator.next(), type));
            }
View Full Code Here

        List<SWRLRule> swrlRules = null;

        if (type == SWRLRule.class) {

            RuleList ruleList = recipe.getRuleList();

            swrlRules = new ArrayList<SWRLRule>();

            if (ruleList != null && !ruleList.isEmpty()) {

                Iterator<Rule> ruleIterator = ruleList.iterator();

                while (ruleIterator.hasNext()) {
                    Rule rule = ruleIterator.next();
                    swrlRules.add(adaptRuleTo(rule, SWRLRule.class));
                }
View Full Code Here

        List<SPARQLObject> sparqlObjects = null;

        if (type == SPARQLObject.class) {

            RuleList ruleList = recipe.getRuleList();
            Iterator<Rule> ruleIterator = ruleList.iterator();

            sparqlObjects = new ArrayList<SPARQLObject>();
            for (int i = 0; ruleIterator.hasNext(); i++) {
                sparqlObjects.add((SPARQLObject) adaptRuleTo(ruleIterator.next(), type));
            }
View Full Code Here

    public KB(String ruleNamespace) {
        log.debug("Setting up a KReSKB");
        prefixes = new Hashtable<String,String>();
        prefixes.put("var", Symbols.variablesPrefix);
        prefixes.put("rmi2", ruleNamespace);
        ruleList = new RuleList();
    }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.rules.base.api.util.RuleList

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.