Пример #1
0
  /**
   * Returns the Capabilities of this filter, customized based on the data. I.e., if removes all
   * class capabilities, in case there's not class attribute present or removes the NO_CLASS
   * capability, in case that there's a class present.
   *
   * @param data the data to use for customization
   * @return the capabilities of this object, based on the data
   * @see #getCapabilities()
   */
  public Capabilities getCapabilities(Instances data) {
    Capabilities result;
    Capabilities classes;
    Iterator iter;
    Capability cap;

    result = getCapabilities();

    // no class? -> remove all class capabilites apart from NO_CLASS
    if (data.classIndex() == -1) {
      classes = result.getClassCapabilities();
      iter = classes.capabilities();
      while (iter.hasNext()) {
        cap = (Capability) iter.next();
        if (cap != Capability.NO_CLASS) {
          result.disable(cap);
          result.disableDependency(cap);
        }
      }
    }
    // class? -> remove NO_CLASS
    else {
      result.disable(Capability.NO_CLASS);
      result.disableDependency(Capability.NO_CLASS);
    }

    return result;
  }
Пример #2
0
  /**
   * retrieves the data from the given Capabilities object
   *
   * @param c the capabilities object to initialize with
   */
  public void assign(Capabilities c) {
    for (Capability cap : Capability.values()) {
      // capability
      if (c.handles(cap)) enable(cap);
      else disable(cap);
      // dependency
      if (c.hasDependency(cap)) enableDependency(cap);
      else disableDependency(cap);
    }

    setMinimumNumberInstances(c.getMinimumNumberInstances());
  }
Пример #3
0
  /**
   * disables the dependency of the given capability Disabling NOMINAL_ATTRIBUTES also disables
   * BINARY_ATTRIBUTES, UNARY_ATTRIBUTES and EMPTY_NOMINAL_ATTRIBUTES. Disabling BINARY_ATTRIBUTES
   * also disables UNARY_ATTRIBUTES and EMPTY_NOMINAL_ATTRIBUTES. Disabling UNARY_ATTRIBUTES also
   * disables EMPTY_NOMINAL_ATTRIBUTES. The same hierarchy applies to the class capabilities.
   *
   * @param c the capability to disable the dependency flag for
   */
  public void disableDependency(Capability c) {
    // attributes
    if (c == Capability.NOMINAL_ATTRIBUTES) {
      disableDependency(Capability.BINARY_ATTRIBUTES);
    } else if (c == Capability.BINARY_ATTRIBUTES) {
      disableDependency(Capability.UNARY_ATTRIBUTES);
    } else if (c == Capability.UNARY_ATTRIBUTES) {
      disableDependency(Capability.EMPTY_NOMINAL_ATTRIBUTES);
    }
    // class
    else if (c == Capability.NOMINAL_CLASS) {
      disableDependency(Capability.BINARY_CLASS);
    } else if (c == Capability.BINARY_CLASS) {
      disableDependency(Capability.UNARY_CLASS);
    } else if (c == Capability.UNARY_CLASS) {
      disableDependency(Capability.EMPTY_NOMINAL_CLASS);
    }

    m_Dependencies.remove(c);
  }
Пример #4
0
 /**
  * disables all attribute type dependencies
  *
  * @see #enableAllAttributeDependencies()
  * @see #getAttributeCapabilities()
  */
 public void disableAllAttributeDependencies() {
   for (Capability cap : Capability.values()) {
     if (cap.isAttribute()) disableDependency(cap);
   }
 }
Пример #5
0
 /**
  * disables all class type dependencies
  *
  * @see #enableAllClassDependencies()
  * @see #getClassCapabilities()
  */
 public void disableAllClassDependencies() {
   for (Capability cap : Capability.values()) {
     if (cap.isClass()) disableDependency(cap);
   }
 }