Package lupos.rif.model

Examples of lupos.rif.model.Conjunction


  }

  private BasicOperator[] patternFromConclusion(final IExpression conclusion) {
    BasicOperator[] result;
    if(conclusion instanceof Conjunction){
      final Conjunction conjunction = (Conjunction) conclusion;
      result = new BasicOperator[conjunction.exprs.size()];
      int i = 0;
      for(final IExpression elem: conjunction.exprs) {
        result[i] = this.onePatternFromConclusion(elem);
        i++;
View Full Code Here


    // nur eine Aussage
    if (n.f0.which == 0)
      parent.setHead((IExpression) n.f0.choice.accept(this, argu));
    else {
      // And-verknuepfte Aussagen   
      final Conjunction conj = new Conjunction();
      conj.setParent(parent);
      for (final INode node : (List<INode>) ((List<INode>) n.f0.choice.accept(this, argu)).get(2).accept(this, argu))
        conj.addExpr((IExpression) node.accept(this, argu));
      if (!conj.isEmpty())
        parent.setHead(conj);
    }
    if (n.f1.present()){
      List<INode> bodyList = (List<INode>) n.f1.node.accept(this, argu);
      parent.setBody((IExpression) bodyList.get(1).accept(this, argu));
View Full Code Here

  public Object visit(final RIFFormula n, final IRuleNode argu) {
    switch (n.f0.which) {
    case 0:
      final NodeListOptional andFormulas = (NodeListOptional) ((List<INode>) n.f0.choice
          .accept(this, argu)).get(2);
      final Conjunction conj = new Conjunction();
      conj.setParent(argu);
      for (final INode node : (List<INode>) andFormulas
          .accept(this, conj))
        conj.addExpr((IExpression) node.accept(this, conj));
      return conj;
    case 1:
      final NodeListOptional orFormulas = (NodeListOptional) ((List<INode>) n.f0.choice
          .accept(this, argu)).get(2);
      final Disjunction disj = new Disjunction();
View Full Code Here

    return term;
  }

  public Object visit(final RIFFrame n, final IRuleNode argu) {
    final List<INode> args = (List<INode>) n.f1.accept(this, argu);
    final AbstractExpressionContainer and = new Conjunction();
    for (final INode node : args) {
      final List<INode> nodeSeq = (List<INode>) node.accept(this, argu);
      final Uniterm term = new RulePredicate(true);
      term.setParent(argu);
      term.termName = (IExpression) nodeSeq.get(0).accept(this, term);
      term.termParams.add((IExpression) ((RIFAtomic)n.getParent().getParent().getParent()).f0.accept(this, term));
      term.termParams
          .add((IExpression) nodeSeq.get(2).accept(this, term));
      if (args.size() == 1)
        return term;
      else
        and.addExpr(term);
    }
    return and;
  }
View Full Code Here

  throws RIFException {
    throw new UnsupportedOperationException();
  }

  public IRuleNode visit(Conjunction obj, IRuleNode arg) throws RIFException {
    final Conjunction result = new Conjunction();
    result.setParent(arg);
    List<IExpression> exprs = new ArrayList<IExpression>(obj.exprs);
    for (IExpression expr : exprs)
      result.exprs.add((IExpression) expr.accept(this, result));
    return result;
  }
View Full Code Here

  }

  public IRuleNode visit(RulePredicate obj, IRuleNode arg)
      throws RIFException {
    obj.setParent(arg);
    Conjunction conjunction = null;
    List<IExpression> items = new ArrayList<IExpression>(obj.termParams);
    obj.termParams.clear();
    for (IExpression expr : items) {
      final IRuleNode result = expr.accept(this, obj);
      if (result instanceof Conjunction) {
        conjunction = conjunction == null ? new Conjunction()
            : conjunction;
        for (IExpression item : ((Conjunction) result).exprs)
          if (item instanceof RulePredicate)
            conjunction.addExpr(item);
          else if (item instanceof RuleVariable)
            obj.termParams.add(item);
      } else
        obj.termParams.add((IExpression) result);
    }
    if (conjunction != null)
      conjunction.addExpr(obj);
    return conjunction == null ? obj : conjunction;
  }
View Full Code Here

        return new Constant(
            LiteralFactory
                .createURILiteral("<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>"),
            arg);
      }
      Conjunction conjunction = new Conjunction();
      conjunction.setParent(arg);
      int iteration = 0;
      //Listenidentifikator erstellen
      String baseName = aliasString + "list" + listCtr++ + "it";
      conjunction.addExpr(new RuleVariable(baseName + iteration));
      int ctr = obj.getItems().size();
      for (IExpression expr : obj.getItems()) {
        ctr--;
        IRuleNode result = expr.accept(this, conjunction);
        final String itVar = baseName + iteration++;
        if (result instanceof Conjunction) {
          for (IExpression item : new ArrayList<IExpression>(
              ((Conjunction) result).exprs))
            if (item instanceof RulePredicate)
              conjunction.addExpr(item);
            else if (item instanceof RuleVariable)
              result = item;
        }
        final RulePredicate item = new RulePredicate(
            new RuleVariable(itVar),
            new Constant(
                LiteralFactory
                    .createURILiteral("<http://www.w3.org/1999/02/22-rdf-syntax-ns#first>"),
                arg), (IExpression) result);
        conjunction.addExpr(item);
        final RulePredicate next = new RulePredicate(
            new RuleVariable(itVar),
            new Constant(
                LiteralFactory
                    .createURILiteral("<http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>"),
                arg),
            ctr == 0 ? new Constant(
                LiteralFactory
                    .createURILiteral("<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>"),
                arg)
                : new RuleVariable(baseName + iteration));
        conjunction.addExpr(next);
        currentVariableScope.addVariable(new RuleVariable(itVar));
      }
      return conjunction;
    } catch (URISyntaxException e) {
      throw new RIFException(e.getMessage());
View Full Code Here

    if (!(obj.getBody() instanceof External))
      obj.setBody((IExpression) obj.getBody().accept(this, obj));

    // dem Body hinzufuegen
    if (!equalities.isEmpty()) {
      Conjunction conj = new Conjunction();
      conj.setParent(obj);
      for (Equality eq : equalities)
        conj.addExpr(eq);
      conj.addExpr(obj.getBody());
      obj.setBody(conj);
    }
    return obj;
  }
View Full Code Here

    }
    return obj;
  }

  public IRuleNode visit(External obj, Object arg) throws RIFException {
    final Conjunction conjunction = new Conjunction();
    conjunction.setParent((IRuleNode) arg);

    RuleVariable alias = new RuleVariable(aliasString + aliasCtr++);
    conjunction.addExpr(alias);

    Equality comp = new Equality();
    comp.leftExpr = new RuleVariable(alias.getName());
    comp.leftExpr.setParent(comp);
    comp.rightExpr = obj;
    obj.setParent(comp);
    conjunction.addExpr(comp);

    currentVariableScope.addVariable(new RuleVariable(alias.getName()));
    return conjunction;
  }
View Full Code Here

    currentVariableScope.addVariable(new RuleVariable(alias.getName()));
    return conjunction;
  }

  public IRuleNode visit(RulePredicate obj, Object arg) throws RIFException {
    Conjunction conjunction = null;
    // Funktionsaufrufe mit Variable ersetzen
    ArrayList<IExpression> params = new ArrayList<IExpression>(
        obj.termParams);
    // Relationen koennen keine Externals sein.
    for (IExpression expr : obj.termParams) {
      final IRuleNode result = expr.accept(this, obj);
      if (result instanceof Conjunction) {
        conjunction = conjunction == null ? new Conjunction()
            : conjunction;
        for (IExpression item : ((Conjunction) result).exprs)
          if (item instanceof Equality)
            conjunction.addExpr(item);
          else
            params.set(params.indexOf(expr), item);
      }
    }
    obj.termParams = params;
    if (conjunction != null)
      conjunction.addExpr(obj);
    return conjunction == null ? obj : conjunction;
  }
View Full Code Here

TOP

Related Classes of lupos.rif.model.Conjunction

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.