Package wyrl.core

Examples of wyrl.core.Type$Bag


            return true;
        }
        if (object instanceof Bag == false) {
            return false;
        }
        Bag other = (Bag) object;
        if (other.size() != size()) {
            return false;
        }
        for (Iterator<E> it = map.keySet().iterator(); it.hasNext();) {
            E element = it.next();
            if (other.getCount(element) != getCount(element)) {
                return false;
            }
        }
        return true;
    }
View Full Code Here


  }

  //loads the files and removes words which occur less than 5 tims
  public void loadProgram() throws FileNotFoundException
  {
    Bag wordBag = new HashBag();

    //Load all the medical files in the directory
    File[] fileList = new File(recordsDir).listFiles();
    for (int i = 0; i<fileList.length; i++) {
      loadFile(fileList[i].toString(), wordBag);
    }

    //dump bag into frequent who appear in 5 or more medical records
    for (Object obj : wordBag.uniqueSet()) {
      if (wordBag.getCount(obj) > 4){
        frequent.add((String)obj);
      }
    }

  }
View Full Code Here

    if (decl.type.element() == null) {
      myOut(1, "public final static Automaton.Term " + name
          + " = new Automaton.Term(K_" + name + ");");
    } else {
      Type.Ref<?> data = decl.type.element();
      Type element = data.element();
      if (element instanceof Type.Collection) {
        // add two helpers
        myOut(1, "public final static int " + name
            + "(Automaton automaton, int... r0) {");
        if (element instanceof Type.Set) {
View Full Code Here

  public void translate(RewriteDecl decl, SpecFile file) {
    register(decl.pattern);

    boolean isReduction = decl instanceof ReduceDecl;
    Type param = decl.pattern.attribute(Attribute.Type.class).type;

    if(decl.name != null) {
      myOut(1, "// " + decl.name);
    }
View Full Code Here

    }
  }

  public int translatePatternMatch(int level, Pattern.Leaf pattern,
      Type declared, int source, Environment environment) {
    Type element = pattern.type().element();

    if (element == Type.T_ANY() || element.isSubtype(declared)) {
      // In this very special case, we don't need to do anything since
      // we're guarantted to have a match based on the context.
      return level;
    } else {
      int typeIndex = register(pattern.type);
View Full Code Here

    // Third, check all remaining elements against the unbounded match.
    // ====================================================================

    int lastPatternElementIndex = pattern_elements.length-1;
    Pattern lastPatternElement = pattern_elements[lastPatternElementIndex].first();
    Type lastDeclaredElement = declared_elements[declared_elements.length-1];
    int element = environment.allocate(Type.T_VOID());

    if(!willSkip(lastPatternElement,lastDeclaredElement)) {

      // Only include the loop if we really need it. In many cases, this
View Full Code Here

    // ====================================================================
    // Third, check all remaining elements against the unbounded match.
    // ====================================================================
    int lastPatternElementIndex = pattern_elements.length-1;
    Pattern lastPatternElement = pattern_elements[lastPatternElementIndex].first();
    Type lastDeclaredElement = declared_elements[declared_elements.length-1];
    int item = environment.allocate(Type.T_VOID());

    if(!willSkip(lastPatternElement,lastDeclaredElement)) {

      // Only include the loop if we really need it. In many cases, this
View Full Code Here

  protected boolean willSkip(Pattern pattern, Type declared) {
    declared = stripNominalsAndRefs(declared);

    if (pattern instanceof Pattern.Leaf) {
      Pattern.Leaf leaf = (Pattern.Leaf) pattern;
      Type element = leaf.type().element();

      if (element == Type.T_ANY() || element.isSubtype(declared)) {
        // In this very special case, we don't need to do anything since
        // we're guarantted to have a match based on the context.
        return true;
      }
    } else if (pattern instanceof Pattern.Term
View Full Code Here

    myOut(1,
        "// =========================================================================");
    myOut();

    for (int i = 0; i != typeRegister.size(); ++i) {
      Type t = typeRegister.get(i);
      JavaIdentifierOutputStream jout = new JavaIdentifierOutputStream();
      BinaryOutputStream bout = new BinaryOutputStream(jout);
      bout.write(t.toBytes());
      bout.flush();
      bout.close();
      // FIXME: strip out nominal types (and any other unneeded types).
      myOut(1, "// " + t);
      myOut(1, "private static Type type" + i + " = Runtime.Type(\""
View Full Code Here

    }
  }

  public int translate(int level, Expr.Cast code, Environment environment,
      SpecFile file) {
    Type type = code.attribute(Attribute.Type.class).type;

    // first translate src expression, and coerce to a value
    int src = translate(level, code.src, environment, file);
    src = coerceFromRef(level, code.src, src, environment);
View Full Code Here

TOP

Related Classes of wyrl.core.Type$Bag

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.