Examples of Term


Examples of aima.core.logic.fol.parsing.ast.Term

    Sentence quantified = sentence.getQuantified();
    Sentence quantifiedAfterSubs = (Sentence) quantified.accept(this, arg);

    List<Variable> variables = new ArrayList<Variable>();
    for (Variable v : sentence.getVariables()) {
      Term st = substitution.get(v);
      if (null != st) {
        if (st instanceof Variable) {
          // Only if it is a variable to I replace it, otherwise
          // I drop it.
          variables.add((Variable) st.copy());
        }
      } else {
        // No substitution for the quantified variable, so
        // keep it.
        variables.add(v.copy());
View Full Code Here

Examples of alice.tuprolog.Term

      throw new IllegalStateException(e);
    }
    if (!info.isSuccess()) {
      throw new IllegalStateException("Failed to call " + goal);
    }
    Term binding;
    try {
      binding = info.getTerm("P");
    } catch (NoSolutionException e) {
      throw new IllegalStateException("Failed to call " + goal, e);
    } catch (UnknownVarException e) {
View Full Code Here

Examples of com.asakusafw.compiler.flow.stage.ShuffleModel.Term

    private Object getKeyGroupField(
            Segment segment,
            String propertyName,
            SegmentedWritable key) {
        Term term = segment.findTerm(propertyName);
        assertThat(propertyName, term, not(nullValue()));
        String fieldName = Naming.getShuffleKeyGroupProperty(
                segment.getElementId(),
                term.getTermId());
        return access(key, fieldName);
    }
View Full Code Here

Examples of com.asakusafw.vocabulary.model.Joined.Term

        Map<Class<?>, Term> terms = Maps.create();
        for (Term term : joined.terms()) {
            terms.put(term.source(), term);
        }
        for (FlowElementPortDescription output : context.getOperatorDescription().getOutputPorts()) {
            Term term = terms.get(output.getDataType());
            assert term != null;
            emitTerm(context, term, inputPort, output);
        }
    }
View Full Code Here

Examples of com.asakusafw.vocabulary.model.Summarized.Term

        Summarized annotation = object.unwrap().getClass().getAnnotation(Summarized.class);
        assertThat(annotation, not(nullValue()));

        loader.setNamespace(Constants.SOURCE_TABLE);

        Term term = annotation.term();
        assertThat(term.source(), eq(loader.modelType("Target")));
        assertThat(term.foldings().length, is(5));
        assertThat(term.foldings(), hasItemInArray(mapping(ANY, "valueA", "key")));
        assertThat(term.foldings(), hasItemInArray(mapping(SUM, "valueB", "sum")));
        assertThat(term.foldings(), hasItemInArray(mapping(COUNT, "sid", "count")));
        assertThat(term.foldings(), hasItemInArray(mapping(MAX, "valueC", "max")));
        assertThat(term.foldings(), hasItemInArray(mapping(MIN, "valueC", "min")));
        assertThat(term.shuffle(), is(grouping("valueA")));
    }
View Full Code Here

Examples of com.esri.ontology.service.catalog.Term

        Filter.any);
      if (path != null) {

        float ii = 1;
        int TopicRecord = numberrecord;
        Term countCat = new Term(key, Relationship.SubClassOf, path.size());
        terms.add(countCat);
        numberrecord++;

        for (Iterator it = path.iterator(); it.hasNext();) {

          Statement statement = (Statement) it.next();
          OntClass onts =
            ontCtx.getModel().getOntClass(statement.getSubject().getNameSpace());
          OntClass onto =
            ontCtx.getModel().getOntClass(statement.getObject().toString());
          if (statement.getPredicate().getLocalName().equalsIgnoreCase(
            "seeAlso")) {
            ii = ii - (1 - queryCriteria.getSeeAlsoWeight());
          } else if (statement.getPredicate().getLocalName().equalsIgnoreCase(
            "subClassOf")) {
            ii = ii - (1 - queryCriteria.getSubClassWeight());
          }
          Term countCatDetails = new Term(onts.getLabel(locale.getLanguage()),
            Relationship.parse(statement.getPredicate().getLocalName()),
            onto.getLabel(locale.getLanguage()), ii);
          terms.add(countCatDetails);
          numberrecord++;
          ii++;

        }
        Term countCat1 = new Term(key, Relationship.SubClassOf, ii - 1);
        terms.set(TopicRecord, countCat1);
      }
    }
  }
View Full Code Here

