Esempio n. 1
0
  /** Function to stores header of a data file. */
  private void readHeader() {
    String attributeName;
    Vector attributeValues;
    int i;

    name = Attributes.getRelationName();

    // Create vectors to hold information temporarily.
    attributes = new Vector();

    Attribute at;

    // store attribute inputs and of the header
    for (int j = 0; j < Attributes.getInputNumAttributes(); j++) {
      at = Attributes.getInputAttribute(j);
      attributeName = at.getName();

      // check if it is real
      if (at.getType() == 2) {
        float min = (float) at.getMinAttribute();
        float max = (float) at.getMinAttribute();
        attributes.addElement(new MyAttribute(attributeName, j));
        MyAttribute att = (MyAttribute) attributes.elementAt(j);
        att.setRange(min, max);
        att.activate();
      } else {
        if (at.getType() == 1) // check if it is integer
        {
          int min = (int) at.getMinAttribute();
          int max = (int) at.getMinAttribute();
          attributes.addElement(new MyAttribute(attributeName, j));
          MyAttribute att = (MyAttribute) attributes.elementAt(j);
          att.setRange(min, max);
          att.activate();
        } else // it is nominal
        {
          attributeValues = new Vector();
          for (int k = 0; k < at.getNumNominalValues(); k++) {
            attributeValues.addElement(at.getNominalValue(k));
          }
          attributes.addElement(new MyAttribute(attributeName, attributeValues, j));
          MyAttribute att = (MyAttribute) attributes.elementAt(j);
          att.activate();
        }
      }
    } // for

    // store outputs of the header
    at = Attributes.getOutputAttribute(0);
    attributeName = at.getName();

    int j = Attributes.getNumAttributes() - 1;

    // check if it is real
    if (at.getType() == 2) {
      float min = (float) at.getMinAttribute();
      float max = (float) at.getMinAttribute();
      attributes.addElement(new MyAttribute(attributeName, j));
      MyAttribute att = (MyAttribute) attributes.elementAt(j);
      att.setRange(min, max);
      att.activate();
    } else {
      if (at.getType() == 1) // check if it is integer
      {
        int min = (int) at.getMinAttribute();
        int max = (int) at.getMinAttribute();
        attributes.addElement(new MyAttribute(attributeName, j));
        MyAttribute att = (MyAttribute) attributes.elementAt(j);
        att.setRange(min, max);
        att.activate();
      } else // it is nominal
      {
        attributeValues = new Vector();
        for (int k = 0; k < at.getNumNominalValues(); k++) {
          attributeValues.addElement(at.getNominalValue(k));
        }
        attributes.addElement(new MyAttribute(attributeName, attributeValues, j));
        MyAttribute att = (MyAttribute) attributes.elementAt(j);
        att.activate();
      }
    }

    // set the index of the output class
    classIndex = Attributes.getNumAttributes() - 1;
  }