aima.core.learning.framework.StringAttributeSpecification Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aima-core Show documentation
Show all versions of aima-core Show documentation
AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.
The newest version!
package aima.core.learning.framework;
import java.util.Arrays;
import java.util.List;
/**
* @author Ravi Mohan
*
*/
public class StringAttributeSpecification implements AttributeSpecification {
String attributeName;
List attributePossibleValues;
public StringAttributeSpecification(String attributeName,
List attributePossibleValues) {
this.attributeName = attributeName;
this.attributePossibleValues = attributePossibleValues;
}
public StringAttributeSpecification(String attributeName,
String[] attributePossibleValues) {
this(attributeName, Arrays.asList(attributePossibleValues));
}
public boolean isValid(String value) {
return (attributePossibleValues.contains(value));
}
/**
* @return Returns the attributeName.
*/
public String getAttributeName() {
return attributeName;
}
public List possibleAttributeValues() {
return attributePossibleValues;
}
public Attribute createAttribute(String rawValue) {
return new StringAttribute(rawValue, this);
}
}