Examples of RuleList


Examples of lupos.rif.model.RuleList

  @Builtin(Name = "distinct-values")
  public static RuleList distinct_values(final Argument arg) {
    if (arg.arguments.size() == 1
        && arg.arguments.get(0) instanceof RuleList) {
      final RuleList list = (RuleList) arg.arguments.get(0);
      final List<IExpression> newList = Lists.newArrayList();
      for (final IExpression expr : list.getItems())
        if (!newList.contains(expr))
          newList.add(expr);
      list.getItems().clear();
      list.getItems().addAll(newList);
      return list;
    }
    return null;
  }
View Full Code Here

Examples of lupos.rif.model.RuleList

  @Builtin(Name = "intersect")
  public static RuleList intersect(final Argument arg) {
    if (arg.arguments.size() > 0
        && arg.arguments.get(0) instanceof RuleList) {
      final RuleList list = (RuleList) arg.arguments.get(0);
      final List<IExpression> newList = Lists.newArrayList();
      for (final Item item : arg.arguments) {
        for (final IExpression expr : ((RuleList) item).getItems()) {
          boolean contained = true;
          for (final Item item1 : arg.arguments)
            if (!((RuleList) item1).getItems().contains(expr)) {
              contained = false;
              break;
            }
          if (contained && !newList.contains(expr))
            newList.add(expr);
        }
      }
      list.getItems().clear();
      list.getItems().addAll(newList);
      return list;
    }
    return null;
  }
View Full Code Here

Examples of lupos.rif.model.RuleList

  @Builtin(Name = "except")
  public static RuleList except(final Argument arg) {
    if (arg.arguments.size() == 2
        && arg.arguments.get(0) instanceof RuleList
        && arg.arguments.get(1) instanceof RuleList) {
      final RuleList list = (RuleList) arg.arguments.get(0);
      final RuleList listE = (RuleList) arg.arguments.get(1);
      for (final IExpression expr : listE.getItems())
        list.getItems().remove(expr);
      return list;
    }
    return null;
  }
View Full Code Here

Examples of lupos.rif.model.RuleList

  @Builtin(Name = "list-contains", Bindable = true)
  public static Object list_contains(final Argument arg) {
    if (arg.arguments.size() == 2) {

      if(arg.arguments.get(0) instanceof RuleList) {
      final RuleList list1 = (RuleList) arg.arguments.get(0);

      if(arg.arguments.get(1) instanceof RuleList){
        final RuleList list2 = (RuleList) arg.arguments.get(1);
        for (final IExpression expr : list1.getItems()) {
          if (expr.equals(list2)) {
            return BooleanLiteral.TRUE;
          }
        }
View Full Code Here

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

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

    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

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

                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

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

            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

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

            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

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

       
        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
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.