Class StringMeasure
- java.lang.Object
-
- org.jgap.gp.CommandGene
-
- org.aksw.limes.core.ml.algorithm.eagle.genes.StringMeasure
-
- All Implemented Interfaces:
Serializable,Cloneable,Comparable,org.jgap.gp.IMutateable,org.jgap.util.ICloneable
public class StringMeasure extends org.jgap.gp.CommandGene implements org.jgap.gp.IMutateable, org.jgap.util.ICloneableWraps around LIMES string similarity commands for the JGAP library, e.g. trigram or levensthein. They all build a expression like similarityMeasure(resource1, resource2)|threshold. Whereas the threshold is ignored if the expression is atomic, i.e. the similarity measure isn't part (argument) of another metric, such as AND). We now expect atleast two parameters: 2 Terminals. Whereas the first is of sub return type ResourceTerminalType.SOURCE, the second of ResourceTerminalType.TARGET. This allows us to differentiate the different resources of the two endpoints and avoid silly measures comparing the same resources of the same endpoint. If mutation is turned on, the similarity command might be changed during the evolution process to another one of the allowed measures.- Version:
- Jul 21, 2016
- Author:
- Klaus Lyko (lyko@informatik.uni-leipzig.de), Mohamed Sherif (sherif@informatik.uni-leipzig.de)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description StringMeasure(String opName, org.jgap.gp.impl.GPConfiguration a_conf)Basic constructor for an atomic similarity measure.StringMeasure(String opName, org.jgap.gp.impl.GPConfiguration a_conf, Class<?> a_returnType, boolean a_mutateable)Constructor for atomic similarity measures.StringMeasure(String opName, org.jgap.gp.impl.GPConfiguration a_conf, Class<?> a_returnType, int a_subReturnType, boolean a_mutateable)Constructor for similarity measures bound by a threshold.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.jgap.gp.CommandGeneapplyMutation()Mutates this CommandGene.org.jgap.gp.CommandGeneapplyMutation(int a_index, double a_percentage)Objectclone()Clones the object.Objectexecute_object(org.jgap.gp.impl.ProgramChromosome a_chrom, int a_n, Object[] args)Executes this CommandGene as object.voidexecute_void(org.jgap.gp.impl.ProgramChromosome a_chrom, int a_n, Object[] args)Class<?>getChildType(org.jgap.gp.IGPProgram a_ind, int a_chromNum)We expect the first 2 parameters to be resource identifier, the third to be an (optional) double value as the threshold for this Similarity command.Set<String>getMeasures()Returns all (standard) String Measures.StringgetName()StringgetOperationName()booleanisValid(org.jgap.gp.impl.ProgramChromosome a_program)booleanisValid(org.jgap.gp.impl.ProgramChromosome a_program, int a_index)voidsetAllowedOperations(Set<String> operationSet)Setter for a specific set of LIMES Measures.StringtoString()-
Methods inherited from class org.jgap.gp.CommandGene
check, check, cleanup, compareTo, dynamizeArity, ensureUniqueness, ensureUniqueness, ensureUniqueness2, equals, execute, execute_boolean, execute_double, execute_float, execute_int, execute_long, getAllele, getApplicationData, getArity, getArityMax, getArityMin, getCommandType, getEnergy, getGPConfiguration, getInternalValue, getPersistentRepresentation, getPersistentRepresentationExt, getReturnType, getSubChildType, getSubChildTypes, getSubReturnType, hashCode, init, isAffectGlobalState, isCompareApplicationData, isFloatType, isIntegerType, setAllele, setApplicationData, setArity, setArityMax, setArityMin, setCompareApplicationData, setEnergy, setNoValidation, setReturnType, setToRandomValue, setValueFromPersistentRepresentation, setValueFromString, size
-
-
-
-
Constructor Detail
-
StringMeasure
public StringMeasure(String opName, org.jgap.gp.impl.GPConfiguration a_conf, Class<?> a_returnType, int a_subReturnType, boolean a_mutateable) throws org.jgap.InvalidConfigurationException
Constructor for similarity measures bound by a threshold.- Parameters:
opName- Name of the LIMES similarity measure operation (e.g. "trigrams").a_conf- JGAP GPConfiguration.a_returnType- The return type of this command.a_subReturnType- Specifies the SubReturnType.a_mutateable- true: this Commandgene is mutateable, viz. the LIMES similarity measure might be changed to another one out of the allowed operations.- Throws:
org.jgap.InvalidConfigurationException
-
StringMeasure
public StringMeasure(String opName, org.jgap.gp.impl.GPConfiguration a_conf, Class<?> a_returnType, boolean a_mutateable) throws org.jgap.InvalidConfigurationException
Constructor for atomic similarity measures. @FIXME antiquated and not actually used.- Parameters:
opName- Name of the LIMES similarity measure operation (e.g. "trigram").a_conf- JGAP GPConfiguration.a_returnType- The return type of this command.a_mutateable- true: this Commandgene is mutateable, viz. the LIMES similarity measure might be changed to another one out of the allowed operations.- Throws:
org.jgap.InvalidConfigurationException- when an invalid value has been passed to a Configuration object
-
StringMeasure
public StringMeasure(String opName, org.jgap.gp.impl.GPConfiguration a_conf) throws org.jgap.InvalidConfigurationException
Basic constructor for an atomic similarity measure. Return Type will be set to String.class and this gene more precisely the similarity measure command will not be mutateable. @FIXME antiquated and not actually used- Parameters:
opName- name of the LIMES similarity measure operation (e.g. "trigram").a_conf- JGAP GPConfiguration.- Throws:
org.jgap.InvalidConfigurationException- when an invalid value has been passed to a Configuration object
-
-
Method Detail
-
toString
public String toString()
- Specified by:
toStringin classorg.jgap.gp.CommandGene
-
getChildType
public Class<?> getChildType(org.jgap.gp.IGPProgram a_ind, int a_chromNum)
We expect the first 2 parameters to be resource identifier, the third to be an (optional) double value as the threshold for this Similarity command.- Overrides:
getChildTypein classorg.jgap.gp.CommandGene- Parameters:
a_ind- A GPPrograma_chromNum- The number of the chromosome.- Returns:
- Class type of the child.
-
getName
public String getName()
- Overrides:
getNamein classorg.jgap.gp.CommandGene
-
getOperationName
public String getOperationName()
-
execute_object
public Object execute_object(org.jgap.gp.impl.ProgramChromosome a_chrom, int a_n, Object[] args)
Executes this CommandGene as object. Is called if the return type is set to String.class. Thereby returning the atomic LIMES expression"sim(a.resource, b.resource)|threshold".- Overrides:
execute_objectin classorg.jgap.gp.CommandGene
-
execute_void
public void execute_void(org.jgap.gp.impl.ProgramChromosome a_chrom, int a_n, Object[] args)- Overrides:
execute_voidin classorg.jgap.gp.CommandGene
-
getMeasures
public Set<String> getMeasures()
Returns all (standard) String Measures.- Returns:
- A Set of all standard String Measures.
-
applyMutation
public org.jgap.gp.CommandGene applyMutation(int a_index, double a_percentage) throws org.jgap.InvalidConfigurationException- Specified by:
applyMutationin interfaceorg.jgap.gp.IMutateable- Throws:
org.jgap.InvalidConfigurationException
-
applyMutation
public org.jgap.gp.CommandGene applyMutation() throws org.jgap.InvalidConfigurationExceptionMutates this CommandGene. A random command out of the set of allowed similarity measures is picked.- Returns:
- A random command out of the set of the allowed similarity measures
- Throws:
org.jgap.InvalidConfigurationException- when an invalid value has been passed to a Configuration object
-
clone
public Object clone()
Clones the object.
-
isValid
public boolean isValid(org.jgap.gp.impl.ProgramChromosome a_program, int a_index)- Overrides:
isValidin classorg.jgap.gp.CommandGene
-
isValid
public boolean isValid(org.jgap.gp.impl.ProgramChromosome a_program)
- Overrides:
isValidin classorg.jgap.gp.CommandGene
-
-