コード例 #1
0
  @Override
  public ExampleSet apply(ExampleSet exampleSet) throws OperatorException {
    String firstName = getParameterAsString(PARAMETER_FIRST_ATTRIBUTE);
    String secondName = getParameterAsString(PARAMETER_SECOND_ATTRIBUTE);

    AttributeRole firstRole = exampleSet.getAttributes().getRole(firstName);
    AttributeRole secondRole = exampleSet.getAttributes().getRole(secondName);

    if (firstRole == null) {
      throw new AttributeNotFoundError(this, PARAMETER_FIRST_ATTRIBUTE, firstName);
    }

    if (secondRole == null) {
      throw new AttributeNotFoundError(this, PARAMETER_SECOND_ATTRIBUTE, secondName);
    }

    String firstRoleName = firstRole.getSpecialName();
    String secondRoleName = secondRole.getSpecialName();

    firstRole.changeToRegular();
    secondRole.changeToRegular();

    firstRole.setSpecial(secondRoleName);
    secondRole.setSpecial(firstRoleName);

    return exampleSet;
  }
コード例 #2
0
 public NonSpecialAttributesExampleSet(ExampleSet exampleSet) {
   this.parent = (ExampleSet) exampleSet.clone();
   Iterator<AttributeRole> s = this.parent.getAttributes().specialAttributes();
   while (s.hasNext()) {
     AttributeRole attributeRole = s.next();
     if (attributeRole.isSpecial()) {
       attributeRole.changeToRegular();
     }
   }
 }