Examples of com.google.devtools.moe.client.parser.Term

  }

  private RepositoryExpression e(String creatorIdentifier,
                               ImmutableMap<String, String> creatorOptions) {
    return new RepositoryExpression(
        new Term(creatorIdentifier, creatorOptions));
  }
View Full Code Here

Examples of com.googlecode.prolog_cafe.lang.Term

    } catch (OrmException err) {
      return logRuleError("Cannot read patch set " + patchSet.getId(), err);
    }

    List<Term> results = new ArrayList<Term>();
    Term submitRule;
    ProjectState projectState = getProjectControl().getProjectState();
    PrologEnvironment env;

    try {
      env = projectState.newPrologEnvironment();
    } catch (CompileException err) {
      return logRuleError("Cannot consult rules.pl for "
          + getProject().getName(), err);
    }

    try {
      env.set(StoredValues.REVIEW_DB, db);
      env.set(StoredValues.CHANGE, change);
      env.set(StoredValues.CHANGE_DATA, cd);
      env.set(StoredValues.PATCH_SET, patchSet);
      env.set(StoredValues.CHANGE_CONTROL, this);

      submitRule = env.once(
        "gerrit", "locate_submit_rule",
        new VariableTerm());
      if (submitRule == null) {
        return logRuleError("No user:submit_rule found for "
            + getProject().getName());
      }

      if (fastEvalLabels) {
        env.once("gerrit", "assume_range_from_label");
      }

      try {
        for (Term[] template : env.all(
            "gerrit", "can_submit",
            submitRule,
            new VariableTerm())) {
          results.add(template[1]);
        }
      } catch (PrologException err) {
        return logRuleError("Exception calling " + submitRule + " on change "
            + change.getId() + " of " + getProject().getName(), err);
      } catch (RuntimeException err) {
        return logRuleError("Exception calling " + submitRule + " on change "
            + change.getId() + " of " + getProject().getName(), err);
      }

      ProjectState parentState = projectState.getParentState();
      PrologEnvironment childEnv = env;
      Set<Project.NameKey> projectsSeen = new HashSet<Project.NameKey>();
      projectsSeen.add(getProject().getNameKey());

      while (parentState != null) {
        if (!projectsSeen.add(parentState.getProject().getNameKey())) {
          //parent has been seen before, stop walk up inheritance tree
          break;
        }
        PrologEnvironment parentEnv;
        try {
          parentEnv = parentState.newPrologEnvironment();
        } catch (CompileException err) {
          return logRuleError("Cannot consult rules.pl for "
              + parentState.getProject().getName(), err);
        }

        parentEnv.copyStoredValues(childEnv);
        Term filterRule =
            parentEnv.once("gerrit", "locate_submit_filter", new VariableTerm());
        if (filterRule != null) {
          try {
            if (fastEvalLabels) {
              env.once("gerrit", "assume_range_from_label");
            }

            Term resultsTerm = toListTerm(results);
            results.clear();
            Term[] template = parentEnv.once(
                "gerrit", "filter_submit_results",
                filterRule,
                resultsTerm,
                new VariableTerm());
            @SuppressWarnings("unchecked")
            final List<? extends Term> termList = ((ListTerm) template[2]).toJava();
            results.addAll(termList);
          } catch (PrologException err) {
            return logRuleError("Exception calling " + filterRule + " on change "
                + change.getId() + " of " + parentState.getProject().getName(), err);
          } catch (RuntimeException err) {
            return logRuleError("Exception calling " + filterRule + " on change "
                + change.getId() + " of " + parentState.getProject().getName(), err);
          }
        }

        parentState = parentState.getParentState();
        childEnv = parentEnv;
      }
    } finally {
      env.close();
    }

    if (results.isEmpty()) {
      // This should never occur. A well written submit rule will always produce
      // at least one result informing the caller of the labels that are
      // required for this change to be submittable. Each label will indicate
      // whether or not that is actually possible given the permissions.
      log.error("Submit rule " + submitRule + " for change " + change.getId()
          + " of " + getProject().getName() + " has no solution.");
      return ruleError("Project submit rule has no solution");
    }

    // Convert the results from Prolog Cafe's format to Gerrit's common format.
    // can_submit/1 terminates when an ok(P) record is found. Therefore walk
    // the results backwards, using only that ok(P) record if it exists. This
    // skips partial results that occur early in the output. Later after the loop
    // the out collection is reversed to restore it to the original ordering.
    //
    List<SubmitRecord> out = new ArrayList<SubmitRecord>(results.size());
    for (int resultIdx = results.size() - 1; 0 <= resultIdx; resultIdx--) {
      Term submitRecord = results.get(resultIdx);
      SubmitRecord rec = new SubmitRecord();
      out.add(rec);

      if (!submitRecord.isStructure() || 1 != submitRecord.arity()) {
        return logInvalidResult(submitRule, submitRecord);
      }

      if ("ok".equals(submitRecord.name())) {
        rec.status = SubmitRecord.Status.OK;

      } else if ("not_ready".equals(submitRecord.name())) {
        rec.status = SubmitRecord.Status.NOT_READY;

      } else {
        return logInvalidResult(submitRule, submitRecord);
      }

      // Unpack the one argument. This should also be a structure with one
      // argument per label that needs to be reported on to the caller.
      //
      submitRecord = submitRecord.arg(0);

      if (!submitRecord.isStructure()) {
        return logInvalidResult(submitRule, submitRecord);
      }

      rec.labels = new ArrayList<SubmitRecord.Label> (submitRecord.arity());

      for (Term state : ((StructureTerm) submitRecord).args()) {
        if (!state.isStructure() || 2 != state.arity() || !"label".equals(state.name())) {
          return logInvalidResult(submitRule, submitRecord);
        }

        SubmitRecord.Label lbl = new SubmitRecord.Label();
        rec.labels.add(lbl);

        lbl.label = state.arg(0).name();
        Term status = state.arg(1);

        if ("ok".equals(status.name())) {
          lbl.status = SubmitRecord.Label.Status.OK;
          appliedBy(lbl, status);

        } else if ("reject".equals(status.name())) {
          lbl.status = SubmitRecord.Label.Status.REJECT;
          appliedBy(lbl, status);

        } else if ("need".equals(status.name())) {
          lbl.status = SubmitRecord.Label.Status.NEED;

        } else if ("may".equals(status.name())) {
          lbl.status = SubmitRecord.Label.Status.MAY;

        } else if ("impossible".equals(status.name())) {
          lbl.status = SubmitRecord.Label.Status.IMPOSSIBLE;

        } else {
          return logInvalidResult(submitRule, submitRecord);
        }
View Full Code Here

Examples of com.knowgate.hipergate.Term

  oSum.setString(3, getString(DB.gu_workarea));
  oSum.setString(4, getString(DB.gu_product));
  oSum.setString(5, getString(DB.gu_workarea));
  oSum.setString(7, getString(DB.gu_workarea));
   
    Term oZone = new Term();
    oZone.load(oConn, getString(DB.gu_geozone));
    LinkedList oChlds = oZone.getChilds(oConn, Term.SCOPE_ALL);
    ListIterator oIter = oChlds.listIterator();
    while (oIter.hasNext()) {
      oZone = (Term) oIter.next();
    oSum.setString(6, oZone.getString(DB.gu_term));
    oSum.setString(8, oZone.getString(DB.gu_term));
    oRst = oSum.executeQuery();
      oRst.next();
    if (DebugFile.trace)
        DebugFile.writeln("  sales for "+oZone.getString(DB.tx_term)+" = "+String.valueOf(oRst.getFloat(1)));
      fSum += oRst.getFloat(1);
      oRst.close();
    } // wend

  if (DebugFile.trace)
      DebugFile.writeln("  subtotal sales for all child zones = "+String.valueOf(fSum));
   
  oSum.setString(6, getString(DB.gu_geozone));
  oSum.setString(8, getString(DB.gu_geozone));
  oRst = oSum.executeQuery();
    oRst.next();
  if (DebugFile.trace) {
      oZone.load(oConn, getString(DB.gu_geozone));
      DebugFile.writeln("  sales for zone "+oZone.getString(DB.tx_term)+" = "+String.valueOf(oRst.getFloat(1)));
  }
    fSum += oRst.getFloat(1);
    oRst.close();

    oSum.close();
View Full Code Here

Examples of com.knowgate.hipergate.Term

  oUpdt.setString(1,sGuWorkArea);
  oUpdt.setString(2,sGuZone);
  oUpdt.setString(3,sGuProduct);
  iAffected += oUpdt.executeUpdate();

  Term oZone = new Term();
  oZone.load(oConn, sGuZone);
  String sGuParent = oZone.getParent(oConn);
 
  while (sGuParent!=null) {   
    oUpdt.setString(1,sGuWorkArea);
    oUpdt.setString(2,sGuParent);
    oUpdt.setString(3,sGuProduct);
    iAffected += oUpdt.executeUpdate();
    oZone.load(oConn, sGuParent);
    sGuParent = oZone.getParent(oConn);   
  } // wend
 
  oUpdt.close();
  return iAffected;                                
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.