id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
sequence
docstring
stringlengths
3
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
105
339
3,400
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Engine.java
Engine.configure
public void configure(TNorm conjunction, SNorm disjunction, TNorm implication, SNorm aggregation, Defuzzifier defuzzifier, Activation activation) { try { for (RuleBlock ruleblock : this.ruleBlocks) { ruleblock.setConjunction(conjunction == null ? null : conjunction.clone()); ruleblock.setDisjunction(disjunction == null ? null : disjunction.clone()); ruleblock.setImplication(implication == null ? null : implication.clone()); ruleblock.setActivation(activation == null ? new General() : activation.clone()); } for (OutputVariable outputVariable : this.outputVariables) { outputVariable.setDefuzzifier(defuzzifier == null ? null : defuzzifier.clone()); outputVariable.setAggregation(aggregation == null ? null : aggregation.clone()); } } catch (Exception ex) { throw new RuntimeException(ex); } }
java
public void configure(TNorm conjunction, SNorm disjunction, TNorm implication, SNorm aggregation, Defuzzifier defuzzifier, Activation activation) { try { for (RuleBlock ruleblock : this.ruleBlocks) { ruleblock.setConjunction(conjunction == null ? null : conjunction.clone()); ruleblock.setDisjunction(disjunction == null ? null : disjunction.clone()); ruleblock.setImplication(implication == null ? null : implication.clone()); ruleblock.setActivation(activation == null ? new General() : activation.clone()); } for (OutputVariable outputVariable : this.outputVariables) { outputVariable.setDefuzzifier(defuzzifier == null ? null : defuzzifier.clone()); outputVariable.setAggregation(aggregation == null ? null : aggregation.clone()); } } catch (Exception ex) { throw new RuntimeException(ex); } }
[ "public", "void", "configure", "(", "TNorm", "conjunction", ",", "SNorm", "disjunction", ",", "TNorm", "implication", ",", "SNorm", "aggregation", ",", "Defuzzifier", "defuzzifier", ",", "Activation", "activation", ")", "{", "try", "{", "for", "(", "RuleBlock", "ruleblock", ":", "this", ".", "ruleBlocks", ")", "{", "ruleblock", ".", "setConjunction", "(", "conjunction", "==", "null", "?", "null", ":", "conjunction", ".", "clone", "(", ")", ")", ";", "ruleblock", ".", "setDisjunction", "(", "disjunction", "==", "null", "?", "null", ":", "disjunction", ".", "clone", "(", ")", ")", ";", "ruleblock", ".", "setImplication", "(", "implication", "==", "null", "?", "null", ":", "implication", ".", "clone", "(", ")", ")", ";", "ruleblock", ".", "setActivation", "(", "activation", "==", "null", "?", "new", "General", "(", ")", ":", "activation", ".", "clone", "(", ")", ")", ";", "}", "for", "(", "OutputVariable", "outputVariable", ":", "this", ".", "outputVariables", ")", "{", "outputVariable", ".", "setDefuzzifier", "(", "defuzzifier", "==", "null", "?", "null", ":", "defuzzifier", ".", "clone", "(", ")", ")", ";", "outputVariable", ".", "setAggregation", "(", "aggregation", "==", "null", "?", "null", ":", "aggregation", ".", "clone", "(", ")", ")", ";", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "ex", ")", ";", "}", "}" ]
Configures the engine with clones of the given operators. @param conjunction is the operator to process the propositions joined by `and` in the antecedent of the rules @param disjunction is the operator to process the propositions joined by `or` in the antecedent of the rules @param implication is the operator to modify the consequents of the rules based on the activation degree of the antecedents of the rules @param aggregation is the operator to aggregate the resulting implications of the rules @param defuzzifier is the operator to transform the aggregated implications into a single scalar value @param activation is the activation method to activate and trigger the rule blocks
[ "Configures", "the", "engine", "with", "clones", "of", "the", "given", "operators", "." ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Engine.java#L157-L174
3,401
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Engine.java
Engine.variables
public List<Variable> variables() { List<Variable> result = new ArrayList<Variable>(inputVariables.size() + outputVariables.size()); result.addAll(inputVariables); result.addAll(outputVariables); return result; }
java
public List<Variable> variables() { List<Variable> result = new ArrayList<Variable>(inputVariables.size() + outputVariables.size()); result.addAll(inputVariables); result.addAll(outputVariables); return result; }
[ "public", "List", "<", "Variable", ">", "variables", "(", ")", "{", "List", "<", "Variable", ">", "result", "=", "new", "ArrayList", "<", "Variable", ">", "(", "inputVariables", ".", "size", "(", ")", "+", "outputVariables", ".", "size", "(", ")", ")", ";", "result", ".", "addAll", "(", "inputVariables", ")", ";", "result", ".", "addAll", "(", "outputVariables", ")", ";", "return", "result", ";", "}" ]
Returns a list that contains the input variables followed by the output variables in the order of insertion @return a list that contains the input variables followed by the output variables in the order of insertion
[ "Returns", "a", "list", "that", "contains", "the", "input", "variables", "followed", "by", "the", "output", "variables", "in", "the", "order", "of", "insertion" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Engine.java#L621-L626
3,402
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Engine.java
Engine.removeInputVariable
public InputVariable removeInputVariable(String name) { for (Iterator<InputVariable> it = this.inputVariables.iterator(); it.hasNext();) { InputVariable inputVariable = it.next(); if (inputVariable.getName().equals(name)) { it.remove(); return inputVariable; } } throw new RuntimeException(String.format( "[engine error] no input variable by name <%s>", name)); }
java
public InputVariable removeInputVariable(String name) { for (Iterator<InputVariable> it = this.inputVariables.iterator(); it.hasNext();) { InputVariable inputVariable = it.next(); if (inputVariable.getName().equals(name)) { it.remove(); return inputVariable; } } throw new RuntimeException(String.format( "[engine error] no input variable by name <%s>", name)); }
[ "public", "InputVariable", "removeInputVariable", "(", "String", "name", ")", "{", "for", "(", "Iterator", "<", "InputVariable", ">", "it", "=", "this", ".", "inputVariables", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "InputVariable", "inputVariable", "=", "it", ".", "next", "(", ")", ";", "if", "(", "inputVariable", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", ")", "{", "it", ".", "remove", "(", ")", ";", "return", "inputVariable", ";", "}", "}", "throw", "new", "RuntimeException", "(", "String", ".", "format", "(", "\"[engine error] no input variable by name <%s>\"", ",", "name", ")", ")", ";", "}" ]
Removes the given input variable from the list of input variables. @param name is the name of the input variable @return the input variable of the given name @throws RuntimeException if there is no variable with the given name
[ "Removes", "the", "given", "input", "variable", "from", "the", "list", "of", "input", "variables", "." ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Engine.java#L698-L708
3,403
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Engine.java
Engine.hasInputVariable
public boolean hasInputVariable(String name) { for (InputVariable inputVariable : this.inputVariables) { if (inputVariable.getName().equals(name)) { return true; } } return false; }
java
public boolean hasInputVariable(String name) { for (InputVariable inputVariable : this.inputVariables) { if (inputVariable.getName().equals(name)) { return true; } } return false; }
[ "public", "boolean", "hasInputVariable", "(", "String", "name", ")", "{", "for", "(", "InputVariable", "inputVariable", ":", "this", ".", "inputVariables", ")", "{", "if", "(", "inputVariable", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Indicates whether an input variable of the given name is in the input variables @param name is the name of the input variable @return whether an input variable is registered with the given name
[ "Indicates", "whether", "an", "input", "variable", "of", "the", "given", "name", "is", "in", "the", "input", "variables" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Engine.java#L728-L735
3,404
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Engine.java
Engine.removeOutputVariable
public OutputVariable removeOutputVariable(String name) { for (Iterator<OutputVariable> it = this.outputVariables.iterator(); it.hasNext();) { OutputVariable outputVariable = it.next(); if (outputVariable.getName().equals(name)) { it.remove(); return outputVariable; } } throw new RuntimeException(String.format( "[engine error] no output variable by name <%s>", name)); }
java
public OutputVariable removeOutputVariable(String name) { for (Iterator<OutputVariable> it = this.outputVariables.iterator(); it.hasNext();) { OutputVariable outputVariable = it.next(); if (outputVariable.getName().equals(name)) { it.remove(); return outputVariable; } } throw new RuntimeException(String.format( "[engine error] no output variable by name <%s>", name)); }
[ "public", "OutputVariable", "removeOutputVariable", "(", "String", "name", ")", "{", "for", "(", "Iterator", "<", "OutputVariable", ">", "it", "=", "this", ".", "outputVariables", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "OutputVariable", "outputVariable", "=", "it", ".", "next", "(", ")", ";", "if", "(", "outputVariable", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", ")", "{", "it", ".", "remove", "(", ")", ";", "return", "outputVariable", ";", "}", "}", "throw", "new", "RuntimeException", "(", "String", ".", "format", "(", "\"[engine error] no output variable by name <%s>\"", ",", "name", ")", ")", ";", "}" ]
Removes the output variable of the given name. @param name is the name of the output variable @return the output variable of the given name @throws RuntimeException if there is no variable with the given name
[ "Removes", "the", "output", "variable", "of", "the", "given", "name", "." ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Engine.java#L833-L843
3,405
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Engine.java
Engine.hasOutputVariable
public boolean hasOutputVariable(String name) { for (OutputVariable outputVariable : this.outputVariables) { if (outputVariable.getName().equals(name)) { return true; } } return false; }
java
public boolean hasOutputVariable(String name) { for (OutputVariable outputVariable : this.outputVariables) { if (outputVariable.getName().equals(name)) { return true; } } return false; }
[ "public", "boolean", "hasOutputVariable", "(", "String", "name", ")", "{", "for", "(", "OutputVariable", "outputVariable", ":", "this", ".", "outputVariables", ")", "{", "if", "(", "outputVariable", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Indicates whether an output variable of the given name is in the output variables @param name is the name of the output variable @return whether an output variable is registered with the given name
[ "Indicates", "whether", "an", "output", "variable", "of", "the", "given", "name", "is", "in", "the", "output", "variables" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Engine.java#L862-L869
3,406
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/norm/s/DrasticSum.java
DrasticSum.compute
@Override public double compute(double a, double b) { if (Op.isEq(Op.min(a, b), 0.0)) { return Op.max(a, b); } return 1.0; }
java
@Override public double compute(double a, double b) { if (Op.isEq(Op.min(a, b), 0.0)) { return Op.max(a, b); } return 1.0; }
[ "@", "Override", "public", "double", "compute", "(", "double", "a", ",", "double", "b", ")", "{", "if", "(", "Op", ".", "isEq", "(", "Op", ".", "min", "(", "a", ",", "b", ")", ",", "0.0", ")", ")", "{", "return", "Op", ".", "max", "(", "a", ",", "b", ")", ";", "}", "return", "1.0", ";", "}" ]
Computes the drastic sum of two membership function values @param a is a membership function value @param b is a membership function value @return `\begin{cases} \max(a,b) & \mbox{if $\min(a,b)=0$} \cr 1 & \mbox{otherwise} \end{cases}`
[ "Computes", "the", "drastic", "sum", "of", "two", "membership", "function", "values" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/norm/s/DrasticSum.java#L43-L49
3,407
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/factory/ConstructionFactory.java
ConstructionFactory.register
public void register(String simpleName, Class<? extends T> clazz) { this.constructors.put(simpleName, clazz); }
java
public void register(String simpleName, Class<? extends T> clazz) { this.constructors.put(simpleName, clazz); }
[ "public", "void", "register", "(", "String", "simpleName", ",", "Class", "<", "?", "extends", "T", ">", "clazz", ")", "{", "this", ".", "constructors", ".", "put", "(", "simpleName", ",", "clazz", ")", ";", "}" ]
Registers the class in the factory utilizing the given key @param simpleName is the simple name of the class by which constructors are (generally) registered @param clazz is the class of the object to construct
[ "Registers", "the", "class", "in", "the", "factory", "utilizing", "the", "given", "key" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/factory/ConstructionFactory.java#L59-L61
3,408
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/factory/ConstructionFactory.java
ConstructionFactory.constructObject
public T constructObject(String simpleName) { if (simpleName == null) { return null; } if (this.constructors.containsKey(simpleName)) { try { Class<? extends T> clazz = this.constructors.get(simpleName); if (clazz != null) { return clazz.newInstance(); } return null; } catch (Exception ex) { throw new RuntimeException(ex); } } throw new RuntimeException("[construction error] constructor <" + simpleName + "> not registered in " + getClass().getSimpleName()); }
java
public T constructObject(String simpleName) { if (simpleName == null) { return null; } if (this.constructors.containsKey(simpleName)) { try { Class<? extends T> clazz = this.constructors.get(simpleName); if (clazz != null) { return clazz.newInstance(); } return null; } catch (Exception ex) { throw new RuntimeException(ex); } } throw new RuntimeException("[construction error] constructor <" + simpleName + "> not registered in " + getClass().getSimpleName()); }
[ "public", "T", "constructObject", "(", "String", "simpleName", ")", "{", "if", "(", "simpleName", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "this", ".", "constructors", ".", "containsKey", "(", "simpleName", ")", ")", "{", "try", "{", "Class", "<", "?", "extends", "T", ">", "clazz", "=", "this", ".", "constructors", ".", "get", "(", "simpleName", ")", ";", "if", "(", "clazz", "!=", "null", ")", "{", "return", "clazz", ".", "newInstance", "(", ")", ";", "}", "return", "null", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "ex", ")", ";", "}", "}", "throw", "new", "RuntimeException", "(", "\"[construction error] constructor <\"", "+", "simpleName", "+", "\"> not registered in \"", "+", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ";", "}" ]
Creates an object by instantiating the registered class associated to the given key @param simpleName is the key of the class to instantiate @return an object by instantiating the registered class associated to the given key. @throws RuntimeException if the given key is not registered
[ "Creates", "an", "object", "by", "instantiating", "the", "registered", "class", "associated", "to", "the", "given", "key" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/factory/ConstructionFactory.java#L111-L129
3,409
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/norm/t/NilpotentMinimum.java
NilpotentMinimum.compute
@Override public double compute(double a, double b) { if (Op.isGt(a + b, 1.0)) { return Op.min(a, b); } return 0.0; }
java
@Override public double compute(double a, double b) { if (Op.isGt(a + b, 1.0)) { return Op.min(a, b); } return 0.0; }
[ "@", "Override", "public", "double", "compute", "(", "double", "a", ",", "double", "b", ")", "{", "if", "(", "Op", ".", "isGt", "(", "a", "+", "b", ",", "1.0", ")", ")", "{", "return", "Op", ".", "min", "(", "a", ",", "b", ")", ";", "}", "return", "0.0", ";", "}" ]
Computes the nilpotent minimum of two membership function values @param a is a membership function value @param b is a membership function value @return `\begin{cases} \min(a,b) & \mbox{if $a+b>1$} \cr 0 & \mbox{otherwise} \end{cases}`
[ "Computes", "the", "nilpotent", "minimum", "of", "two", "membership", "function", "values" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/norm/t/NilpotentMinimum.java#L43-L49
3,410
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/factory/FunctionFactory.java
FunctionFactory.availableOperators
public Set<String> availableOperators() { Set<String> operators = new HashSet<String>(this.getObjects().keySet()); Iterator<String> it = operators.iterator(); while (it.hasNext()) { String key = it.next(); if (!getObject(key).isOperator()) { it.remove(); } } return operators; }
java
public Set<String> availableOperators() { Set<String> operators = new HashSet<String>(this.getObjects().keySet()); Iterator<String> it = operators.iterator(); while (it.hasNext()) { String key = it.next(); if (!getObject(key).isOperator()) { it.remove(); } } return operators; }
[ "public", "Set", "<", "String", ">", "availableOperators", "(", ")", "{", "Set", "<", "String", ">", "operators", "=", "new", "HashSet", "<", "String", ">", "(", "this", ".", "getObjects", "(", ")", ".", "keySet", "(", ")", ")", ";", "Iterator", "<", "String", ">", "it", "=", "operators", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "String", "key", "=", "it", ".", "next", "(", ")", ";", "if", "(", "!", "getObject", "(", "key", ")", ".", "isOperator", "(", ")", ")", "{", "it", ".", "remove", "(", ")", ";", "}", "}", "return", "operators", ";", "}" ]
Returns a set of the operators available @return a set of the operators available
[ "Returns", "a", "set", "of", "the", "operators", "available" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/factory/FunctionFactory.java#L170-L180
3,411
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/factory/FunctionFactory.java
FunctionFactory.availableFunctions
public Set<String> availableFunctions() { Set<String> functions = new HashSet<String>(this.getObjects().keySet()); Iterator<String> it = functions.iterator(); while (it.hasNext()) { String key = it.next(); if (!getObject(key).isFunction()) { it.remove(); } } return functions; }
java
public Set<String> availableFunctions() { Set<String> functions = new HashSet<String>(this.getObjects().keySet()); Iterator<String> it = functions.iterator(); while (it.hasNext()) { String key = it.next(); if (!getObject(key).isFunction()) { it.remove(); } } return functions; }
[ "public", "Set", "<", "String", ">", "availableFunctions", "(", ")", "{", "Set", "<", "String", ">", "functions", "=", "new", "HashSet", "<", "String", ">", "(", "this", ".", "getObjects", "(", ")", ".", "keySet", "(", ")", ")", ";", "Iterator", "<", "String", ">", "it", "=", "functions", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "String", "key", "=", "it", ".", "next", "(", ")", ";", "if", "(", "!", "getObject", "(", "key", ")", ".", "isFunction", "(", ")", ")", "{", "it", ".", "remove", "(", ")", ";", "}", "}", "return", "functions", ";", "}" ]
Returns a set of the functions available @return a set of the functions available
[ "Returns", "a", "set", "of", "the", "functions", "available" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/factory/FunctionFactory.java#L187-L197
3,412
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Op.java
Op.min
public static double min(double a, double b) { if (Double.isNaN(a)) { return b; } if (Double.isNaN(b)) { return a; } return a < b ? a : b; }
java
public static double min(double a, double b) { if (Double.isNaN(a)) { return b; } if (Double.isNaN(b)) { return a; } return a < b ? a : b; }
[ "public", "static", "double", "min", "(", "double", "a", ",", "double", "b", ")", "{", "if", "(", "Double", ".", "isNaN", "(", "a", ")", ")", "{", "return", "b", ";", "}", "if", "(", "Double", ".", "isNaN", "(", "b", ")", ")", "{", "return", "a", ";", "}", "return", "a", "<", "b", "?", "a", ":", "b", ";", "}" ]
Returns the minimum between the two parameters @param a @param b @return `\min(a,b)`
[ "Returns", "the", "minimum", "between", "the", "two", "parameters" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Op.java#L41-L49
3,413
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Op.java
Op.in
public static boolean in(double x, double min, double max) { return in(x, min, max, true, true); }
java
public static boolean in(double x, double min, double max) { return in(x, min, max, true, true); }
[ "public", "static", "boolean", "in", "(", "double", "x", ",", "double", "min", ",", "double", "max", ")", "{", "return", "in", "(", "x", ",", "min", ",", "max", ",", "true", ",", "true", ")", ";", "}" ]
Indicates whether `x` is within the closed boundaries @param x is the value @param min is the minimum of the range @param max is the maximum of the range @return ` \begin{cases} x \in [\min,\max] & \mbox{if $geq \wedge leq$} \cr x \in (\min,\max] & \mbox{if $geq \wedge \bar{leq}$} \cr x \in [\min, \max) & \mbox{if $\bar{geq} \wedge leq$} \cr x \in (\min, \max) & \mbox{if $\bar{geq} \wedge \bar{leq}$} \cr \end{cases} `
[ "Indicates", "whether", "x", "is", "within", "the", "closed", "boundaries" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Op.java#L100-L102
3,414
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Op.java
Op.isEq
public static boolean isEq(double a, double b) { return a == b || Math.abs(a - b) < FuzzyLite.macheps || (Double.isNaN(a) && Double.isNaN(b)); }
java
public static boolean isEq(double a, double b) { return a == b || Math.abs(a - b) < FuzzyLite.macheps || (Double.isNaN(a) && Double.isNaN(b)); }
[ "public", "static", "boolean", "isEq", "(", "double", "a", ",", "double", "b", ")", "{", "return", "a", "==", "b", "||", "Math", ".", "abs", "(", "a", "-", "b", ")", "<", "FuzzyLite", ".", "macheps", "||", "(", "Double", ".", "isNaN", "(", "a", ")", "&&", "Double", ".", "isNaN", "(", "b", ")", ")", ";", "}" ]
Returns whether `a` is equal to `b` at the default tolerance @param a @param b @return whether `a` is equal to `b` at the default tolerance
[ "Returns", "whether", "a", "is", "equal", "to", "b", "at", "the", "default", "tolerance" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Op.java#L146-L148
3,415
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Op.java
Op.variance
public static double variance(double[] x, double mean) { if (x.length == 0) { return Double.NaN; } if (x.length == 1) { return 0.0; } double result = 0.0; for (double i : x) { result += (i - mean) * (i - mean); } result /= -1 + x.length; return result; }
java
public static double variance(double[] x, double mean) { if (x.length == 0) { return Double.NaN; } if (x.length == 1) { return 0.0; } double result = 0.0; for (double i : x) { result += (i - mean) * (i - mean); } result /= -1 + x.length; return result; }
[ "public", "static", "double", "variance", "(", "double", "[", "]", "x", ",", "double", "mean", ")", "{", "if", "(", "x", ".", "length", "==", "0", ")", "{", "return", "Double", ".", "NaN", ";", "}", "if", "(", "x", ".", "length", "==", "1", ")", "{", "return", "0.0", ";", "}", "double", "result", "=", "0.0", ";", "for", "(", "double", "i", ":", "x", ")", "{", "result", "+=", "(", "i", "-", "mean", ")", "*", "(", "i", "-", "mean", ")", ";", "}", "result", "/=", "-", "1", "+", "x", ".", "length", ";", "return", "result", ";", "}" ]
Computes the variance of the vector using the given mean @param x is the vector @param mean is the mean value of the vector @return ` \sum_i{ (x_i - \bar{x})^2 } / (|x| - 1) `
[ "Computes", "the", "variance", "of", "the", "vector", "using", "the", "given", "mean" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Op.java#L554-L567
3,416
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Op.java
Op.standardDeviation
public static double standardDeviation(double[] x, double mean) { if (x.length == 0) { return Double.NaN; } if (x.length == 1) { return 0.0; } return Math.sqrt(variance(x, mean)); }
java
public static double standardDeviation(double[] x, double mean) { if (x.length == 0) { return Double.NaN; } if (x.length == 1) { return 0.0; } return Math.sqrt(variance(x, mean)); }
[ "public", "static", "double", "standardDeviation", "(", "double", "[", "]", "x", ",", "double", "mean", ")", "{", "if", "(", "x", ".", "length", "==", "0", ")", "{", "return", "Double", ".", "NaN", ";", "}", "if", "(", "x", ".", "length", "==", "1", ")", "{", "return", "0.0", ";", "}", "return", "Math", ".", "sqrt", "(", "variance", "(", "x", ",", "mean", ")", ")", ";", "}" ]
Computes the standard deviation of the vector using the given mean @param x @param mean is the mean value of x @return ` \sqrt{\mbox{variance}(x, \bar{x})} `
[ "Computes", "the", "standard", "deviation", "of", "the", "vector", "using", "the", "given", "mean" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Op.java#L586-L594
3,417
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Op.java
Op.split
public static List<String> split(String string, String delimiter) { return split(string, delimiter, true); }
java
public static List<String> split(String string, String delimiter) { return split(string, delimiter, true); }
[ "public", "static", "List", "<", "String", ">", "split", "(", "String", "string", ",", "String", "delimiter", ")", "{", "return", "split", "(", "string", ",", "delimiter", ",", "true", ")", ";", "}" ]
Splits the string around the given delimiter ignoring empty splits @param string is the string to split @param delimiter is the substrings on which the string will be split @return the string split around the given delimiter
[ "Splits", "the", "string", "around", "the", "given", "delimiter", "ignoring", "empty", "splits" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Op.java#L603-L605
3,418
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Op.java
Op.split
public static List<String> split(String string, String delimiter, boolean ignoreEmpty) { List<String> result = new ArrayList<String>(); if (string.isEmpty() || delimiter.isEmpty()) { result.add(string); return result; } int position = 0, next = 0; while (next >= 0) { next = string.indexOf(delimiter, position); String token; if (next < 0) { token = string.substring(position); } else { token = string.substring(position, next); } if (!(token.isEmpty() && ignoreEmpty)) { result.add(token); } if (next >= 0) { position = next + delimiter.length(); } } return result; }
java
public static List<String> split(String string, String delimiter, boolean ignoreEmpty) { List<String> result = new ArrayList<String>(); if (string.isEmpty() || delimiter.isEmpty()) { result.add(string); return result; } int position = 0, next = 0; while (next >= 0) { next = string.indexOf(delimiter, position); String token; if (next < 0) { token = string.substring(position); } else { token = string.substring(position, next); } if (!(token.isEmpty() && ignoreEmpty)) { result.add(token); } if (next >= 0) { position = next + delimiter.length(); } } return result; }
[ "public", "static", "List", "<", "String", ">", "split", "(", "String", "string", ",", "String", "delimiter", ",", "boolean", "ignoreEmpty", ")", "{", "List", "<", "String", ">", "result", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "if", "(", "string", ".", "isEmpty", "(", ")", "||", "delimiter", ".", "isEmpty", "(", ")", ")", "{", "result", ".", "add", "(", "string", ")", ";", "return", "result", ";", "}", "int", "position", "=", "0", ",", "next", "=", "0", ";", "while", "(", "next", ">=", "0", ")", "{", "next", "=", "string", ".", "indexOf", "(", "delimiter", ",", "position", ")", ";", "String", "token", ";", "if", "(", "next", "<", "0", ")", "{", "token", "=", "string", ".", "substring", "(", "position", ")", ";", "}", "else", "{", "token", "=", "string", ".", "substring", "(", "position", ",", "next", ")", ";", "}", "if", "(", "!", "(", "token", ".", "isEmpty", "(", ")", "&&", "ignoreEmpty", ")", ")", "{", "result", ".", "add", "(", "token", ")", ";", "}", "if", "(", "next", ">=", "0", ")", "{", "position", "=", "next", "+", "delimiter", ".", "length", "(", ")", ";", "}", "}", "return", "result", ";", "}" ]
Splits the string around the given delimiter @param string is the string to split @param delimiter is the substrings on which the string will be split @param ignoreEmpty whether the empty strings are discarded @return the string split around the given delimiter
[ "Splits", "the", "string", "around", "the", "given", "delimiter" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Op.java#L615-L639
3,419
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Op.java
Op.toDouble
public static double toDouble(String x) throws NumberFormatException { if ("nan".equals(x)) { return Double.NaN; } if ("inf".equals(x)) { return Double.POSITIVE_INFINITY; } if ("-inf".equals(x)) { return Double.NEGATIVE_INFINITY; } return Double.parseDouble(x); }
java
public static double toDouble(String x) throws NumberFormatException { if ("nan".equals(x)) { return Double.NaN; } if ("inf".equals(x)) { return Double.POSITIVE_INFINITY; } if ("-inf".equals(x)) { return Double.NEGATIVE_INFINITY; } return Double.parseDouble(x); }
[ "public", "static", "double", "toDouble", "(", "String", "x", ")", "throws", "NumberFormatException", "{", "if", "(", "\"nan\"", ".", "equals", "(", "x", ")", ")", "{", "return", "Double", ".", "NaN", ";", "}", "if", "(", "\"inf\"", ".", "equals", "(", "x", ")", ")", "{", "return", "Double", ".", "POSITIVE_INFINITY", ";", "}", "if", "(", "\"-inf\"", ".", "equals", "(", "x", ")", ")", "{", "return", "Double", ".", "NEGATIVE_INFINITY", ";", "}", "return", "Double", ".", "parseDouble", "(", "x", ")", ";", "}" ]
Parses the given string into a scalar value @param x is the string to parse @return the given string into a scalar value @throws NumberFormatException if the string does not contain a scalar value
[ "Parses", "the", "given", "string", "into", "a", "scalar", "value" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Op.java#L665-L677
3,420
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Op.java
Op.toDoubles
public static double[] toDoubles(String x, double alternative) throws NumberFormatException { String[] tokens = x.split("\\s+"); double[] result = new double[tokens.length]; for (int i = 0; i < tokens.length; ++i) { result[i] = Op.toDouble(tokens[i], alternative); } return result; }
java
public static double[] toDoubles(String x, double alternative) throws NumberFormatException { String[] tokens = x.split("\\s+"); double[] result = new double[tokens.length]; for (int i = 0; i < tokens.length; ++i) { result[i] = Op.toDouble(tokens[i], alternative); } return result; }
[ "public", "static", "double", "[", "]", "toDoubles", "(", "String", "x", ",", "double", "alternative", ")", "throws", "NumberFormatException", "{", "String", "[", "]", "tokens", "=", "x", ".", "split", "(", "\"\\\\s+\"", ")", ";", "double", "[", "]", "result", "=", "new", "double", "[", "tokens", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "tokens", ".", "length", ";", "++", "i", ")", "{", "result", "[", "i", "]", "=", "Op", ".", "toDouble", "(", "tokens", "[", "i", "]", ",", "alternative", ")", ";", "}", "return", "result", ";", "}" ]
Parses the given string into a vector of scalar values @param x is the string containing space-separated values to parse @param alternative is the value to use if an invalid value is found @return the vector of scalar values
[ "Parses", "the", "given", "string", "into", "a", "vector", "of", "scalar", "values" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Op.java#L703-L710
3,421
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Op.java
Op.increment
public static boolean increment(int[] array, int position, int[] min, int[] max) { if (array.length == 0 || position < 0) { return false; } boolean incremented = true; if (array[position] < max[position]) { ++array[position]; } else { incremented = !(position == 0); array[position] = min[position]; --position; if (position >= 0) { incremented = increment(array, position, min, max); } } return incremented; }
java
public static boolean increment(int[] array, int position, int[] min, int[] max) { if (array.length == 0 || position < 0) { return false; } boolean incremented = true; if (array[position] < max[position]) { ++array[position]; } else { incremented = !(position == 0); array[position] = min[position]; --position; if (position >= 0) { incremented = increment(array, position, min, max); } } return incremented; }
[ "public", "static", "boolean", "increment", "(", "int", "[", "]", "array", ",", "int", "position", ",", "int", "[", "]", "min", ",", "int", "[", "]", "max", ")", "{", "if", "(", "array", ".", "length", "==", "0", "||", "position", "<", "0", ")", "{", "return", "false", ";", "}", "boolean", "incremented", "=", "true", ";", "if", "(", "array", "[", "position", "]", "<", "max", "[", "position", "]", ")", "{", "++", "array", "[", "position", "]", ";", "}", "else", "{", "incremented", "=", "!", "(", "position", "==", "0", ")", ";", "array", "[", "position", "]", "=", "min", "[", "position", "]", ";", "--", "position", ";", "if", "(", "position", ">=", "0", ")", "{", "incremented", "=", "increment", "(", "array", ",", "position", ",", "min", ",", "max", ")", ";", "}", "}", "return", "incremented", ";", "}" ]
Increments `x` by the unit at the given position, treating the entire vector as a number. For example, incrementing `x_0=\{0,0,0\}` within boundaries `[0,1]` at the second position results in: `x_1=\{0,1,0\}`, `x_2=\{1,0,0\}`, `x_3=\{1,1,0\}`, `x_4=\{0,0,0\}`. @param array is the vector to increment @param position is the position of the vector to increment, where smaller values lead to higher significance digits @param min is the minimum value of the dimension @param max is the maximum value of the dimension @return `true` if `x` was incremented, `false` otherwise (e.g., incrementing `x_3` returns `false`). In earlier versions to 6.0, the result was the inverse and indicated whether the counter had overflown (most sincere apologies for this change).
[ "Increments", "x", "by", "the", "unit", "at", "the", "given", "position", "treating", "the", "entire", "vector", "as", "a", "number", ".", "For", "example", "incrementing" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Op.java#L763-L780
3,422
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Op.java
Op.validName
public static String validName(String name) { if (name == null || name.trim().isEmpty()) { return "unnamed"; } StringBuilder result = new StringBuilder(); for (char c : name.toCharArray()) { if (c == '_' || c == '.' || Character.isLetterOrDigit(c)) { result.append(c); } } return result.toString(); }
java
public static String validName(String name) { if (name == null || name.trim().isEmpty()) { return "unnamed"; } StringBuilder result = new StringBuilder(); for (char c : name.toCharArray()) { if (c == '_' || c == '.' || Character.isLetterOrDigit(c)) { result.append(c); } } return result.toString(); }
[ "public", "static", "String", "validName", "(", "String", "name", ")", "{", "if", "(", "name", "==", "null", "||", "name", ".", "trim", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "return", "\"unnamed\"", ";", "}", "StringBuilder", "result", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "char", "c", ":", "name", ".", "toCharArray", "(", ")", ")", "{", "if", "(", "c", "==", "'", "'", "||", "c", "==", "'", "'", "||", "Character", ".", "isLetterOrDigit", "(", "c", ")", ")", "{", "result", ".", "append", "(", "c", ")", ";", "}", "}", "return", "result", ".", "toString", "(", ")", ";", "}" ]
Returns a valid name for variables @param name @return an name whose characters are in `[a-zA-Z_0-9.]`
[ "Returns", "a", "valid", "name", "for", "variables" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Op.java#L975-L986
3,423
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/term/Discrete.java
Discrete.create
public static Discrete create(String name, double... xy) { final int mod2 = xy.length % 2; List<Pair> xyValues = new ArrayList<Pair>(xy.length / 2); for (int i = 0; i < xy.length - mod2; i += 2) { xyValues.add(new Pair(xy[i], xy[i + 1])); } Discrete result = new Discrete(name, xyValues); if (mod2 != 0) { result.setHeight(xy[xy.length - 1]); } return new Discrete(name, xyValues); }
java
public static Discrete create(String name, double... xy) { final int mod2 = xy.length % 2; List<Pair> xyValues = new ArrayList<Pair>(xy.length / 2); for (int i = 0; i < xy.length - mod2; i += 2) { xyValues.add(new Pair(xy[i], xy[i + 1])); } Discrete result = new Discrete(name, xyValues); if (mod2 != 0) { result.setHeight(xy[xy.length - 1]); } return new Discrete(name, xyValues); }
[ "public", "static", "Discrete", "create", "(", "String", "name", ",", "double", "...", "xy", ")", "{", "final", "int", "mod2", "=", "xy", ".", "length", "%", "2", ";", "List", "<", "Pair", ">", "xyValues", "=", "new", "ArrayList", "<", "Pair", ">", "(", "xy", ".", "length", "/", "2", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "xy", ".", "length", "-", "mod2", ";", "i", "+=", "2", ")", "{", "xyValues", ".", "add", "(", "new", "Pair", "(", "xy", "[", "i", "]", ",", "xy", "[", "i", "+", "1", "]", ")", ")", ";", "}", "Discrete", "result", "=", "new", "Discrete", "(", "name", ",", "xyValues", ")", ";", "if", "(", "mod2", "!=", "0", ")", "{", "result", ".", "setHeight", "(", "xy", "[", "xy", ".", "length", "-", "1", "]", ")", ";", "}", "return", "new", "Discrete", "(", "name", ",", "xyValues", ")", ";", "}" ]
Creates a Discrete term from a variadic set of values. @param name is the name of the resulting term @param xy are the values `x_0, y_0, ..., x_i, y_i, ..., x_n, y_n` @return a new Discrete term with the given parameters
[ "Creates", "a", "Discrete", "term", "from", "a", "variadic", "set", "of", "values", "." ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/term/Discrete.java#L187-L198
3,424
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/term/Discrete.java
Discrete.discretize
public static Discrete discretize(Term term, double start, double end, int resolution, boolean boundedMembershipFunction) { Discrete result = new Discrete(term.getName()); double dx = (end - start) / resolution; double x, y; for (int i = 0; i <= resolution; ++i) { x = start + i * dx; y = term.membership(x); if (boundedMembershipFunction) { y = Op.bound(y, 0.0, 1.0); } result.add(new Discrete.Pair(x, y)); } return result; }
java
public static Discrete discretize(Term term, double start, double end, int resolution, boolean boundedMembershipFunction) { Discrete result = new Discrete(term.getName()); double dx = (end - start) / resolution; double x, y; for (int i = 0; i <= resolution; ++i) { x = start + i * dx; y = term.membership(x); if (boundedMembershipFunction) { y = Op.bound(y, 0.0, 1.0); } result.add(new Discrete.Pair(x, y)); } return result; }
[ "public", "static", "Discrete", "discretize", "(", "Term", "term", ",", "double", "start", ",", "double", "end", ",", "int", "resolution", ",", "boolean", "boundedMembershipFunction", ")", "{", "Discrete", "result", "=", "new", "Discrete", "(", "term", ".", "getName", "(", ")", ")", ";", "double", "dx", "=", "(", "end", "-", "start", ")", "/", "resolution", ";", "double", "x", ",", "y", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<=", "resolution", ";", "++", "i", ")", "{", "x", "=", "start", "+", "i", "*", "dx", ";", "y", "=", "term", ".", "membership", "(", "x", ")", ";", "if", "(", "boundedMembershipFunction", ")", "{", "y", "=", "Op", ".", "bound", "(", "y", ",", "0.0", ",", "1.0", ")", ";", "}", "result", ".", "add", "(", "new", "Discrete", ".", "Pair", "(", "x", ",", "y", ")", ")", ";", "}", "return", "result", ";", "}" ]
Discretizes the given term @param term is the term to discretize @param start is the value from which discretization starts @param end is the value at which discretization ends @param resolution is the number of equally-distributed samples to perform between start and end @param boundedMembershipFunction indicates whether to ensure that `\mu(x)\in[0.0,1.0]` @return a Discrete term that approximates the given term
[ "Discretizes", "the", "given", "term" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/term/Discrete.java#L241-L255
3,425
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/term/Discrete.java
Discrete.membership
@Override public double membership(double x) { if (Double.isNaN(x)) { return Double.NaN; } if (xy.isEmpty()) { throw new RuntimeException("[discrete error] term is empty"); } // ______________________ // / \ // / \ // ____________/ \____________ // x[0] x[n-1] // Pair first = xy.get(0); Pair last = xy.get(xy.size() - 1); if (Op.isLE(x, first.getX())) { return height * first.getY(); } if (Op.isGE(x, last.getX())) { return height * last.getY(); } Discrete.Pair value = new Discrete.Pair(x, Double.NaN); //Binary search will find a number greater than or equal to x int upper = Collections.binarySearch(xy, value, ASCENDANTLY); //if the upper bound is equal to x if (upper >= 0) { return height * xy.get(upper).y; } //if the upper bound is not x, then binary search returns (-insertionPoint - 1) upper = Math.abs(upper + 1); //and the lower bound int lower = upper - 1; //FuzzyLite.logger().log(Level.INFO, "x={0}\t[{1} , {2}]", new Object[]{x, lower, upper}); return height * Op.scale(x, xy.get(lower).getX(), xy.get(upper).getX(), xy.get(lower).getY(), xy.get(upper).getY()); }
java
@Override public double membership(double x) { if (Double.isNaN(x)) { return Double.NaN; } if (xy.isEmpty()) { throw new RuntimeException("[discrete error] term is empty"); } // ______________________ // / \ // / \ // ____________/ \____________ // x[0] x[n-1] // Pair first = xy.get(0); Pair last = xy.get(xy.size() - 1); if (Op.isLE(x, first.getX())) { return height * first.getY(); } if (Op.isGE(x, last.getX())) { return height * last.getY(); } Discrete.Pair value = new Discrete.Pair(x, Double.NaN); //Binary search will find a number greater than or equal to x int upper = Collections.binarySearch(xy, value, ASCENDANTLY); //if the upper bound is equal to x if (upper >= 0) { return height * xy.get(upper).y; } //if the upper bound is not x, then binary search returns (-insertionPoint - 1) upper = Math.abs(upper + 1); //and the lower bound int lower = upper - 1; //FuzzyLite.logger().log(Level.INFO, "x={0}\t[{1} , {2}]", new Object[]{x, lower, upper}); return height * Op.scale(x, xy.get(lower).getX(), xy.get(upper).getX(), xy.get(lower).getY(), xy.get(upper).getY()); }
[ "@", "Override", "public", "double", "membership", "(", "double", "x", ")", "{", "if", "(", "Double", ".", "isNaN", "(", "x", ")", ")", "{", "return", "Double", ".", "NaN", ";", "}", "if", "(", "xy", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"[discrete error] term is empty\"", ")", ";", "}", "// ______________________", "// / \\", "// / \\", "// ____________/ \\____________", "// x[0] x[n-1]", "//", "Pair", "first", "=", "xy", ".", "get", "(", "0", ")", ";", "Pair", "last", "=", "xy", ".", "get", "(", "xy", ".", "size", "(", ")", "-", "1", ")", ";", "if", "(", "Op", ".", "isLE", "(", "x", ",", "first", ".", "getX", "(", ")", ")", ")", "{", "return", "height", "*", "first", ".", "getY", "(", ")", ";", "}", "if", "(", "Op", ".", "isGE", "(", "x", ",", "last", ".", "getX", "(", ")", ")", ")", "{", "return", "height", "*", "last", ".", "getY", "(", ")", ";", "}", "Discrete", ".", "Pair", "value", "=", "new", "Discrete", ".", "Pair", "(", "x", ",", "Double", ".", "NaN", ")", ";", "//Binary search will find a number greater than or equal to x", "int", "upper", "=", "Collections", ".", "binarySearch", "(", "xy", ",", "value", ",", "ASCENDANTLY", ")", ";", "//if the upper bound is equal to x", "if", "(", "upper", ">=", "0", ")", "{", "return", "height", "*", "xy", ".", "get", "(", "upper", ")", ".", "y", ";", "}", "//if the upper bound is not x, then binary search returns (-insertionPoint - 1)", "upper", "=", "Math", ".", "abs", "(", "upper", "+", "1", ")", ";", "//and the lower bound", "int", "lower", "=", "upper", "-", "1", ";", "//FuzzyLite.logger().log(Level.INFO, \"x={0}\\t[{1} , {2}]\", new Object[]{x, lower, upper});", "return", "height", "*", "Op", ".", "scale", "(", "x", ",", "xy", ".", "get", "(", "lower", ")", ".", "getX", "(", ")", ",", "xy", ".", "get", "(", "upper", ")", ".", "getX", "(", ")", ",", "xy", ".", "get", "(", "lower", ")", ".", "getY", "(", ")", ",", "xy", ".", "get", "(", "upper", ")", ".", "getY", "(", ")", ")", ";", "}" ]
Computes the membership function evaluated at `x` by using binary search to find the lower and upper bounds of `x` and then linearly interpolating the membership function between the bounds. @param x @return ` \dfrac{h (y_{\max} - y_{\min})}{(x_{\max}- x_{\min})} (x - x_{\min}) + y_{\min}` where `h` is the height of the Term, `x_{\min}` and `x_{\max}`is are the lower and upper limits of `x` in `xy` (respectively), `y_{\min}` and `y_{\max}`is are the membership functions of `\mu(x_{\min})` and `\mu(x_{\max})` (respectively)
[ "Computes", "the", "membership", "function", "evaluated", "at", "x", "by", "using", "binary", "search", "to", "find", "the", "lower", "and", "upper", "bounds", "of", "x", "and", "then", "linearly", "interpolating", "the", "membership", "function", "between", "the", "bounds", "." ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/term/Discrete.java#L311-L349
3,426
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/term/Discrete.java
Discrete.x
public List<Double> x() { List<Double> result = new ArrayList<Double>(xy.size()); for (Discrete.Pair pair : xy) { result.add(pair.x); } return result; }
java
public List<Double> x() { List<Double> result = new ArrayList<Double>(xy.size()); for (Discrete.Pair pair : xy) { result.add(pair.x); } return result; }
[ "public", "List", "<", "Double", ">", "x", "(", ")", "{", "List", "<", "Double", ">", "result", "=", "new", "ArrayList", "<", "Double", ">", "(", "xy", ".", "size", "(", ")", ")", ";", "for", "(", "Discrete", ".", "Pair", "pair", ":", "xy", ")", "{", "result", ".", "add", "(", "pair", ".", "x", ")", ";", "}", "return", "result", ";", "}" ]
Creates, fills and returns a list containing the `x` values @return a list containing the `x` values
[ "Creates", "fills", "and", "returns", "a", "list", "containing", "the", "x", "values" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/term/Discrete.java#L374-L380
3,427
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/term/Discrete.java
Discrete.toList
public static List<Double> toList(List<Pair> xyValues) { List<Double> result = new ArrayList<Double>(xyValues.size() * 2); for (Pair pair : xyValues) { result.add(pair.getX()); result.add(pair.getY()); } return result; }
java
public static List<Double> toList(List<Pair> xyValues) { List<Double> result = new ArrayList<Double>(xyValues.size() * 2); for (Pair pair : xyValues) { result.add(pair.getX()); result.add(pair.getY()); } return result; }
[ "public", "static", "List", "<", "Double", ">", "toList", "(", "List", "<", "Pair", ">", "xyValues", ")", "{", "List", "<", "Double", ">", "result", "=", "new", "ArrayList", "<", "Double", ">", "(", "xyValues", ".", "size", "(", ")", "*", "2", ")", ";", "for", "(", "Pair", "pair", ":", "xyValues", ")", "{", "result", ".", "add", "(", "pair", ".", "getX", "(", ")", ")", ";", "result", ".", "add", "(", "pair", ".", "getY", "(", ")", ")", ";", "}", "return", "result", ";", "}" ]
Creates a list of scalars from a list of Pair given in the form `\left(\{x_1,y_1\},...,\{x_n,y_n\}\right)` @param xyValues is the list of Pair @return a vector of scalars as `(x_1,y_1,...,x_n,y_n)`
[ "Creates", "a", "list", "of", "scalars", "from", "a", "list", "of", "Pair", "given", "in", "the", "form" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/term/Discrete.java#L434-L441
3,428
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/term/Discrete.java
Discrete.formatXY
public static String formatXY(List<Discrete.Pair> xy, String prefix, String innerSeparator, String suffix, String outerSeparator) { StringBuilder result = new StringBuilder(); Iterator<Pair> it = xy.iterator(); while (it.hasNext()) { Pair pair = it.next(); result.append(prefix).append(Op.str(pair.getX())) .append(innerSeparator).append(Op.str(pair.getY())) .append(suffix); if (it.hasNext()) { result.append(outerSeparator); } } return result.toString(); }
java
public static String formatXY(List<Discrete.Pair> xy, String prefix, String innerSeparator, String suffix, String outerSeparator) { StringBuilder result = new StringBuilder(); Iterator<Pair> it = xy.iterator(); while (it.hasNext()) { Pair pair = it.next(); result.append(prefix).append(Op.str(pair.getX())) .append(innerSeparator).append(Op.str(pair.getY())) .append(suffix); if (it.hasNext()) { result.append(outerSeparator); } } return result.toString(); }
[ "public", "static", "String", "formatXY", "(", "List", "<", "Discrete", ".", "Pair", ">", "xy", ",", "String", "prefix", ",", "String", "innerSeparator", ",", "String", "suffix", ",", "String", "outerSeparator", ")", "{", "StringBuilder", "result", "=", "new", "StringBuilder", "(", ")", ";", "Iterator", "<", "Pair", ">", "it", "=", "xy", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "Pair", "pair", "=", "it", ".", "next", "(", ")", ";", "result", ".", "append", "(", "prefix", ")", ".", "append", "(", "Op", ".", "str", "(", "pair", ".", "getX", "(", ")", ")", ")", ".", "append", "(", "innerSeparator", ")", ".", "append", "(", "Op", ".", "str", "(", "pair", ".", "getY", "(", ")", ")", ")", ".", "append", "(", "suffix", ")", ";", "if", "(", "it", ".", "hasNext", "(", ")", ")", "{", "result", ".", "append", "(", "outerSeparator", ")", ";", "}", "}", "return", "result", ".", "toString", "(", ")", ";", "}" ]
Formats a vector of Pair into a string in the form `(x_1,y_1) ... (x_n,y_n)` @param xy is the vector of Pair @param prefix indicates the prefix of a Pair, e.g., `(` results in `(x_i` @param innerSeparator indicates the separator between `x` and `y`, e.g., `,` results in `x_i,y_i` @param suffix indicates the postfix of a Pair, e.g., `]` results in `y_i]` @param outerSeparator indicates the separator between Pair, e.g., `;` results in `(x_i,y_i);(x_j,y_j)` @return a formatted string containing the pairs of `(x,y)` values
[ "Formats", "a", "vector", "of", "Pair", "into", "a", "string", "in", "the", "form" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/term/Discrete.java#L515-L530
3,429
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/activation/Threshold.java
Threshold.configure
@Override public void configure(String parameters) { if (parameters.isEmpty()) { return; } List<String> values = Op.split(parameters, " ", true); final int required = 2; if (values.size() < required) { throw new RuntimeException(MessageFormat.format( "[configuration error] activation {0} requires {1} parameters", this.getClass().getSimpleName(), required)); } setComparison(Comparison.fromOperator(values.get(0))); setValue(Op.toDouble(values.get(1))); }
java
@Override public void configure(String parameters) { if (parameters.isEmpty()) { return; } List<String> values = Op.split(parameters, " ", true); final int required = 2; if (values.size() < required) { throw new RuntimeException(MessageFormat.format( "[configuration error] activation {0} requires {1} parameters", this.getClass().getSimpleName(), required)); } setComparison(Comparison.fromOperator(values.get(0))); setValue(Op.toDouble(values.get(1))); }
[ "@", "Override", "public", "void", "configure", "(", "String", "parameters", ")", "{", "if", "(", "parameters", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "List", "<", "String", ">", "values", "=", "Op", ".", "split", "(", "parameters", ",", "\" \"", ",", "true", ")", ";", "final", "int", "required", "=", "2", ";", "if", "(", "values", ".", "size", "(", ")", "<", "required", ")", "{", "throw", "new", "RuntimeException", "(", "MessageFormat", ".", "format", "(", "\"[configuration error] activation {0} requires {1} parameters\"", ",", "this", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ",", "required", ")", ")", ";", "}", "setComparison", "(", "Comparison", ".", "fromOperator", "(", "values", ".", "get", "(", "0", ")", ")", ")", ";", "setValue", "(", "Op", ".", "toDouble", "(", "values", ".", "get", "(", "1", ")", ")", ")", ";", "}" ]
Configures the activation method with the comparison operator and the threshold. @param parameters is the comparison operator and threshold
[ "Configures", "the", "activation", "method", "with", "the", "comparison", "operator", "and", "the", "threshold", "." ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/activation/Threshold.java#L179-L194
3,430
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/activation/Threshold.java
Threshold.activatesWith
boolean activatesWith(double activationDegree) { //favour if-then-return over switch to avoid new file Threshold$1.class if (Comparison.LessThan == this.comparison) { return Op.isLt(activationDegree, getValue()); } if (Comparison.LessThanOrEqualTo == this.comparison) { return Op.isLE(activationDegree, getValue()); } if (Comparison.EqualTo == this.comparison) { return Op.isEq(activationDegree, getValue()); } if (Comparison.NotEqualTo == this.comparison) { return !Op.isEq(activationDegree, getValue()); } if (Comparison.GreaterThanOrEqualTo == this.comparison) { return Op.isGE(activationDegree, getValue()); } if (Comparison.GreaterThan == this.comparison) { return Op.isGt(activationDegree, getValue()); } return false; }
java
boolean activatesWith(double activationDegree) { //favour if-then-return over switch to avoid new file Threshold$1.class if (Comparison.LessThan == this.comparison) { return Op.isLt(activationDegree, getValue()); } if (Comparison.LessThanOrEqualTo == this.comparison) { return Op.isLE(activationDegree, getValue()); } if (Comparison.EqualTo == this.comparison) { return Op.isEq(activationDegree, getValue()); } if (Comparison.NotEqualTo == this.comparison) { return !Op.isEq(activationDegree, getValue()); } if (Comparison.GreaterThanOrEqualTo == this.comparison) { return Op.isGE(activationDegree, getValue()); } if (Comparison.GreaterThan == this.comparison) { return Op.isGt(activationDegree, getValue()); } return false; }
[ "boolean", "activatesWith", "(", "double", "activationDegree", ")", "{", "//favour if-then-return over switch to avoid new file Threshold$1.class", "if", "(", "Comparison", ".", "LessThan", "==", "this", ".", "comparison", ")", "{", "return", "Op", ".", "isLt", "(", "activationDegree", ",", "getValue", "(", ")", ")", ";", "}", "if", "(", "Comparison", ".", "LessThanOrEqualTo", "==", "this", ".", "comparison", ")", "{", "return", "Op", ".", "isLE", "(", "activationDegree", ",", "getValue", "(", ")", ")", ";", "}", "if", "(", "Comparison", ".", "EqualTo", "==", "this", ".", "comparison", ")", "{", "return", "Op", ".", "isEq", "(", "activationDegree", ",", "getValue", "(", ")", ")", ";", "}", "if", "(", "Comparison", ".", "NotEqualTo", "==", "this", ".", "comparison", ")", "{", "return", "!", "Op", ".", "isEq", "(", "activationDegree", ",", "getValue", "(", ")", ")", ";", "}", "if", "(", "Comparison", ".", "GreaterThanOrEqualTo", "==", "this", ".", "comparison", ")", "{", "return", "Op", ".", "isGE", "(", "activationDegree", ",", "getValue", "(", ")", ")", ";", "}", "if", "(", "Comparison", ".", "GreaterThan", "==", "this", ".", "comparison", ")", "{", "return", "Op", ".", "isGt", "(", "activationDegree", ",", "getValue", "(", ")", ")", ";", "}", "return", "false", ";", "}" ]
Returns whether the activation method will activate a rule with the given activation degree @param activationDegree an activation degree @return whether the comparison equation is satisfied with the activation degree and the threshold
[ "Returns", "whether", "the", "activation", "method", "will", "activate", "a", "rule", "with", "the", "given", "activation", "degree" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/activation/Threshold.java#L204-L225
3,431
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/norm/t/EinsteinProduct.java
EinsteinProduct.compute
@Override public double compute(double a, double b) { return (a * b) / (2 - (a + b - a * b)); }
java
@Override public double compute(double a, double b) { return (a * b) / (2 - (a + b - a * b)); }
[ "@", "Override", "public", "double", "compute", "(", "double", "a", ",", "double", "b", ")", "{", "return", "(", "a", "*", "b", ")", "/", "(", "2", "-", "(", "a", "+", "b", "-", "a", "*", "b", ")", ")", ";", "}" ]
Computes the Einstein product of two membership function values @param a is a membership function value @param b is a membership function value @return `(a\times b)/(2-(a+b-a\times b))`
[ "Computes", "the", "Einstein", "product", "of", "two", "membership", "function", "values" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/norm/t/EinsteinProduct.java#L41-L44
3,432
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/imex/RScriptExporter.java
RScriptExporter.toFile
public void toFile(File file, Engine engine, InputVariable a, InputVariable b, int values, FldExporter.ScopeOfValues scope, List<OutputVariable> outputVariables) throws IOException { BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(file), FuzzyLite.UTF_8)); try { writeScriptExportingDataFrame(engine, writer, a, b, values, scope, outputVariables); } catch (RuntimeException ex) { throw ex; } catch (IOException ex) { throw ex; } finally { writer.close(); } }
java
public void toFile(File file, Engine engine, InputVariable a, InputVariable b, int values, FldExporter.ScopeOfValues scope, List<OutputVariable> outputVariables) throws IOException { BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(file), FuzzyLite.UTF_8)); try { writeScriptExportingDataFrame(engine, writer, a, b, values, scope, outputVariables); } catch (RuntimeException ex) { throw ex; } catch (IOException ex) { throw ex; } finally { writer.close(); } }
[ "public", "void", "toFile", "(", "File", "file", ",", "Engine", "engine", ",", "InputVariable", "a", ",", "InputVariable", "b", ",", "int", "values", ",", "FldExporter", ".", "ScopeOfValues", "scope", ",", "List", "<", "OutputVariable", ">", "outputVariables", ")", "throws", "IOException", "{", "BufferedWriter", "writer", "=", "new", "BufferedWriter", "(", "new", "OutputStreamWriter", "(", "new", "FileOutputStream", "(", "file", ")", ",", "FuzzyLite", ".", "UTF_8", ")", ")", ";", "try", "{", "writeScriptExportingDataFrame", "(", "engine", ",", "writer", ",", "a", ",", "b", ",", "values", ",", "scope", ",", "outputVariables", ")", ";", "}", "catch", "(", "RuntimeException", "ex", ")", "{", "throw", "ex", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "ex", ";", "}", "finally", "{", "writer", ".", "close", "(", ")", ";", "}", "}" ]
Creates an R script file plotting multiple surfaces based on a data frame generated with the given number of values and scope for the two input variables @param file is the R script file @param engine is the engine to export @param a is the first input variable @param b is the second input variable @param values is the number of values to evaluate the engine @param scope is the scope of the number of values to evaluate the engine @param outputVariables are the output variables to create the surface for @throws IOException if any error occurs upon writing the file
[ "Creates", "an", "R", "script", "file", "plotting", "multiple", "surfaces", "based", "on", "a", "data", "frame", "generated", "with", "the", "given", "number", "of", "values", "and", "scope", "for", "the", "two", "input", "variables" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/imex/RScriptExporter.java#L225-L240
3,433
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/imex/RScriptExporter.java
RScriptExporter.toFile
public void toFile(File file, Engine engine, InputVariable a, InputVariable b, Reader reader, List<OutputVariable> outputVariables) throws IOException { BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(file), FuzzyLite.UTF_8)); try { writeScriptExportingDataFrame(engine, writer, a, b, reader, outputVariables); } catch (RuntimeException ex) { throw ex; } catch (IOException ex) { throw ex; } finally { writer.close(); } }
java
public void toFile(File file, Engine engine, InputVariable a, InputVariable b, Reader reader, List<OutputVariable> outputVariables) throws IOException { BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(file), FuzzyLite.UTF_8)); try { writeScriptExportingDataFrame(engine, writer, a, b, reader, outputVariables); } catch (RuntimeException ex) { throw ex; } catch (IOException ex) { throw ex; } finally { writer.close(); } }
[ "public", "void", "toFile", "(", "File", "file", ",", "Engine", "engine", ",", "InputVariable", "a", ",", "InputVariable", "b", ",", "Reader", "reader", ",", "List", "<", "OutputVariable", ">", "outputVariables", ")", "throws", "IOException", "{", "BufferedWriter", "writer", "=", "new", "BufferedWriter", "(", "new", "OutputStreamWriter", "(", "new", "FileOutputStream", "(", "file", ")", ",", "FuzzyLite", ".", "UTF_8", ")", ")", ";", "try", "{", "writeScriptExportingDataFrame", "(", "engine", ",", "writer", ",", "a", ",", "b", ",", "reader", ",", "outputVariables", ")", ";", "}", "catch", "(", "RuntimeException", "ex", ")", "{", "throw", "ex", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "ex", ";", "}", "finally", "{", "writer", ".", "close", "(", ")", ";", "}", "}" ]
Creates an R script file plotting multiple surfaces based on the input stream of values for the two input variables. @param file is the R script file @param engine is the engine to export @param a is the first input variable @param b is the second input variable @param reader is an input stream of data whose lines contain space-separated input values @param outputVariables are the output variables to create the surface for @throws IOException if any error occurs upon writing the file
[ "Creates", "an", "R", "script", "file", "plotting", "multiple", "surfaces", "based", "on", "the", "input", "stream", "of", "values", "for", "the", "two", "input", "variables", "." ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/imex/RScriptExporter.java#L255-L269
3,434
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/imex/RScriptExporter.java
RScriptExporter.writeScriptImportingDataFrame
public void writeScriptImportingDataFrame(Engine engine, Writer writer, InputVariable a, InputVariable b, String dataFramePath, List<OutputVariable> outputVariables) throws IOException { writeScriptHeader(writer, engine); writer.append("engine.fldFile = \"" + dataFramePath + "\"\n"); writer.append("if (require(data.table)) {\n" + " engine.df = data.table::fread(engine.fldFile, sep=\"auto\", header=\"auto\")\n" + "} else {\n" + " engine.df = read.table(engine.fldFile, header=TRUE)\n" + "}\n"); writer.append("\n"); writeScriptPlots(writer, a, b, outputVariables); }
java
public void writeScriptImportingDataFrame(Engine engine, Writer writer, InputVariable a, InputVariable b, String dataFramePath, List<OutputVariable> outputVariables) throws IOException { writeScriptHeader(writer, engine); writer.append("engine.fldFile = \"" + dataFramePath + "\"\n"); writer.append("if (require(data.table)) {\n" + " engine.df = data.table::fread(engine.fldFile, sep=\"auto\", header=\"auto\")\n" + "} else {\n" + " engine.df = read.table(engine.fldFile, header=TRUE)\n" + "}\n"); writer.append("\n"); writeScriptPlots(writer, a, b, outputVariables); }
[ "public", "void", "writeScriptImportingDataFrame", "(", "Engine", "engine", ",", "Writer", "writer", ",", "InputVariable", "a", ",", "InputVariable", "b", ",", "String", "dataFramePath", ",", "List", "<", "OutputVariable", ">", "outputVariables", ")", "throws", "IOException", "{", "writeScriptHeader", "(", "writer", ",", "engine", ")", ";", "writer", ".", "append", "(", "\"engine.fldFile = \\\"\"", "+", "dataFramePath", "+", "\"\\\"\\n\"", ")", ";", "writer", ".", "append", "(", "\"if (require(data.table)) {\\n\"", "+", "\" engine.df = data.table::fread(engine.fldFile, sep=\\\"auto\\\", header=\\\"auto\\\")\\n\"", "+", "\"} else {\\n\"", "+", "\" engine.df = read.table(engine.fldFile, header=TRUE)\\n\"", "+", "\"}\\n\"", ")", ";", "writer", ".", "append", "(", "\"\\n\"", ")", ";", "writeScriptPlots", "(", "writer", ",", "a", ",", "b", ",", "outputVariables", ")", ";", "}" ]
Writes an R script plotting multiple surfaces based on a manually imported data frame containing the data for the two input variables on the output variables. @param engine is the engine to export @param writer is the output where the engine will be written to @param a is the first input variable @param b is the second input variable @param dataFramePath is the path where the data frame should be located (the path will not be accessed, it will only be written to script) @param outputVariables are the output variables to create the surface for @throws IOException if any error occurs upon writing on the writer
[ "Writes", "an", "R", "script", "plotting", "multiple", "surfaces", "based", "on", "a", "manually", "imported", "data", "frame", "containing", "the", "data", "for", "the", "two", "input", "variables", "on", "the", "output", "variables", "." ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/imex/RScriptExporter.java#L286-L300
3,435
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/term/Function.java
Function.evaluate
public double evaluate(Map<String, Double> localVariables) { if (this.root == null) { throw new RuntimeException("[function error] evaluation failed " + "because function is not loaded"); } return this.root.evaluate(localVariables); }
java
public double evaluate(Map<String, Double> localVariables) { if (this.root == null) { throw new RuntimeException("[function error] evaluation failed " + "because function is not loaded"); } return this.root.evaluate(localVariables); }
[ "public", "double", "evaluate", "(", "Map", "<", "String", ",", "Double", ">", "localVariables", ")", "{", "if", "(", "this", ".", "root", "==", "null", ")", "{", "throw", "new", "RuntimeException", "(", "\"[function error] evaluation failed \"", "+", "\"because function is not loaded\"", ")", ";", "}", "return", "this", ".", "root", ".", "evaluate", "(", "localVariables", ")", ";", "}" ]
Computes the function value of this term using the given map of variable substitutions. @param localVariables is a map of substitution variables @return the function value of this term using the given map of variable substitutions.
[ "Computes", "the", "function", "value", "of", "this", "term", "using", "the", "given", "map", "of", "variable", "substitutions", "." ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/term/Function.java#L592-L598
3,436
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/term/Function.java
Function.create
public static Function create(String name, String formula, Engine engine) { Function result = new Function(name); try { result.load(formula, engine); } catch (RuntimeException ex) { throw ex; } catch (Exception ex) { throw new RuntimeException(ex); } return result; }
java
public static Function create(String name, String formula, Engine engine) { Function result = new Function(name); try { result.load(formula, engine); } catch (RuntimeException ex) { throw ex; } catch (Exception ex) { throw new RuntimeException(ex); } return result; }
[ "public", "static", "Function", "create", "(", "String", "name", ",", "String", "formula", ",", "Engine", "engine", ")", "{", "Function", "result", "=", "new", "Function", "(", "name", ")", ";", "try", "{", "result", ".", "load", "(", "formula", ",", "engine", ")", ";", "}", "catch", "(", "RuntimeException", "ex", ")", "{", "throw", "ex", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "ex", ")", ";", "}", "return", "result", ";", "}" ]
Creates a Function term with the given parameters @param name is the name of the term @param formula is the formula defining the membership function @param engine is the engine to which the Function can have access @return a Function term configured with the given parameters @throws RuntimeException if the formula has a syntax error
[ "Creates", "a", "Function", "term", "with", "the", "given", "parameters" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/term/Function.java#L610-L620
3,437
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/term/Function.java
Function.load
public void load(String formula, Engine engine) { this.root = parse(formula); this.formula = formula; this.engine = engine; }
java
public void load(String formula, Engine engine) { this.root = parse(formula); this.formula = formula; this.engine = engine; }
[ "public", "void", "load", "(", "String", "formula", ",", "Engine", "engine", ")", "{", "this", ".", "root", "=", "parse", "(", "formula", ")", ";", "this", ".", "formula", "=", "formula", ";", "this", ".", "engine", "=", "engine", ";", "}" ]
Loads the given formula expressed in infix notation, and sets the engine holding the variables to which the formula refers. @param formula is the right-hand side of a mathematical equation expressed in infix notation @param engine is the engine to which the formula can refer @throws RuntimeException if the formula has syntax errors
[ "Loads", "the", "given", "formula", "expressed", "in", "infix", "notation", "and", "sets", "the", "engine", "holding", "the", "variables", "to", "which", "the", "formula", "refers", "." ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/term/Function.java#L687-L691
3,438
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/term/Function.java
Function.parse
public Node parse(String text) { if (text.isEmpty()) { return null; } String postfix = toPostfix(text); Deque<Node> stack = new ArrayDeque<Node>(); StringTokenizer tokenizer = new StringTokenizer(postfix); String token; FunctionFactory factory = FactoryManager.instance().function(); while (tokenizer.hasMoreTokens()) { token = tokenizer.nextToken(); Element element = factory.getObject(token); boolean isOperand = element == null && !"(".equals(token) && !")".equals(token) && !",".equals(token); if (element != null) { if (element.getArity() > stack.size()) { throw new RuntimeException(String.format("[function error] " + "operator <%s> has arity <%d>, " + "but <%d> elements are available: (%s)", element.getName(), element.getArity(), stack.size(), Op.join(stack, ", "))); } Node node; try { node = new Node(element.clone()); } catch (Exception ex) { throw new RuntimeException(ex); } node.left = stack.pop(); if (element.getArity() == 2) { node.right = stack.pop(); } stack.push(node); } else if (isOperand) { Node node; try { double value = Op.toDouble(token); node = new Node(value); } catch (Exception ex) { node = new Node(token); } stack.push(node); } } if (stack.size() != 1) { throw new RuntimeException(String.format( "[function error] ill-formed formula <%s> due to: <%s>", text, Op.join(stack, ";"))); } return stack.pop(); }
java
public Node parse(String text) { if (text.isEmpty()) { return null; } String postfix = toPostfix(text); Deque<Node> stack = new ArrayDeque<Node>(); StringTokenizer tokenizer = new StringTokenizer(postfix); String token; FunctionFactory factory = FactoryManager.instance().function(); while (tokenizer.hasMoreTokens()) { token = tokenizer.nextToken(); Element element = factory.getObject(token); boolean isOperand = element == null && !"(".equals(token) && !")".equals(token) && !",".equals(token); if (element != null) { if (element.getArity() > stack.size()) { throw new RuntimeException(String.format("[function error] " + "operator <%s> has arity <%d>, " + "but <%d> elements are available: (%s)", element.getName(), element.getArity(), stack.size(), Op.join(stack, ", "))); } Node node; try { node = new Node(element.clone()); } catch (Exception ex) { throw new RuntimeException(ex); } node.left = stack.pop(); if (element.getArity() == 2) { node.right = stack.pop(); } stack.push(node); } else if (isOperand) { Node node; try { double value = Op.toDouble(token); node = new Node(value); } catch (Exception ex) { node = new Node(token); } stack.push(node); } } if (stack.size() != 1) { throw new RuntimeException(String.format( "[function error] ill-formed formula <%s> due to: <%s>", text, Op.join(stack, ";"))); } return stack.pop(); }
[ "public", "Node", "parse", "(", "String", "text", ")", "{", "if", "(", "text", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "String", "postfix", "=", "toPostfix", "(", "text", ")", ";", "Deque", "<", "Node", ">", "stack", "=", "new", "ArrayDeque", "<", "Node", ">", "(", ")", ";", "StringTokenizer", "tokenizer", "=", "new", "StringTokenizer", "(", "postfix", ")", ";", "String", "token", ";", "FunctionFactory", "factory", "=", "FactoryManager", ".", "instance", "(", ")", ".", "function", "(", ")", ";", "while", "(", "tokenizer", ".", "hasMoreTokens", "(", ")", ")", "{", "token", "=", "tokenizer", ".", "nextToken", "(", ")", ";", "Element", "element", "=", "factory", ".", "getObject", "(", "token", ")", ";", "boolean", "isOperand", "=", "element", "==", "null", "&&", "!", "\"(\"", ".", "equals", "(", "token", ")", "&&", "!", "\")\"", ".", "equals", "(", "token", ")", "&&", "!", "\",\"", ".", "equals", "(", "token", ")", ";", "if", "(", "element", "!=", "null", ")", "{", "if", "(", "element", ".", "getArity", "(", ")", ">", "stack", ".", "size", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "String", ".", "format", "(", "\"[function error] \"", "+", "\"operator <%s> has arity <%d>, \"", "+", "\"but <%d> elements are available: (%s)\"", ",", "element", ".", "getName", "(", ")", ",", "element", ".", "getArity", "(", ")", ",", "stack", ".", "size", "(", ")", ",", "Op", ".", "join", "(", "stack", ",", "\", \"", ")", ")", ")", ";", "}", "Node", "node", ";", "try", "{", "node", "=", "new", "Node", "(", "element", ".", "clone", "(", ")", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "ex", ")", ";", "}", "node", ".", "left", "=", "stack", ".", "pop", "(", ")", ";", "if", "(", "element", ".", "getArity", "(", ")", "==", "2", ")", "{", "node", ".", "right", "=", "stack", ".", "pop", "(", ")", ";", "}", "stack", ".", "push", "(", "node", ")", ";", "}", "else", "if", "(", "isOperand", ")", "{", "Node", "node", ";", "try", "{", "double", "value", "=", "Op", ".", "toDouble", "(", "token", ")", ";", "node", "=", "new", "Node", "(", "value", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "node", "=", "new", "Node", "(", "token", ")", ";", "}", "stack", ".", "push", "(", "node", ")", ";", "}", "}", "if", "(", "stack", ".", "size", "(", ")", "!=", "1", ")", "{", "throw", "new", "RuntimeException", "(", "String", ".", "format", "(", "\"[function error] ill-formed formula <%s> due to: <%s>\"", ",", "text", ",", "Op", ".", "join", "(", "stack", ",", "\";\"", ")", ")", ")", ";", "}", "return", "stack", ".", "pop", "(", ")", ";", "}" ]
Creates a node representing a binary expression tree from the given formula @param text is the right-hand side of a mathematical equation expressed in infix notation @return a node representing a binary expression tree from the given formula @throws RuntimeException if the formula has syntax errors
[ "Creates", "a", "node", "representing", "a", "binary", "expression", "tree", "from", "the", "given", "formula" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/term/Function.java#L823-L879
3,439
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/term/Aggregated.java
Aggregated.membership
@Override public double membership(double x) { if (Double.isNaN(x)) { return Double.NaN; } double mu = 0.0; for (Activated term : this.terms) { mu = this.aggregation.compute(mu, term.membership(x)); } return mu; }
java
@Override public double membership(double x) { if (Double.isNaN(x)) { return Double.NaN; } double mu = 0.0; for (Activated term : this.terms) { mu = this.aggregation.compute(mu, term.membership(x)); } return mu; }
[ "@", "Override", "public", "double", "membership", "(", "double", "x", ")", "{", "if", "(", "Double", ".", "isNaN", "(", "x", ")", ")", "{", "return", "Double", ".", "NaN", ";", "}", "double", "mu", "=", "0.0", ";", "for", "(", "Activated", "term", ":", "this", ".", "terms", ")", "{", "mu", "=", "this", ".", "aggregation", ".", "compute", "(", "mu", ",", "term", ".", "membership", "(", "x", ")", ")", ";", "}", "return", "mu", ";", "}" ]
Aggregates the membership function values of `x` utilizing the aggregation operator @param x is a value @return `\sum_i{\mu_i(x)}, i \in \mbox{terms}`
[ "Aggregates", "the", "membership", "function", "values", "of", "x", "utilizing", "the", "aggregation", "operator" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/term/Aggregated.java#L104-L114
3,440
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/term/Aggregated.java
Aggregated.highestActivatedTerm
public Activated highestActivatedTerm() { Activated maximumTerm = null; double maximumActivation = Double.POSITIVE_INFINITY; for (Activated activated : terms) { if (Op.isGt(activated.getDegree(), maximumActivation)) { maximumActivation = activated.getDegree(); maximumTerm = activated; } } return maximumTerm; }
java
public Activated highestActivatedTerm() { Activated maximumTerm = null; double maximumActivation = Double.POSITIVE_INFINITY; for (Activated activated : terms) { if (Op.isGt(activated.getDegree(), maximumActivation)) { maximumActivation = activated.getDegree(); maximumTerm = activated; } } return maximumTerm; }
[ "public", "Activated", "highestActivatedTerm", "(", ")", "{", "Activated", "maximumTerm", "=", "null", ";", "double", "maximumActivation", "=", "Double", ".", "POSITIVE_INFINITY", ";", "for", "(", "Activated", "activated", ":", "terms", ")", "{", "if", "(", "Op", ".", "isGt", "(", "activated", ".", "getDegree", "(", ")", ",", "maximumActivation", ")", ")", "{", "maximumActivation", "=", "activated", ".", "getDegree", "(", ")", ";", "maximumTerm", "=", "activated", ";", "}", "}", "return", "maximumTerm", ";", "}" ]
Iterates over the Activated terms to find the term with the maximum activation degree @return the term with the maximum activation degree
[ "Iterates", "over", "the", "Activated", "terms", "to", "find", "the", "term", "with", "the", "maximum", "activation", "degree" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/term/Aggregated.java#L146-L156
3,441
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/rule/Rule.java
Rule.activateWith
public double activateWith(TNorm conjunction, SNorm disjunction) { if (!isLoaded()) { throw new RuntimeException(String.format("[rule error] the following rule is not loaded: %s", text)); } activationDegree = weight * antecedent.activationDegree(conjunction, disjunction); return activationDegree; }
java
public double activateWith(TNorm conjunction, SNorm disjunction) { if (!isLoaded()) { throw new RuntimeException(String.format("[rule error] the following rule is not loaded: %s", text)); } activationDegree = weight * antecedent.activationDegree(conjunction, disjunction); return activationDegree; }
[ "public", "double", "activateWith", "(", "TNorm", "conjunction", ",", "SNorm", "disjunction", ")", "{", "if", "(", "!", "isLoaded", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "String", ".", "format", "(", "\"[rule error] the following rule is not loaded: %s\"", ",", "text", ")", ")", ";", "}", "activationDegree", "=", "weight", "*", "antecedent", ".", "activationDegree", "(", "conjunction", ",", "disjunction", ")", ";", "return", "activationDegree", ";", "}" ]
Activates the rule by computing its activation degree using the given conjunction and disjunction operators @param conjunction is the conjunction operator @param disjunction is the disjunction operator @return the activation degree of the rule
[ "Activates", "the", "rule", "by", "computing", "its", "activation", "degree", "using", "the", "given", "conjunction", "and", "disjunction", "operators" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/rule/Rule.java#L238-L244
3,442
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/rule/Rule.java
Rule.unload
public void unload() { deactivate(); if (getAntecedent() != null) { getAntecedent().unload(); } if (getConsequent() != null) { getConsequent().unload(); } }
java
public void unload() { deactivate(); if (getAntecedent() != null) { getAntecedent().unload(); } if (getConsequent() != null) { getConsequent().unload(); } }
[ "public", "void", "unload", "(", ")", "{", "deactivate", "(", ")", ";", "if", "(", "getAntecedent", "(", ")", "!=", "null", ")", "{", "getAntecedent", "(", ")", ".", "unload", "(", ")", ";", "}", "if", "(", "getConsequent", "(", ")", "!=", "null", ")", "{", "getConsequent", "(", ")", ".", "unload", "(", ")", ";", "}", "}" ]
Unloads the rule
[ "Unloads", "the", "rule" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/rule/Rule.java#L288-L296
3,443
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/rule/Rule.java
Rule.load
public void load(String rule, Engine engine) { deactivate(); setEnabled(true); setText(rule); StringTokenizer tokenizer = new StringTokenizer(rule); String token; StringBuilder strAntecedent = new StringBuilder(); StringBuilder strConsequent = new StringBuilder(); double ruleWeight = 1.0; final byte S_NONE = 0, S_IF = 1, S_THEN = 2, S_WITH = 3, S_END = 4; byte state = S_NONE; try { while (tokenizer.hasMoreTokens()) { token = tokenizer.nextToken(); int commentIndex = token.indexOf('#'); if (commentIndex >= 0) { token = token.substring(0, commentIndex); } switch (state) { case S_NONE: if (Rule.FL_IF.equals(token)) { state = S_IF; } else { throw new RuntimeException(String.format( "[syntax error] expected keyword <%s>, but found <%s> in rule: %s", Rule.FL_IF, token, rule)); } break; case S_IF: if (Rule.FL_THEN.equals(token)) { state = S_THEN; } else { strAntecedent.append(token).append(" "); } break; case S_THEN: if (Rule.FL_WITH.equals(token)) { state = S_WITH; } else { strConsequent.append(token).append(" "); } break; case S_WITH: try { ruleWeight = Op.toDouble(token); state = S_END; } catch (NumberFormatException ex) { throw ex; } break; case S_END: throw new RuntimeException(String.format( "[syntax error] unexpected token <%s> at the end of rule", token)); default: throw new RuntimeException(String.format( "[syntax error] unexpected state <%s>", state)); } } if (state == S_NONE) { throw new RuntimeException(String.format("[syntax error] %s rule: %s", (rule.isEmpty() ? "empty" : "ignored"), rule)); } else if (state == S_IF) { throw new RuntimeException(String.format( "[syntax error] keyword <%s> not found in rule: %s", Rule.FL_THEN, rule)); } else if (state == S_WITH) { throw new RuntimeException(String.format( "[syntax error] expected a numeric value as the weight of the rule: %s", rule)); } getAntecedent().load(strAntecedent.toString(), engine); getConsequent().load(strConsequent.toString(), engine); setWeight(ruleWeight); } catch (RuntimeException ex) { unload(); throw ex; } }
java
public void load(String rule, Engine engine) { deactivate(); setEnabled(true); setText(rule); StringTokenizer tokenizer = new StringTokenizer(rule); String token; StringBuilder strAntecedent = new StringBuilder(); StringBuilder strConsequent = new StringBuilder(); double ruleWeight = 1.0; final byte S_NONE = 0, S_IF = 1, S_THEN = 2, S_WITH = 3, S_END = 4; byte state = S_NONE; try { while (tokenizer.hasMoreTokens()) { token = tokenizer.nextToken(); int commentIndex = token.indexOf('#'); if (commentIndex >= 0) { token = token.substring(0, commentIndex); } switch (state) { case S_NONE: if (Rule.FL_IF.equals(token)) { state = S_IF; } else { throw new RuntimeException(String.format( "[syntax error] expected keyword <%s>, but found <%s> in rule: %s", Rule.FL_IF, token, rule)); } break; case S_IF: if (Rule.FL_THEN.equals(token)) { state = S_THEN; } else { strAntecedent.append(token).append(" "); } break; case S_THEN: if (Rule.FL_WITH.equals(token)) { state = S_WITH; } else { strConsequent.append(token).append(" "); } break; case S_WITH: try { ruleWeight = Op.toDouble(token); state = S_END; } catch (NumberFormatException ex) { throw ex; } break; case S_END: throw new RuntimeException(String.format( "[syntax error] unexpected token <%s> at the end of rule", token)); default: throw new RuntimeException(String.format( "[syntax error] unexpected state <%s>", state)); } } if (state == S_NONE) { throw new RuntimeException(String.format("[syntax error] %s rule: %s", (rule.isEmpty() ? "empty" : "ignored"), rule)); } else if (state == S_IF) { throw new RuntimeException(String.format( "[syntax error] keyword <%s> not found in rule: %s", Rule.FL_THEN, rule)); } else if (state == S_WITH) { throw new RuntimeException(String.format( "[syntax error] expected a numeric value as the weight of the rule: %s", rule)); } getAntecedent().load(strAntecedent.toString(), engine); getConsequent().load(strConsequent.toString(), engine); setWeight(ruleWeight); } catch (RuntimeException ex) { unload(); throw ex; } }
[ "public", "void", "load", "(", "String", "rule", ",", "Engine", "engine", ")", "{", "deactivate", "(", ")", ";", "setEnabled", "(", "true", ")", ";", "setText", "(", "rule", ")", ";", "StringTokenizer", "tokenizer", "=", "new", "StringTokenizer", "(", "rule", ")", ";", "String", "token", ";", "StringBuilder", "strAntecedent", "=", "new", "StringBuilder", "(", ")", ";", "StringBuilder", "strConsequent", "=", "new", "StringBuilder", "(", ")", ";", "double", "ruleWeight", "=", "1.0", ";", "final", "byte", "S_NONE", "=", "0", ",", "S_IF", "=", "1", ",", "S_THEN", "=", "2", ",", "S_WITH", "=", "3", ",", "S_END", "=", "4", ";", "byte", "state", "=", "S_NONE", ";", "try", "{", "while", "(", "tokenizer", ".", "hasMoreTokens", "(", ")", ")", "{", "token", "=", "tokenizer", ".", "nextToken", "(", ")", ";", "int", "commentIndex", "=", "token", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "commentIndex", ">=", "0", ")", "{", "token", "=", "token", ".", "substring", "(", "0", ",", "commentIndex", ")", ";", "}", "switch", "(", "state", ")", "{", "case", "S_NONE", ":", "if", "(", "Rule", ".", "FL_IF", ".", "equals", "(", "token", ")", ")", "{", "state", "=", "S_IF", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "String", ".", "format", "(", "\"[syntax error] expected keyword <%s>, but found <%s> in rule: %s\"", ",", "Rule", ".", "FL_IF", ",", "token", ",", "rule", ")", ")", ";", "}", "break", ";", "case", "S_IF", ":", "if", "(", "Rule", ".", "FL_THEN", ".", "equals", "(", "token", ")", ")", "{", "state", "=", "S_THEN", ";", "}", "else", "{", "strAntecedent", ".", "append", "(", "token", ")", ".", "append", "(", "\" \"", ")", ";", "}", "break", ";", "case", "S_THEN", ":", "if", "(", "Rule", ".", "FL_WITH", ".", "equals", "(", "token", ")", ")", "{", "state", "=", "S_WITH", ";", "}", "else", "{", "strConsequent", ".", "append", "(", "token", ")", ".", "append", "(", "\" \"", ")", ";", "}", "break", ";", "case", "S_WITH", ":", "try", "{", "ruleWeight", "=", "Op", ".", "toDouble", "(", "token", ")", ";", "state", "=", "S_END", ";", "}", "catch", "(", "NumberFormatException", "ex", ")", "{", "throw", "ex", ";", "}", "break", ";", "case", "S_END", ":", "throw", "new", "RuntimeException", "(", "String", ".", "format", "(", "\"[syntax error] unexpected token <%s> at the end of rule\"", ",", "token", ")", ")", ";", "default", ":", "throw", "new", "RuntimeException", "(", "String", ".", "format", "(", "\"[syntax error] unexpected state <%s>\"", ",", "state", ")", ")", ";", "}", "}", "if", "(", "state", "==", "S_NONE", ")", "{", "throw", "new", "RuntimeException", "(", "String", ".", "format", "(", "\"[syntax error] %s rule: %s\"", ",", "(", "rule", ".", "isEmpty", "(", ")", "?", "\"empty\"", ":", "\"ignored\"", ")", ",", "rule", ")", ")", ";", "}", "else", "if", "(", "state", "==", "S_IF", ")", "{", "throw", "new", "RuntimeException", "(", "String", ".", "format", "(", "\"[syntax error] keyword <%s> not found in rule: %s\"", ",", "Rule", ".", "FL_THEN", ",", "rule", ")", ")", ";", "}", "else", "if", "(", "state", "==", "S_WITH", ")", "{", "throw", "new", "RuntimeException", "(", "String", ".", "format", "(", "\"[syntax error] expected a numeric value as the weight of the rule: %s\"", ",", "rule", ")", ")", ";", "}", "getAntecedent", "(", ")", ".", "load", "(", "strAntecedent", ".", "toString", "(", ")", ",", "engine", ")", ";", "getConsequent", "(", ")", ".", "load", "(", "strConsequent", ".", "toString", "(", ")", ",", "engine", ")", ";", "setWeight", "(", "ruleWeight", ")", ";", "}", "catch", "(", "RuntimeException", "ex", ")", "{", "unload", "(", ")", ";", "throw", "ex", ";", "}", "}" ]
Loads the rule with the given text, and uses the engine to identify and retrieve references to the input variables and output variables as required @param rule is the rule in text @param engine is the engine from which the rule is part of
[ "Loads", "the", "rule", "with", "the", "given", "text", "and", "uses", "the", "engine", "to", "identify", "and", "retrieve", "references", "to", "the", "input", "variables", "and", "output", "variables", "as", "required" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/rule/Rule.java#L316-L395
3,444
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/rule/Rule.java
Rule.parse
public static Rule parse(String rule, Engine engine) { Rule result = new Rule(); result.load(rule, engine); return result; }
java
public static Rule parse(String rule, Engine engine) { Rule result = new Rule(); result.load(rule, engine); return result; }
[ "public", "static", "Rule", "parse", "(", "String", "rule", ",", "Engine", "engine", ")", "{", "Rule", "result", "=", "new", "Rule", "(", ")", ";", "result", ".", "load", "(", "rule", ",", "engine", ")", ";", "return", "result", ";", "}" ]
Parses and creates a new rule based on the text passed @param rule is the rule in text @param engine is the engine from which the rule is part of @return a new rule parsed from the given text
[ "Parses", "and", "creates", "a", "new", "rule", "based", "on", "the", "text", "passed" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/rule/Rule.java#L414-L418
3,445
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/norm/s/NilpotentMaximum.java
NilpotentMaximum.compute
@Override public double compute(double a, double b) { if (Op.isLt(a + b, 1.0)) { return Op.max(a, b); } return 1.0; }
java
@Override public double compute(double a, double b) { if (Op.isLt(a + b, 1.0)) { return Op.max(a, b); } return 1.0; }
[ "@", "Override", "public", "double", "compute", "(", "double", "a", ",", "double", "b", ")", "{", "if", "(", "Op", ".", "isLt", "(", "a", "+", "b", ",", "1.0", ")", ")", "{", "return", "Op", ".", "max", "(", "a", ",", "b", ")", ";", "}", "return", "1.0", ";", "}" ]
Computes the nilpotent maximum of two membership function values @param a is a membership function value @param b is a membership function value @return `\begin{cases} \max(a,b) & \mbox{if $a+b<0$} \cr 1 & \mbox{otherwise} \end{cases}`
[ "Computes", "the", "nilpotent", "maximum", "of", "two", "membership", "function", "values" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/norm/s/NilpotentMaximum.java#L43-L49
3,446
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/term/Ramp.java
Ramp.direction
public Direction direction() { double range = this.end - this.start; if (!Op.isFinite(range) || Op.isEq(range, 0.0)) { return Direction.Zero; } if (Op.isGt(range, 0.0)) { return Direction.Positive; } return Direction.Negative; }
java
public Direction direction() { double range = this.end - this.start; if (!Op.isFinite(range) || Op.isEq(range, 0.0)) { return Direction.Zero; } if (Op.isGt(range, 0.0)) { return Direction.Positive; } return Direction.Negative; }
[ "public", "Direction", "direction", "(", ")", "{", "double", "range", "=", "this", ".", "end", "-", "this", ".", "start", ";", "if", "(", "!", "Op", ".", "isFinite", "(", "range", ")", "||", "Op", ".", "isEq", "(", "range", ",", "0.0", ")", ")", "{", "return", "Direction", ".", "Zero", ";", "}", "if", "(", "Op", ".", "isGt", "(", "range", ",", "0.0", ")", ")", "{", "return", "Direction", ".", "Positive", ";", "}", "return", "Direction", ".", "Negative", ";", "}" ]
Returns the direction of the ramp @return the direction of the ramp
[ "Returns", "the", "direction", "of", "the", "ramp" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/term/Ramp.java#L211-L220
3,447
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/activation/Lowest.java
Lowest.activate
@Override public void activate(RuleBlock ruleBlock) { if (FuzzyLite.isDebugging()) { FuzzyLite.logger().log(Level.FINE, "Activation: {0} {1}", new String[]{getClass().getName(), parameters()}); } TNorm conjunction = ruleBlock.getConjunction(); SNorm disjunction = ruleBlock.getDisjunction(); TNorm implication = ruleBlock.getImplication(); PriorityQueue<Rule> rulesToActivate = new PriorityQueue<Rule>( numberOfRules, new Ascending()); for (Rule rule : ruleBlock.getRules()) { rule.deactivate(); if (rule.isLoaded()) { double activationDegree = rule.activateWith(conjunction, disjunction); if (Op.isGt(activationDegree, 0.0)) { rulesToActivate.offer(rule); } } } int activated = 0; while (!rulesToActivate.isEmpty() && activated++ < numberOfRules) { rulesToActivate.poll().trigger(implication); } }
java
@Override public void activate(RuleBlock ruleBlock) { if (FuzzyLite.isDebugging()) { FuzzyLite.logger().log(Level.FINE, "Activation: {0} {1}", new String[]{getClass().getName(), parameters()}); } TNorm conjunction = ruleBlock.getConjunction(); SNorm disjunction = ruleBlock.getDisjunction(); TNorm implication = ruleBlock.getImplication(); PriorityQueue<Rule> rulesToActivate = new PriorityQueue<Rule>( numberOfRules, new Ascending()); for (Rule rule : ruleBlock.getRules()) { rule.deactivate(); if (rule.isLoaded()) { double activationDegree = rule.activateWith(conjunction, disjunction); if (Op.isGt(activationDegree, 0.0)) { rulesToActivate.offer(rule); } } } int activated = 0; while (!rulesToActivate.isEmpty() && activated++ < numberOfRules) { rulesToActivate.poll().trigger(implication); } }
[ "@", "Override", "public", "void", "activate", "(", "RuleBlock", "ruleBlock", ")", "{", "if", "(", "FuzzyLite", ".", "isDebugging", "(", ")", ")", "{", "FuzzyLite", ".", "logger", "(", ")", ".", "log", "(", "Level", ".", "FINE", ",", "\"Activation: {0} {1}\"", ",", "new", "String", "[", "]", "{", "getClass", "(", ")", ".", "getName", "(", ")", ",", "parameters", "(", ")", "}", ")", ";", "}", "TNorm", "conjunction", "=", "ruleBlock", ".", "getConjunction", "(", ")", ";", "SNorm", "disjunction", "=", "ruleBlock", ".", "getDisjunction", "(", ")", ";", "TNorm", "implication", "=", "ruleBlock", ".", "getImplication", "(", ")", ";", "PriorityQueue", "<", "Rule", ">", "rulesToActivate", "=", "new", "PriorityQueue", "<", "Rule", ">", "(", "numberOfRules", ",", "new", "Ascending", "(", ")", ")", ";", "for", "(", "Rule", "rule", ":", "ruleBlock", ".", "getRules", "(", ")", ")", "{", "rule", ".", "deactivate", "(", ")", ";", "if", "(", "rule", ".", "isLoaded", "(", ")", ")", "{", "double", "activationDegree", "=", "rule", ".", "activateWith", "(", "conjunction", ",", "disjunction", ")", ";", "if", "(", "Op", ".", "isGt", "(", "activationDegree", ",", "0.0", ")", ")", "{", "rulesToActivate", ".", "offer", "(", "rule", ")", ";", "}", "}", "}", "int", "activated", "=", "0", ";", "while", "(", "!", "rulesToActivate", ".", "isEmpty", "(", ")", "&&", "activated", "++", "<", "numberOfRules", ")", "{", "rulesToActivate", ".", "poll", "(", ")", ".", "trigger", "(", "implication", ")", ";", "}", "}" ]
Activates the rules with the lowest activation degrees in the given rule block @param ruleBlock is the rule block to activate
[ "Activates", "the", "rules", "with", "the", "lowest", "activation", "degrees", "in", "the", "given", "rule", "block" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/activation/Lowest.java#L101-L129
3,448
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/activation/Proportional.java
Proportional.activate
@Override public void activate(RuleBlock ruleBlock) { if (FuzzyLite.isDebugging()) { FuzzyLite.logger().log(Level.FINE, "Activation: {0} {1}", new String[]{getClass().getName(), parameters()}); } TNorm conjunction = ruleBlock.getConjunction(); SNorm disjunction = ruleBlock.getDisjunction(); TNorm implication = ruleBlock.getImplication(); double sumActivationDegrees = 0.0; List<Rule> rulesToActivate = new ArrayList<Rule>(ruleBlock.getRules().size()); for (Rule rule : ruleBlock.getRules()) { rule.deactivate(); if (rule.isLoaded()) { double activationDegree = rule.activateWith(conjunction, disjunction); rulesToActivate.add(rule); sumActivationDegrees += activationDegree; } } for (Rule rule : rulesToActivate) { double activationDegree = rule.getActivationDegree() / sumActivationDegrees; rule.setActivationDegree(activationDegree); rule.trigger(implication); } }
java
@Override public void activate(RuleBlock ruleBlock) { if (FuzzyLite.isDebugging()) { FuzzyLite.logger().log(Level.FINE, "Activation: {0} {1}", new String[]{getClass().getName(), parameters()}); } TNorm conjunction = ruleBlock.getConjunction(); SNorm disjunction = ruleBlock.getDisjunction(); TNorm implication = ruleBlock.getImplication(); double sumActivationDegrees = 0.0; List<Rule> rulesToActivate = new ArrayList<Rule>(ruleBlock.getRules().size()); for (Rule rule : ruleBlock.getRules()) { rule.deactivate(); if (rule.isLoaded()) { double activationDegree = rule.activateWith(conjunction, disjunction); rulesToActivate.add(rule); sumActivationDegrees += activationDegree; } } for (Rule rule : rulesToActivate) { double activationDegree = rule.getActivationDegree() / sumActivationDegrees; rule.setActivationDegree(activationDegree); rule.trigger(implication); } }
[ "@", "Override", "public", "void", "activate", "(", "RuleBlock", "ruleBlock", ")", "{", "if", "(", "FuzzyLite", ".", "isDebugging", "(", ")", ")", "{", "FuzzyLite", ".", "logger", "(", ")", ".", "log", "(", "Level", ".", "FINE", ",", "\"Activation: {0} {1}\"", ",", "new", "String", "[", "]", "{", "getClass", "(", ")", ".", "getName", "(", ")", ",", "parameters", "(", ")", "}", ")", ";", "}", "TNorm", "conjunction", "=", "ruleBlock", ".", "getConjunction", "(", ")", ";", "SNorm", "disjunction", "=", "ruleBlock", ".", "getDisjunction", "(", ")", ";", "TNorm", "implication", "=", "ruleBlock", ".", "getImplication", "(", ")", ";", "double", "sumActivationDegrees", "=", "0.0", ";", "List", "<", "Rule", ">", "rulesToActivate", "=", "new", "ArrayList", "<", "Rule", ">", "(", "ruleBlock", ".", "getRules", "(", ")", ".", "size", "(", ")", ")", ";", "for", "(", "Rule", "rule", ":", "ruleBlock", ".", "getRules", "(", ")", ")", "{", "rule", ".", "deactivate", "(", ")", ";", "if", "(", "rule", ".", "isLoaded", "(", ")", ")", "{", "double", "activationDegree", "=", "rule", ".", "activateWith", "(", "conjunction", ",", "disjunction", ")", ";", "rulesToActivate", ".", "add", "(", "rule", ")", ";", "sumActivationDegrees", "+=", "activationDegree", ";", "}", "}", "for", "(", "Rule", "rule", ":", "rulesToActivate", ")", "{", "double", "activationDegree", "=", "rule", ".", "getActivationDegree", "(", ")", "/", "sumActivationDegrees", ";", "rule", ".", "setActivationDegree", "(", "activationDegree", ")", ";", "rule", ".", "trigger", "(", "implication", ")", ";", "}", "}" ]
Activates the rules utilizing activation degrees proportional to the activation degrees of the other rules in the rule block. @param ruleBlock is the rule block to activate.
[ "Activates", "the", "rules", "utilizing", "activation", "degrees", "proportional", "to", "the", "activation", "degrees", "of", "the", "other", "rules", "in", "the", "rule", "block", "." ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/activation/Proportional.java#L71-L96
3,449
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Benchmark.java
Benchmark.prepare
public void prepare(int values, FldExporter.ScopeOfValues scope) { if (engine == null) { throw new RuntimeException("[benchmark error] engine not set before " + "preparing for values and scope"); } int resolution; if (scope == FldExporter.ScopeOfValues.AllVariables) { resolution = -1 + (int) Math.max(1.0, Math.pow( values, 1.0 / engine.numberOfInputVariables())); } else {//if (type == EachVariable resolution = values - 1; } int[] sampleValues = new int[engine.numberOfInputVariables()]; int[] minSampleValues = new int[engine.numberOfInputVariables()]; int[] maxSampleValues = new int[engine.numberOfInputVariables()]; for (int i = 0; i < engine.numberOfInputVariables(); ++i) { sampleValues[i] = 0; minSampleValues[i] = 0; maxSampleValues[i] = resolution; } this.expected = new ArrayList<double[]>(); do { double[] expectedValues = new double[engine.numberOfInputVariables()]; for (int i = 0; i < engine.numberOfInputVariables(); ++i) { InputVariable inputVariable = engine.getInputVariable(i); expectedValues[i] = inputVariable.getMinimum() + sampleValues[i] * inputVariable.range() / Math.max(1, resolution); } this.expected.add(expectedValues); } while (Op.increment(sampleValues, minSampleValues, maxSampleValues)); }
java
public void prepare(int values, FldExporter.ScopeOfValues scope) { if (engine == null) { throw new RuntimeException("[benchmark error] engine not set before " + "preparing for values and scope"); } int resolution; if (scope == FldExporter.ScopeOfValues.AllVariables) { resolution = -1 + (int) Math.max(1.0, Math.pow( values, 1.0 / engine.numberOfInputVariables())); } else {//if (type == EachVariable resolution = values - 1; } int[] sampleValues = new int[engine.numberOfInputVariables()]; int[] minSampleValues = new int[engine.numberOfInputVariables()]; int[] maxSampleValues = new int[engine.numberOfInputVariables()]; for (int i = 0; i < engine.numberOfInputVariables(); ++i) { sampleValues[i] = 0; minSampleValues[i] = 0; maxSampleValues[i] = resolution; } this.expected = new ArrayList<double[]>(); do { double[] expectedValues = new double[engine.numberOfInputVariables()]; for (int i = 0; i < engine.numberOfInputVariables(); ++i) { InputVariable inputVariable = engine.getInputVariable(i); expectedValues[i] = inputVariable.getMinimum() + sampleValues[i] * inputVariable.range() / Math.max(1, resolution); } this.expected.add(expectedValues); } while (Op.increment(sampleValues, minSampleValues, maxSampleValues)); }
[ "public", "void", "prepare", "(", "int", "values", ",", "FldExporter", ".", "ScopeOfValues", "scope", ")", "{", "if", "(", "engine", "==", "null", ")", "{", "throw", "new", "RuntimeException", "(", "\"[benchmark error] engine not set before \"", "+", "\"preparing for values and scope\"", ")", ";", "}", "int", "resolution", ";", "if", "(", "scope", "==", "FldExporter", ".", "ScopeOfValues", ".", "AllVariables", ")", "{", "resolution", "=", "-", "1", "+", "(", "int", ")", "Math", ".", "max", "(", "1.0", ",", "Math", ".", "pow", "(", "values", ",", "1.0", "/", "engine", ".", "numberOfInputVariables", "(", ")", ")", ")", ";", "}", "else", "{", "//if (type == EachVariable", "resolution", "=", "values", "-", "1", ";", "}", "int", "[", "]", "sampleValues", "=", "new", "int", "[", "engine", ".", "numberOfInputVariables", "(", ")", "]", ";", "int", "[", "]", "minSampleValues", "=", "new", "int", "[", "engine", ".", "numberOfInputVariables", "(", ")", "]", ";", "int", "[", "]", "maxSampleValues", "=", "new", "int", "[", "engine", ".", "numberOfInputVariables", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "engine", ".", "numberOfInputVariables", "(", ")", ";", "++", "i", ")", "{", "sampleValues", "[", "i", "]", "=", "0", ";", "minSampleValues", "[", "i", "]", "=", "0", ";", "maxSampleValues", "[", "i", "]", "=", "resolution", ";", "}", "this", ".", "expected", "=", "new", "ArrayList", "<", "double", "[", "]", ">", "(", ")", ";", "do", "{", "double", "[", "]", "expectedValues", "=", "new", "double", "[", "engine", ".", "numberOfInputVariables", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "engine", ".", "numberOfInputVariables", "(", ")", ";", "++", "i", ")", "{", "InputVariable", "inputVariable", "=", "engine", ".", "getInputVariable", "(", "i", ")", ";", "expectedValues", "[", "i", "]", "=", "inputVariable", ".", "getMinimum", "(", ")", "+", "sampleValues", "[", "i", "]", "*", "inputVariable", ".", "range", "(", ")", "/", "Math", ".", "max", "(", "1", ",", "resolution", ")", ";", "}", "this", ".", "expected", ".", "add", "(", "expectedValues", ")", ";", "}", "while", "(", "Op", ".", "increment", "(", "sampleValues", ",", "minSampleValues", ",", "maxSampleValues", ")", ")", ";", "}" ]
Produces and loads into memory the set of expected values from the engine @param values is the number of values to evaluate the engine upon @param scope is the scope of the values to generate @throws RuntimeException if the engine is not set
[ "Produces", "and", "loads", "into", "memory", "the", "set", "of", "expected", "values", "from", "the", "engine" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Benchmark.java#L230-L262
3,450
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Benchmark.java
Benchmark.prepare
public void prepare(Reader reader, long numberOfLines) throws IOException { this.expected = new ArrayList<double[]>(); BufferedReader bufferedReader = new BufferedReader(reader); try { String line; int lineNumber = 0; while (lineNumber != numberOfLines && (line = bufferedReader.readLine()) != null) { ++lineNumber; line = line.trim(); if (line.isEmpty() || line.charAt(0) == '#') { continue; } double[] expectedValues; if (lineNumber == 1) { //automatic detection of header. try { expectedValues = Op.toDoubles(line); } catch (Exception ex) { continue; } } else { expectedValues = Op.toDoubles(line); } this.expected.add(expectedValues); } } catch (IOException ex) { throw ex; } finally { bufferedReader.close(); } }
java
public void prepare(Reader reader, long numberOfLines) throws IOException { this.expected = new ArrayList<double[]>(); BufferedReader bufferedReader = new BufferedReader(reader); try { String line; int lineNumber = 0; while (lineNumber != numberOfLines && (line = bufferedReader.readLine()) != null) { ++lineNumber; line = line.trim(); if (line.isEmpty() || line.charAt(0) == '#') { continue; } double[] expectedValues; if (lineNumber == 1) { //automatic detection of header. try { expectedValues = Op.toDoubles(line); } catch (Exception ex) { continue; } } else { expectedValues = Op.toDoubles(line); } this.expected.add(expectedValues); } } catch (IOException ex) { throw ex; } finally { bufferedReader.close(); } }
[ "public", "void", "prepare", "(", "Reader", "reader", ",", "long", "numberOfLines", ")", "throws", "IOException", "{", "this", ".", "expected", "=", "new", "ArrayList", "<", "double", "[", "]", ">", "(", ")", ";", "BufferedReader", "bufferedReader", "=", "new", "BufferedReader", "(", "reader", ")", ";", "try", "{", "String", "line", ";", "int", "lineNumber", "=", "0", ";", "while", "(", "lineNumber", "!=", "numberOfLines", "&&", "(", "line", "=", "bufferedReader", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "++", "lineNumber", ";", "line", "=", "line", ".", "trim", "(", ")", ";", "if", "(", "line", ".", "isEmpty", "(", ")", "||", "line", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "continue", ";", "}", "double", "[", "]", "expectedValues", ";", "if", "(", "lineNumber", "==", "1", ")", "{", "//automatic detection of header.", "try", "{", "expectedValues", "=", "Op", ".", "toDoubles", "(", "line", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "continue", ";", "}", "}", "else", "{", "expectedValues", "=", "Op", ".", "toDoubles", "(", "line", ")", ";", "}", "this", ".", "expected", ".", "add", "(", "expectedValues", ")", ";", "}", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "ex", ";", "}", "finally", "{", "bufferedReader", ".", "close", "(", ")", ";", "}", "}" ]
Reads and loads into memory the set of expected values from the engine @param reader is the reader of a set of lines containing space-separated values @param numberOfLines is the maximum number of lines to read from the reader, and a value $f@n=(\infty, -1]$f@ reads the entire file. @throws IOException if the reader cannot be read
[ "Reads", "and", "loads", "into", "memory", "the", "set", "of", "expected", "values", "from", "the", "engine" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Benchmark.java#L284-L315
3,451
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Benchmark.java
Benchmark.run
public double[] run(int times) { if (engine == null) { throw new RuntimeException("[benchmark error] engine not set for benchmark"); } double[] runtimes = new double[times]; final int offset = engine.getInputVariables().size(); for (int t = 0; t < times; ++t) { obtained = new ArrayList<double[]>(expected.size()); for (int i = 0; i < expected.size(); ++i) { obtained.add(new double[engine.numberOfInputVariables() + engine.numberOfOutputVariables()]); } engine.restart(); long start = System.nanoTime(); for (int evaluation = 0; evaluation < expected.size(); ++evaluation) { double[] expectedValues = expected.get(evaluation); double[] obtainedValues = obtained.get(evaluation); if (expectedValues.length < engine.getInputVariables().size()) { throw new RuntimeException(MessageFormat.format( "[benchmark error] the number of input values given <{0}> " + "at line <{1}> must be at least the same number of input variables " + "<{2}> in the engine", expectedValues.length, evaluation + 1, engine.numberOfInputVariables())); } for (int i = 0; i < engine.getInputVariables().size(); ++i) { engine.getInputVariables().get(i).setValue(expectedValues[i]); obtainedValues[i] = expectedValues[i]; } engine.process(); for (int i = 0; i < engine.getOutputVariables().size(); ++i) { obtainedValues[i + offset] = engine.getOutputVariables().get(i).getValue(); } } long end = System.nanoTime(); runtimes[t] = end - start; } for (double x : runtimes) { this.times.add(x); } return runtimes; }
java
public double[] run(int times) { if (engine == null) { throw new RuntimeException("[benchmark error] engine not set for benchmark"); } double[] runtimes = new double[times]; final int offset = engine.getInputVariables().size(); for (int t = 0; t < times; ++t) { obtained = new ArrayList<double[]>(expected.size()); for (int i = 0; i < expected.size(); ++i) { obtained.add(new double[engine.numberOfInputVariables() + engine.numberOfOutputVariables()]); } engine.restart(); long start = System.nanoTime(); for (int evaluation = 0; evaluation < expected.size(); ++evaluation) { double[] expectedValues = expected.get(evaluation); double[] obtainedValues = obtained.get(evaluation); if (expectedValues.length < engine.getInputVariables().size()) { throw new RuntimeException(MessageFormat.format( "[benchmark error] the number of input values given <{0}> " + "at line <{1}> must be at least the same number of input variables " + "<{2}> in the engine", expectedValues.length, evaluation + 1, engine.numberOfInputVariables())); } for (int i = 0; i < engine.getInputVariables().size(); ++i) { engine.getInputVariables().get(i).setValue(expectedValues[i]); obtainedValues[i] = expectedValues[i]; } engine.process(); for (int i = 0; i < engine.getOutputVariables().size(); ++i) { obtainedValues[i + offset] = engine.getOutputVariables().get(i).getValue(); } } long end = System.nanoTime(); runtimes[t] = end - start; } for (double x : runtimes) { this.times.add(x); } return runtimes; }
[ "public", "double", "[", "]", "run", "(", "int", "times", ")", "{", "if", "(", "engine", "==", "null", ")", "{", "throw", "new", "RuntimeException", "(", "\"[benchmark error] engine not set for benchmark\"", ")", ";", "}", "double", "[", "]", "runtimes", "=", "new", "double", "[", "times", "]", ";", "final", "int", "offset", "=", "engine", ".", "getInputVariables", "(", ")", ".", "size", "(", ")", ";", "for", "(", "int", "t", "=", "0", ";", "t", "<", "times", ";", "++", "t", ")", "{", "obtained", "=", "new", "ArrayList", "<", "double", "[", "]", ">", "(", "expected", ".", "size", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "expected", ".", "size", "(", ")", ";", "++", "i", ")", "{", "obtained", ".", "add", "(", "new", "double", "[", "engine", ".", "numberOfInputVariables", "(", ")", "+", "engine", ".", "numberOfOutputVariables", "(", ")", "]", ")", ";", "}", "engine", ".", "restart", "(", ")", ";", "long", "start", "=", "System", ".", "nanoTime", "(", ")", ";", "for", "(", "int", "evaluation", "=", "0", ";", "evaluation", "<", "expected", ".", "size", "(", ")", ";", "++", "evaluation", ")", "{", "double", "[", "]", "expectedValues", "=", "expected", ".", "get", "(", "evaluation", ")", ";", "double", "[", "]", "obtainedValues", "=", "obtained", ".", "get", "(", "evaluation", ")", ";", "if", "(", "expectedValues", ".", "length", "<", "engine", ".", "getInputVariables", "(", ")", ".", "size", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "MessageFormat", ".", "format", "(", "\"[benchmark error] the number of input values given <{0}> \"", "+", "\"at line <{1}> must be at least the same number of input variables \"", "+", "\"<{2}> in the engine\"", ",", "expectedValues", ".", "length", ",", "evaluation", "+", "1", ",", "engine", ".", "numberOfInputVariables", "(", ")", ")", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "engine", ".", "getInputVariables", "(", ")", ".", "size", "(", ")", ";", "++", "i", ")", "{", "engine", ".", "getInputVariables", "(", ")", ".", "get", "(", "i", ")", ".", "setValue", "(", "expectedValues", "[", "i", "]", ")", ";", "obtainedValues", "[", "i", "]", "=", "expectedValues", "[", "i", "]", ";", "}", "engine", ".", "process", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "engine", ".", "getOutputVariables", "(", ")", ".", "size", "(", ")", ";", "++", "i", ")", "{", "obtainedValues", "[", "i", "+", "offset", "]", "=", "engine", ".", "getOutputVariables", "(", ")", ".", "get", "(", "i", ")", ".", "getValue", "(", ")", ";", "}", "}", "long", "end", "=", "System", ".", "nanoTime", "(", ")", ";", "runtimes", "[", "t", "]", "=", "end", "-", "start", ";", "}", "for", "(", "double", "x", ":", "runtimes", ")", "{", "this", ".", "times", ".", "add", "(", "x", ")", ";", "}", "return", "runtimes", ";", "}" ]
Runs the benchmark on the engine multiple times @param times is the number of times to run the benchmark on the engine @return vector of the time in nanoseconds required by each run, which is also appended to the times stored in Benchmark::getTimes()
[ "Runs", "the", "benchmark", "on", "the", "engine", "multiple", "times" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Benchmark.java#L334-L382
3,452
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Benchmark.java
Benchmark.canComputeErrors
public boolean canComputeErrors() { return !(engine == null || expected.isEmpty() || obtained.isEmpty() || expected.size() != obtained.size() || expected.get(0).length != obtained.get(0).length || expected.get(0).length != engine.variables().size()); }
java
public boolean canComputeErrors() { return !(engine == null || expected.isEmpty() || obtained.isEmpty() || expected.size() != obtained.size() || expected.get(0).length != obtained.get(0).length || expected.get(0).length != engine.variables().size()); }
[ "public", "boolean", "canComputeErrors", "(", ")", "{", "return", "!", "(", "engine", "==", "null", "||", "expected", ".", "isEmpty", "(", ")", "||", "obtained", ".", "isEmpty", "(", ")", "||", "expected", ".", "size", "(", ")", "!=", "obtained", ".", "size", "(", ")", "||", "expected", ".", "get", "(", "0", ")", ".", "length", "!=", "obtained", ".", "get", "(", "0", ")", ".", "length", "||", "expected", ".", "get", "(", "0", ")", ".", "length", "!=", "engine", ".", "variables", "(", ")", ".", "size", "(", ")", ")", ";", "}" ]
Indicates whether errors can be computed based on the expected and obtained values from the benchmark. If the benchmark was prepared from a file reader and the file included columns of expected output values and the benchmark has been run at least once, then the benchmark can automatically compute the errors and will automatically include them in the results. @return whether errors can be computed based on the expected and obtained values from the benchmark
[ "Indicates", "whether", "errors", "can", "be", "computed", "based", "on", "the", "expected", "and", "obtained", "values", "from", "the", "benchmark", ".", "If", "the", "benchmark", "was", "prepared", "from", "a", "file", "reader", "and", "the", "file", "included", "columns", "of", "expected", "output", "values", "and", "the", "benchmark", "has", "been", "run", "at", "least", "once", "then", "the", "benchmark", "can", "automatically", "compute", "the", "errors", "and", "will", "automatically", "include", "them", "in", "the", "results", "." ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Benchmark.java#L402-L407
3,453
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Benchmark.java
Benchmark.numberOfErrors
public int numberOfErrors(ErrorType errorType, OutputVariable outputVariable) { if (!canComputeErrors()) { return -1; } int errors = 0; final int offset = engine.numberOfInputVariables(); for (int i = 0; i < expected.size(); ++i) { double[] e = expected.get(i); double[] o = obtained.get(i); for (int y = 0; y < engine.numberOfOutputVariables(); ++y) { if (outputVariable == null || outputVariable == engine.getOutputVariable(y)) { if (!Op.isEq(e[offset + y], o[offset + y], tolerance)) { double difference = e[offset + y] - o[offset + y]; if (errorType == ErrorType.Accuracy && Op.isFinite(difference)) { ++errors; } else if (errorType == ErrorType.NonFinite && !Op.isFinite(difference)) { ++errors; } else if (errorType == ErrorType.All) { ++errors; } } } } } return errors; }
java
public int numberOfErrors(ErrorType errorType, OutputVariable outputVariable) { if (!canComputeErrors()) { return -1; } int errors = 0; final int offset = engine.numberOfInputVariables(); for (int i = 0; i < expected.size(); ++i) { double[] e = expected.get(i); double[] o = obtained.get(i); for (int y = 0; y < engine.numberOfOutputVariables(); ++y) { if (outputVariable == null || outputVariable == engine.getOutputVariable(y)) { if (!Op.isEq(e[offset + y], o[offset + y], tolerance)) { double difference = e[offset + y] - o[offset + y]; if (errorType == ErrorType.Accuracy && Op.isFinite(difference)) { ++errors; } else if (errorType == ErrorType.NonFinite && !Op.isFinite(difference)) { ++errors; } else if (errorType == ErrorType.All) { ++errors; } } } } } return errors; }
[ "public", "int", "numberOfErrors", "(", "ErrorType", "errorType", ",", "OutputVariable", "outputVariable", ")", "{", "if", "(", "!", "canComputeErrors", "(", ")", ")", "{", "return", "-", "1", ";", "}", "int", "errors", "=", "0", ";", "final", "int", "offset", "=", "engine", ".", "numberOfInputVariables", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "expected", ".", "size", "(", ")", ";", "++", "i", ")", "{", "double", "[", "]", "e", "=", "expected", ".", "get", "(", "i", ")", ";", "double", "[", "]", "o", "=", "obtained", ".", "get", "(", "i", ")", ";", "for", "(", "int", "y", "=", "0", ";", "y", "<", "engine", ".", "numberOfOutputVariables", "(", ")", ";", "++", "y", ")", "{", "if", "(", "outputVariable", "==", "null", "||", "outputVariable", "==", "engine", ".", "getOutputVariable", "(", "y", ")", ")", "{", "if", "(", "!", "Op", ".", "isEq", "(", "e", "[", "offset", "+", "y", "]", ",", "o", "[", "offset", "+", "y", "]", ",", "tolerance", ")", ")", "{", "double", "difference", "=", "e", "[", "offset", "+", "y", "]", "-", "o", "[", "offset", "+", "y", "]", ";", "if", "(", "errorType", "==", "ErrorType", ".", "Accuracy", "&&", "Op", ".", "isFinite", "(", "difference", ")", ")", "{", "++", "errors", ";", "}", "else", "if", "(", "errorType", "==", "ErrorType", ".", "NonFinite", "&&", "!", "Op", ".", "isFinite", "(", "difference", ")", ")", "{", "++", "errors", ";", "}", "else", "if", "(", "errorType", "==", "ErrorType", ".", "All", ")", "{", "++", "errors", ";", "}", "}", "}", "}", "}", "return", "errors", ";", "}" ]
Computes the number of errors of the given type over the given output variable. @param errorType is type of error to account for @param outputVariable is output variable to account the errors for @return the number of errors over the given output variable
[ "Computes", "the", "number", "of", "errors", "of", "the", "given", "type", "over", "the", "given", "output", "variable", "." ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Benchmark.java#L570-L597
3,454
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Benchmark.java
Benchmark.factorOf
public double factorOf(TimeUnit unit) { if (unit == TimeUnit.NanoSeconds) { return 1.0; } else if (unit == TimeUnit.MicroSeconds) { return 1.0e-3; } else if (unit == TimeUnit.MilliSeconds) { return 1.0e-6; } else if (unit == TimeUnit.Seconds) { return 1.0e-9; } else if (unit == TimeUnit.Minutes) { return 1.0e-9 / 60; } else if (unit == TimeUnit.Hours) { return 1.0e-9 / 3600; } return Double.NaN; }
java
public double factorOf(TimeUnit unit) { if (unit == TimeUnit.NanoSeconds) { return 1.0; } else if (unit == TimeUnit.MicroSeconds) { return 1.0e-3; } else if (unit == TimeUnit.MilliSeconds) { return 1.0e-6; } else if (unit == TimeUnit.Seconds) { return 1.0e-9; } else if (unit == TimeUnit.Minutes) { return 1.0e-9 / 60; } else if (unit == TimeUnit.Hours) { return 1.0e-9 / 3600; } return Double.NaN; }
[ "public", "double", "factorOf", "(", "TimeUnit", "unit", ")", "{", "if", "(", "unit", "==", "TimeUnit", ".", "NanoSeconds", ")", "{", "return", "1.0", ";", "}", "else", "if", "(", "unit", "==", "TimeUnit", ".", "MicroSeconds", ")", "{", "return", "1.0e-3", ";", "}", "else", "if", "(", "unit", "==", "TimeUnit", ".", "MilliSeconds", ")", "{", "return", "1.0e-6", ";", "}", "else", "if", "(", "unit", "==", "TimeUnit", ".", "Seconds", ")", "{", "return", "1.0e-9", ";", "}", "else", "if", "(", "unit", "==", "TimeUnit", ".", "Minutes", ")", "{", "return", "1.0e-9", "/", "60", ";", "}", "else", "if", "(", "unit", "==", "TimeUnit", ".", "Hours", ")", "{", "return", "1.0e-9", "/", "3600", ";", "}", "return", "Double", ".", "NaN", ";", "}" ]
Returns the factor of the given unit from NanoSeconds @param unit is the unit of time @return the factor of the given unit from NanoSeconds
[ "Returns", "the", "factor", "of", "the", "given", "unit", "from", "NanoSeconds" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Benchmark.java#L605-L620
3,455
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Benchmark.java
Benchmark.convert
public double convert(double time, TimeUnit from, TimeUnit to) { return time * factorOf(to) / factorOf(from); }
java
public double convert(double time, TimeUnit from, TimeUnit to) { return time * factorOf(to) / factorOf(from); }
[ "public", "double", "convert", "(", "double", "time", ",", "TimeUnit", "from", ",", "TimeUnit", "to", ")", "{", "return", "time", "*", "factorOf", "(", "to", ")", "/", "factorOf", "(", "from", ")", ";", "}" ]
Converts the time to different scales @param time is the time to convert @param from is the units of the time to convert from @param to is the units of the time to convert to @return the time in the units specified
[ "Converts", "the", "time", "to", "different", "scales" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Benchmark.java#L630-L632
3,456
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Benchmark.java
Benchmark.header
public Set<String> header(int runs, boolean includeErrors) { Benchmark result = new Benchmark(); Engine dummy = new Engine(); dummy.addOutputVariable(new OutputVariable()); result.setEngine(dummy); Double[] dummyTimes = new Double[runs]; Arrays.fill(dummyTimes, Double.NaN); result.setTimes(Arrays.asList(dummyTimes)); if (includeErrors) { double[] dummyArray = new double[1]; List<double[]> dummyList = new ArrayList<double[]>(); dummyList.add(dummyArray); result.setExpected(dummyList); result.setObtained(dummyList); } return result.results().keySet(); }
java
public Set<String> header(int runs, boolean includeErrors) { Benchmark result = new Benchmark(); Engine dummy = new Engine(); dummy.addOutputVariable(new OutputVariable()); result.setEngine(dummy); Double[] dummyTimes = new Double[runs]; Arrays.fill(dummyTimes, Double.NaN); result.setTimes(Arrays.asList(dummyTimes)); if (includeErrors) { double[] dummyArray = new double[1]; List<double[]> dummyList = new ArrayList<double[]>(); dummyList.add(dummyArray); result.setExpected(dummyList); result.setObtained(dummyList); } return result.results().keySet(); }
[ "public", "Set", "<", "String", ">", "header", "(", "int", "runs", ",", "boolean", "includeErrors", ")", "{", "Benchmark", "result", "=", "new", "Benchmark", "(", ")", ";", "Engine", "dummy", "=", "new", "Engine", "(", ")", ";", "dummy", ".", "addOutputVariable", "(", "new", "OutputVariable", "(", ")", ")", ";", "result", ".", "setEngine", "(", "dummy", ")", ";", "Double", "[", "]", "dummyTimes", "=", "new", "Double", "[", "runs", "]", ";", "Arrays", ".", "fill", "(", "dummyTimes", ",", "Double", ".", "NaN", ")", ";", "result", ".", "setTimes", "(", "Arrays", ".", "asList", "(", "dummyTimes", ")", ")", ";", "if", "(", "includeErrors", ")", "{", "double", "[", "]", "dummyArray", "=", "new", "double", "[", "1", "]", ";", "List", "<", "double", "[", "]", ">", "dummyList", "=", "new", "ArrayList", "<", "double", "[", "]", ">", "(", ")", ";", "dummyList", ".", "add", "(", "dummyArray", ")", ";", "result", ".", "setExpected", "(", "dummyList", ")", ";", "result", ".", "setObtained", "(", "dummyList", ")", ";", "}", "return", "result", ".", "results", "(", ")", ".", "keySet", "(", ")", ";", "}" ]
Returns the header of a horizontal table of results @param runs is the number of times the benchmark will be run, hence producing the relevant number of columns for each run @param includeErrors indicates whether to include columns for computing the errors @return the header of a horizontal table of results
[ "Returns", "the", "header", "of", "a", "horizontal", "table", "of", "results" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Benchmark.java#L643-L663
3,457
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Benchmark.java
Benchmark.results
public Map<String, String> results(TimeUnit timeUnit, boolean includeTimes) { return results(null, timeUnit, includeTimes); }
java
public Map<String, String> results(TimeUnit timeUnit, boolean includeTimes) { return results(null, timeUnit, includeTimes); }
[ "public", "Map", "<", "String", ",", "String", ">", "results", "(", "TimeUnit", "timeUnit", ",", "boolean", "includeTimes", ")", "{", "return", "results", "(", "null", ",", "timeUnit", ",", "includeTimes", ")", ";", "}" ]
Computes and returns the results from the benchmark aggregating the statistics of all the output variables @param timeUnit is the unit of time of the results @param includeTimes indicates whether to include the times of each run @return the results from the benchmark
[ "Computes", "and", "returns", "the", "results", "from", "the", "benchmark", "aggregating", "the", "statistics", "of", "all", "the", "output", "variables" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Benchmark.java#L694-L696
3,458
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/imex/Exporter.java
Exporter.toFile
public void toFile(File file, Engine engine) throws IOException { if (!file.createNewFile()) { FuzzyLite.logger().log(Level.FINE, "Replacing file: {0}", file.getAbsolutePath()); } BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(file), FuzzyLite.UTF_8)); try { writer.write(toString(engine)); } catch (IOException ex) { throw ex; } finally { writer.close(); } }
java
public void toFile(File file, Engine engine) throws IOException { if (!file.createNewFile()) { FuzzyLite.logger().log(Level.FINE, "Replacing file: {0}", file.getAbsolutePath()); } BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(file), FuzzyLite.UTF_8)); try { writer.write(toString(engine)); } catch (IOException ex) { throw ex; } finally { writer.close(); } }
[ "public", "void", "toFile", "(", "File", "file", ",", "Engine", "engine", ")", "throws", "IOException", "{", "if", "(", "!", "file", ".", "createNewFile", "(", ")", ")", "{", "FuzzyLite", ".", "logger", "(", ")", ".", "log", "(", "Level", ".", "FINE", ",", "\"Replacing file: {0}\"", ",", "file", ".", "getAbsolutePath", "(", ")", ")", ";", "}", "BufferedWriter", "writer", "=", "new", "BufferedWriter", "(", "new", "OutputStreamWriter", "(", "new", "FileOutputStream", "(", "file", ")", ",", "FuzzyLite", ".", "UTF_8", ")", ")", ";", "try", "{", "writer", ".", "write", "(", "toString", "(", "engine", ")", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "ex", ";", "}", "finally", "{", "writer", ".", "close", "(", ")", ";", "}", "}" ]
Stores the string representation of the engine into the specified file @param file is the file to export the engine to @param engine is the engine to export @throws IOException if any problem occurs upon creation or writing to the file
[ "Stores", "the", "string", "representation", "of", "the", "engine", "into", "the", "specified", "file" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/imex/Exporter.java#L58-L71
3,459
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/imex/FldExporter.java
FldExporter.header
public String header(Engine engine) { List<String> result = new LinkedList<String>(); if (exportInputValues) { for (InputVariable inputVariable : engine.getInputVariables()) { result.add(inputVariable.getName()); } } if (exportOutputValues) { for (OutputVariable outputVariable : engine.getOutputVariables()) { result.add(outputVariable.getName()); } } return Op.join(result, separator); }
java
public String header(Engine engine) { List<String> result = new LinkedList<String>(); if (exportInputValues) { for (InputVariable inputVariable : engine.getInputVariables()) { result.add(inputVariable.getName()); } } if (exportOutputValues) { for (OutputVariable outputVariable : engine.getOutputVariables()) { result.add(outputVariable.getName()); } } return Op.join(result, separator); }
[ "public", "String", "header", "(", "Engine", "engine", ")", "{", "List", "<", "String", ">", "result", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";", "if", "(", "exportInputValues", ")", "{", "for", "(", "InputVariable", "inputVariable", ":", "engine", ".", "getInputVariables", "(", ")", ")", "{", "result", ".", "add", "(", "inputVariable", ".", "getName", "(", ")", ")", ";", "}", "}", "if", "(", "exportOutputValues", ")", "{", "for", "(", "OutputVariable", "outputVariable", ":", "engine", ".", "getOutputVariables", "(", ")", ")", "{", "result", ".", "add", "(", "outputVariable", ".", "getName", "(", ")", ")", ";", "}", "}", "return", "Op", ".", "join", "(", "result", ",", "separator", ")", ";", "}" ]
Gets the header of the dataset for the given engine @param engine is the engine to be exported @return the header of the dataset for the given engine
[ "Gets", "the", "header", "of", "the", "dataset", "for", "the", "given", "engine" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/imex/FldExporter.java#L165-L178
3,460
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/defuzzifier/WeightedDefuzzifier.java
WeightedDefuzzifier.inferType
public Type inferType(Term term) { if (term instanceof Constant || term instanceof Linear || term instanceof Function) { return Type.TakagiSugeno; } return Type.Tsukamoto; }
java
public Type inferType(Term term) { if (term instanceof Constant || term instanceof Linear || term instanceof Function) { return Type.TakagiSugeno; } return Type.Tsukamoto; }
[ "public", "Type", "inferType", "(", "Term", "term", ")", "{", "if", "(", "term", "instanceof", "Constant", "||", "term", "instanceof", "Linear", "||", "term", "instanceof", "Function", ")", "{", "return", "Type", ".", "TakagiSugeno", ";", "}", "return", "Type", ".", "Tsukamoto", ";", "}" ]
Infers the type of the defuzzifier based on the given term. If the given term is Constant, Linear or Function, then the type is TakagiSugeno; otherwise, the type is Tsukamoto @param term is the given term @return the inferred type of the defuzzifier based on the given term
[ "Infers", "the", "type", "of", "the", "defuzzifier", "based", "on", "the", "given", "term", ".", "If", "the", "given", "term", "is", "Constant", "Linear", "or", "Function", "then", "the", "type", "is", "TakagiSugeno", ";", "otherwise", "the", "type", "is", "Tsukamoto" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/defuzzifier/WeightedDefuzzifier.java#L93-L98
3,461
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/variable/OutputVariable.java
OutputVariable.defuzzify
public void defuzzify() { if (!isEnabled()) { return; } if (Op.isFinite(getValue())) { setPreviousValue(getValue()); } String exception = null; double result = Double.NaN; boolean isValid = !fuzzyOutput().getTerms().isEmpty(); if (isValid) { /* Checks whether the variable can be defuzzified without exceptions. * If it cannot be defuzzified, be that due to a missing defuzzifier * or aggregation operator, the expected behaviour is to leave the * variable in a state that reflects an invalid defuzzification, * that is, apply logic of default values and previous values.*/ isValid = false; if (getDefuzzifier() != null) { try { result = getDefuzzifier().defuzzify(fuzzyOutput(), getMinimum(), getMaximum()); isValid = true; } catch (Exception ex) { exception = ex.toString(); } } else { exception = String.format("[defuzzifier error] defuzzifier needed " + "to defuzzify output variable <%s>", getName()); } } if (!isValid) { //if a previous defuzzification was successfully performed and //and the output value is supposed not to change when the output is empty if (isLockPreviousValue() && !Double.isNaN(getPreviousValue())) { result = getPreviousValue(); } else { result = getDefaultValue(); } } setValue(result); if (exception != null) { throw new RuntimeException(exception); } }
java
public void defuzzify() { if (!isEnabled()) { return; } if (Op.isFinite(getValue())) { setPreviousValue(getValue()); } String exception = null; double result = Double.NaN; boolean isValid = !fuzzyOutput().getTerms().isEmpty(); if (isValid) { /* Checks whether the variable can be defuzzified without exceptions. * If it cannot be defuzzified, be that due to a missing defuzzifier * or aggregation operator, the expected behaviour is to leave the * variable in a state that reflects an invalid defuzzification, * that is, apply logic of default values and previous values.*/ isValid = false; if (getDefuzzifier() != null) { try { result = getDefuzzifier().defuzzify(fuzzyOutput(), getMinimum(), getMaximum()); isValid = true; } catch (Exception ex) { exception = ex.toString(); } } else { exception = String.format("[defuzzifier error] defuzzifier needed " + "to defuzzify output variable <%s>", getName()); } } if (!isValid) { //if a previous defuzzification was successfully performed and //and the output value is supposed not to change when the output is empty if (isLockPreviousValue() && !Double.isNaN(getPreviousValue())) { result = getPreviousValue(); } else { result = getDefaultValue(); } } setValue(result); if (exception != null) { throw new RuntimeException(exception); } }
[ "public", "void", "defuzzify", "(", ")", "{", "if", "(", "!", "isEnabled", "(", ")", ")", "{", "return", ";", "}", "if", "(", "Op", ".", "isFinite", "(", "getValue", "(", ")", ")", ")", "{", "setPreviousValue", "(", "getValue", "(", ")", ")", ";", "}", "String", "exception", "=", "null", ";", "double", "result", "=", "Double", ".", "NaN", ";", "boolean", "isValid", "=", "!", "fuzzyOutput", "(", ")", ".", "getTerms", "(", ")", ".", "isEmpty", "(", ")", ";", "if", "(", "isValid", ")", "{", "/* Checks whether the variable can be defuzzified without exceptions.\n * If it cannot be defuzzified, be that due to a missing defuzzifier\n * or aggregation operator, the expected behaviour is to leave the\n * variable in a state that reflects an invalid defuzzification,\n * that is, apply logic of default values and previous values.*/", "isValid", "=", "false", ";", "if", "(", "getDefuzzifier", "(", ")", "!=", "null", ")", "{", "try", "{", "result", "=", "getDefuzzifier", "(", ")", ".", "defuzzify", "(", "fuzzyOutput", "(", ")", ",", "getMinimum", "(", ")", ",", "getMaximum", "(", ")", ")", ";", "isValid", "=", "true", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "exception", "=", "ex", ".", "toString", "(", ")", ";", "}", "}", "else", "{", "exception", "=", "String", ".", "format", "(", "\"[defuzzifier error] defuzzifier needed \"", "+", "\"to defuzzify output variable <%s>\"", ",", "getName", "(", ")", ")", ";", "}", "}", "if", "(", "!", "isValid", ")", "{", "//if a previous defuzzification was successfully performed and", "//and the output value is supposed not to change when the output is empty", "if", "(", "isLockPreviousValue", "(", ")", "&&", "!", "Double", ".", "isNaN", "(", "getPreviousValue", "(", ")", ")", ")", "{", "result", "=", "getPreviousValue", "(", ")", ";", "}", "else", "{", "result", "=", "getDefaultValue", "(", ")", ";", "}", "}", "setValue", "(", "result", ")", ";", "if", "(", "exception", "!=", "null", ")", "{", "throw", "new", "RuntimeException", "(", "exception", ")", ";", "}", "}" ]
Defuzzifies the output variable and stores the output value and the previous output value
[ "Defuzzifies", "the", "output", "variable", "and", "stores", "the", "output", "value", "and", "the", "previous", "output", "value" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/variable/OutputVariable.java#L228-L277
3,462
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/rule/RuleBlock.java
RuleBlock.loadRules
public void loadRules(Engine engine) { List<String> exceptions = new ArrayList<String>(); for (Rule rule : this.rules) { if (rule.isLoaded()) { rule.unload(); } try { rule.load(engine); } catch (Exception ex) { exceptions.add(String.format("[%s]: %s", rule.getText(), ex.toString())); } } if (!exceptions.isEmpty()) { throw new RuntimeException("[ruleblock error] the following " + "rules could not be loaded:\n" + Op.join(exceptions, "\n")); } }
java
public void loadRules(Engine engine) { List<String> exceptions = new ArrayList<String>(); for (Rule rule : this.rules) { if (rule.isLoaded()) { rule.unload(); } try { rule.load(engine); } catch (Exception ex) { exceptions.add(String.format("[%s]: %s", rule.getText(), ex.toString())); } } if (!exceptions.isEmpty()) { throw new RuntimeException("[ruleblock error] the following " + "rules could not be loaded:\n" + Op.join(exceptions, "\n")); } }
[ "public", "void", "loadRules", "(", "Engine", "engine", ")", "{", "List", "<", "String", ">", "exceptions", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "Rule", "rule", ":", "this", ".", "rules", ")", "{", "if", "(", "rule", ".", "isLoaded", "(", ")", ")", "{", "rule", ".", "unload", "(", ")", ";", "}", "try", "{", "rule", ".", "load", "(", "engine", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "exceptions", ".", "add", "(", "String", ".", "format", "(", "\"[%s]: %s\"", ",", "rule", ".", "getText", "(", ")", ",", "ex", ".", "toString", "(", ")", ")", ")", ";", "}", "}", "if", "(", "!", "exceptions", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"[ruleblock error] the following \"", "+", "\"rules could not be loaded:\\n\"", "+", "Op", ".", "join", "(", "exceptions", ",", "\"\\n\"", ")", ")", ";", "}", "}" ]
Loads all the rules into the rule block @param engine is the engine where this rule block is registered
[ "Loads", "all", "the", "rules", "into", "the", "rule", "block" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/rule/RuleBlock.java#L86-L102
3,463
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/term/Binary.java
Binary.direction
public Direction direction() { if (direction > start) { return Direction.Positive; } if (direction < start) { return Direction.Negative; } return Direction.Undefined; }
java
public Direction direction() { if (direction > start) { return Direction.Positive; } if (direction < start) { return Direction.Negative; } return Direction.Undefined; }
[ "public", "Direction", "direction", "(", ")", "{", "if", "(", "direction", ">", "start", ")", "{", "return", "Direction", ".", "Positive", ";", "}", "if", "(", "direction", "<", "start", ")", "{", "return", "Direction", ".", "Negative", ";", "}", "return", "Direction", ".", "Undefined", ";", "}" ]
Gets the Direction of the binary edge as an enumerator @return the Direction of the binary edge as an enumerator
[ "Gets", "the", "Direction", "of", "the", "binary", "edge", "as", "an", "enumerator" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/term/Binary.java#L184-L192
3,464
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/term/Activated.java
Activated.membership
@Override public double membership(double x) { if (Double.isNaN(x)) { return Double.NaN; } if (implication == null) { throw new RuntimeException(String.format("[implication error] " + "implication operator needed to activate %s", getTerm().toString())); } return implication.compute(term.membership(x), degree); }
java
@Override public double membership(double x) { if (Double.isNaN(x)) { return Double.NaN; } if (implication == null) { throw new RuntimeException(String.format("[implication error] " + "implication operator needed to activate %s", getTerm().toString())); } return implication.compute(term.membership(x), degree); }
[ "@", "Override", "public", "double", "membership", "(", "double", "x", ")", "{", "if", "(", "Double", ".", "isNaN", "(", "x", ")", ")", "{", "return", "Double", ".", "NaN", ";", "}", "if", "(", "implication", "==", "null", ")", "{", "throw", "new", "RuntimeException", "(", "String", ".", "format", "(", "\"[implication error] \"", "+", "\"implication operator needed to activate %s\"", ",", "getTerm", "(", ")", ".", "toString", "(", ")", ")", ")", ";", "}", "return", "implication", ".", "compute", "(", "term", ".", "membership", "(", "x", ")", ",", "degree", ")", ";", "}" ]
Computes the implication of the activation degree and the membership function value of `x` @param x is a value @return `d \otimes \mu(x)`, where `d` is the activation degree
[ "Computes", "the", "implication", "of", "the", "activation", "degree", "and", "the", "membership", "function", "value", "of", "x" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/term/Activated.java#L57-L68
3,465
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/term/Sigmoid.java
Sigmoid.direction
public Direction direction() { if (!Op.isFinite(slope) || Op.isEq(slope, 0.0)) { return Direction.Zero; } if (Op.isGt(slope, 0.0)) { return Direction.Positive; } return Direction.Negative; }
java
public Direction direction() { if (!Op.isFinite(slope) || Op.isEq(slope, 0.0)) { return Direction.Zero; } if (Op.isGt(slope, 0.0)) { return Direction.Positive; } return Direction.Negative; }
[ "public", "Direction", "direction", "(", ")", "{", "if", "(", "!", "Op", ".", "isFinite", "(", "slope", ")", "||", "Op", ".", "isEq", "(", "slope", ",", "0.0", ")", ")", "{", "return", "Direction", ".", "Zero", ";", "}", "if", "(", "Op", ".", "isGt", "(", "slope", ",", "0.0", ")", ")", "{", "return", "Direction", ".", "Positive", ";", "}", "return", "Direction", ".", "Negative", ";", "}" ]
Returns the direction of the sigmoid @return the direction of the sigmoid
[ "Returns", "the", "direction", "of", "the", "sigmoid" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/term/Sigmoid.java#L200-L208
3,466
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Console.java
Console.mamdani
public static Engine mamdani() { Engine engine = new Engine(); engine.setName("simple-dimmer"); engine.setDescription(""); InputVariable ambient = new InputVariable(); ambient.setName("ambient"); ambient.setDescription(""); ambient.setEnabled(true); ambient.setRange(0.000, 1.000); ambient.setLockValueInRange(false); ambient.addTerm(new Triangle("DARK", 0.000, 0.250, 0.500)); ambient.addTerm(new Triangle("MEDIUM", 0.250, 0.500, 0.750)); ambient.addTerm(new Triangle("BRIGHT", 0.500, 0.750, 1.000)); engine.addInputVariable(ambient); OutputVariable power = new OutputVariable(); power.setName("power"); power.setDescription(""); power.setEnabled(true); power.setRange(0.000, 2.000); power.setLockValueInRange(false); power.setAggregation(new Maximum()); power.setDefuzzifier(new Centroid(200)); power.setDefaultValue(Double.NaN); power.setLockPreviousValue(false); power.addTerm(new Triangle("LOW", 0.000, 0.500, 1.000)); power.addTerm(new Triangle("MEDIUM", 0.500, 1.000, 1.500)); power.addTerm(new Triangle("HIGH", 1.000, 1.500, 2.000)); engine.addOutputVariable(power); RuleBlock ruleBlock = new RuleBlock(); ruleBlock.setName(""); ruleBlock.setDescription(""); ruleBlock.setEnabled(true); ruleBlock.setConjunction(null); ruleBlock.setDisjunction(null); ruleBlock.setImplication(new Minimum()); ruleBlock.setActivation(new General()); ruleBlock.addRule(Rule.parse("if ambient is DARK then power is HIGH", engine)); ruleBlock.addRule(Rule.parse("if ambient is MEDIUM then power is MEDIUM", engine)); ruleBlock.addRule(Rule.parse("if ambient is BRIGHT then power is LOW", engine)); engine.addRuleBlock(ruleBlock); return engine; }
java
public static Engine mamdani() { Engine engine = new Engine(); engine.setName("simple-dimmer"); engine.setDescription(""); InputVariable ambient = new InputVariable(); ambient.setName("ambient"); ambient.setDescription(""); ambient.setEnabled(true); ambient.setRange(0.000, 1.000); ambient.setLockValueInRange(false); ambient.addTerm(new Triangle("DARK", 0.000, 0.250, 0.500)); ambient.addTerm(new Triangle("MEDIUM", 0.250, 0.500, 0.750)); ambient.addTerm(new Triangle("BRIGHT", 0.500, 0.750, 1.000)); engine.addInputVariable(ambient); OutputVariable power = new OutputVariable(); power.setName("power"); power.setDescription(""); power.setEnabled(true); power.setRange(0.000, 2.000); power.setLockValueInRange(false); power.setAggregation(new Maximum()); power.setDefuzzifier(new Centroid(200)); power.setDefaultValue(Double.NaN); power.setLockPreviousValue(false); power.addTerm(new Triangle("LOW", 0.000, 0.500, 1.000)); power.addTerm(new Triangle("MEDIUM", 0.500, 1.000, 1.500)); power.addTerm(new Triangle("HIGH", 1.000, 1.500, 2.000)); engine.addOutputVariable(power); RuleBlock ruleBlock = new RuleBlock(); ruleBlock.setName(""); ruleBlock.setDescription(""); ruleBlock.setEnabled(true); ruleBlock.setConjunction(null); ruleBlock.setDisjunction(null); ruleBlock.setImplication(new Minimum()); ruleBlock.setActivation(new General()); ruleBlock.addRule(Rule.parse("if ambient is DARK then power is HIGH", engine)); ruleBlock.addRule(Rule.parse("if ambient is MEDIUM then power is MEDIUM", engine)); ruleBlock.addRule(Rule.parse("if ambient is BRIGHT then power is LOW", engine)); engine.addRuleBlock(ruleBlock); return engine; }
[ "public", "static", "Engine", "mamdani", "(", ")", "{", "Engine", "engine", "=", "new", "Engine", "(", ")", ";", "engine", ".", "setName", "(", "\"simple-dimmer\"", ")", ";", "engine", ".", "setDescription", "(", "\"\"", ")", ";", "InputVariable", "ambient", "=", "new", "InputVariable", "(", ")", ";", "ambient", ".", "setName", "(", "\"ambient\"", ")", ";", "ambient", ".", "setDescription", "(", "\"\"", ")", ";", "ambient", ".", "setEnabled", "(", "true", ")", ";", "ambient", ".", "setRange", "(", "0.000", ",", "1.000", ")", ";", "ambient", ".", "setLockValueInRange", "(", "false", ")", ";", "ambient", ".", "addTerm", "(", "new", "Triangle", "(", "\"DARK\"", ",", "0.000", ",", "0.250", ",", "0.500", ")", ")", ";", "ambient", ".", "addTerm", "(", "new", "Triangle", "(", "\"MEDIUM\"", ",", "0.250", ",", "0.500", ",", "0.750", ")", ")", ";", "ambient", ".", "addTerm", "(", "new", "Triangle", "(", "\"BRIGHT\"", ",", "0.500", ",", "0.750", ",", "1.000", ")", ")", ";", "engine", ".", "addInputVariable", "(", "ambient", ")", ";", "OutputVariable", "power", "=", "new", "OutputVariable", "(", ")", ";", "power", ".", "setName", "(", "\"power\"", ")", ";", "power", ".", "setDescription", "(", "\"\"", ")", ";", "power", ".", "setEnabled", "(", "true", ")", ";", "power", ".", "setRange", "(", "0.000", ",", "2.000", ")", ";", "power", ".", "setLockValueInRange", "(", "false", ")", ";", "power", ".", "setAggregation", "(", "new", "Maximum", "(", ")", ")", ";", "power", ".", "setDefuzzifier", "(", "new", "Centroid", "(", "200", ")", ")", ";", "power", ".", "setDefaultValue", "(", "Double", ".", "NaN", ")", ";", "power", ".", "setLockPreviousValue", "(", "false", ")", ";", "power", ".", "addTerm", "(", "new", "Triangle", "(", "\"LOW\"", ",", "0.000", ",", "0.500", ",", "1.000", ")", ")", ";", "power", ".", "addTerm", "(", "new", "Triangle", "(", "\"MEDIUM\"", ",", "0.500", ",", "1.000", ",", "1.500", ")", ")", ";", "power", ".", "addTerm", "(", "new", "Triangle", "(", "\"HIGH\"", ",", "1.000", ",", "1.500", ",", "2.000", ")", ")", ";", "engine", ".", "addOutputVariable", "(", "power", ")", ";", "RuleBlock", "ruleBlock", "=", "new", "RuleBlock", "(", ")", ";", "ruleBlock", ".", "setName", "(", "\"\"", ")", ";", "ruleBlock", ".", "setDescription", "(", "\"\"", ")", ";", "ruleBlock", ".", "setEnabled", "(", "true", ")", ";", "ruleBlock", ".", "setConjunction", "(", "null", ")", ";", "ruleBlock", ".", "setDisjunction", "(", "null", ")", ";", "ruleBlock", ".", "setImplication", "(", "new", "Minimum", "(", ")", ")", ";", "ruleBlock", ".", "setActivation", "(", "new", "General", "(", ")", ")", ";", "ruleBlock", ".", "addRule", "(", "Rule", ".", "parse", "(", "\"if ambient is DARK then power is HIGH\"", ",", "engine", ")", ")", ";", "ruleBlock", ".", "addRule", "(", "Rule", ".", "parse", "(", "\"if ambient is MEDIUM then power is MEDIUM\"", ",", "engine", ")", ")", ";", "ruleBlock", ".", "addRule", "(", "Rule", ".", "parse", "(", "\"if ambient is BRIGHT then power is LOW\"", ",", "engine", ")", ")", ";", "engine", ".", "addRuleBlock", "(", "ruleBlock", ")", ";", "return", "engine", ";", "}" ]
Creates a new Mamdani Engine based on the SimpleDimmer example @return a new Mamdani Engine based on the SimpleDimmer example
[ "Creates", "a", "new", "Mamdani", "Engine", "based", "on", "the", "SimpleDimmer", "example" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Console.java#L493-L538
3,467
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Console.java
Console.benchmark
public void benchmark(File fllFile, File fldFile, int runs, Writer writer) throws Exception { Engine engine = new FllImporter().fromFile(fllFile); Reader reader = new InputStreamReader(new FileInputStream(fldFile), FuzzyLite.UTF_8); try { Benchmark benchmark = new Benchmark(engine.getName(), engine); benchmark.prepare(reader); if (writer != null) { FuzzyLite.logger().log(Level.INFO, "\tEvaluating on {0} values read from {1}", new Object[]{benchmark.getExpected().size(), fldFile.getAbsolutePath()}); } for (int i = 0; i < runs; ++i) { benchmark.runOnce(); } String results = benchmark.format(benchmark.results(), Benchmark.TableShape.Horizontal, Benchmark.TableContents.Body) + "\n"; if (writer != null) { double[] times = new double[benchmark.getTimes().size()]; for (int i = 0; i < benchmark.getTimes().size(); ++i) { times[i] = benchmark.getTimes().get(i); } FuzzyLite.logger().log(Level.INFO, "\tMean(t)={0}", Op.str(Op.mean(times))); writer.write(results); writer.flush(); } else { System.out.println(results); } } catch (Exception ex) { throw ex; } finally { reader.close(); } }
java
public void benchmark(File fllFile, File fldFile, int runs, Writer writer) throws Exception { Engine engine = new FllImporter().fromFile(fllFile); Reader reader = new InputStreamReader(new FileInputStream(fldFile), FuzzyLite.UTF_8); try { Benchmark benchmark = new Benchmark(engine.getName(), engine); benchmark.prepare(reader); if (writer != null) { FuzzyLite.logger().log(Level.INFO, "\tEvaluating on {0} values read from {1}", new Object[]{benchmark.getExpected().size(), fldFile.getAbsolutePath()}); } for (int i = 0; i < runs; ++i) { benchmark.runOnce(); } String results = benchmark.format(benchmark.results(), Benchmark.TableShape.Horizontal, Benchmark.TableContents.Body) + "\n"; if (writer != null) { double[] times = new double[benchmark.getTimes().size()]; for (int i = 0; i < benchmark.getTimes().size(); ++i) { times[i] = benchmark.getTimes().get(i); } FuzzyLite.logger().log(Level.INFO, "\tMean(t)={0}", Op.str(Op.mean(times))); writer.write(results); writer.flush(); } else { System.out.println(results); } } catch (Exception ex) { throw ex; } finally { reader.close(); } }
[ "public", "void", "benchmark", "(", "File", "fllFile", ",", "File", "fldFile", ",", "int", "runs", ",", "Writer", "writer", ")", "throws", "Exception", "{", "Engine", "engine", "=", "new", "FllImporter", "(", ")", ".", "fromFile", "(", "fllFile", ")", ";", "Reader", "reader", "=", "new", "InputStreamReader", "(", "new", "FileInputStream", "(", "fldFile", ")", ",", "FuzzyLite", ".", "UTF_8", ")", ";", "try", "{", "Benchmark", "benchmark", "=", "new", "Benchmark", "(", "engine", ".", "getName", "(", ")", ",", "engine", ")", ";", "benchmark", ".", "prepare", "(", "reader", ")", ";", "if", "(", "writer", "!=", "null", ")", "{", "FuzzyLite", ".", "logger", "(", ")", ".", "log", "(", "Level", ".", "INFO", ",", "\"\\tEvaluating on {0} values read from {1}\"", ",", "new", "Object", "[", "]", "{", "benchmark", ".", "getExpected", "(", ")", ".", "size", "(", ")", ",", "fldFile", ".", "getAbsolutePath", "(", ")", "}", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "runs", ";", "++", "i", ")", "{", "benchmark", ".", "runOnce", "(", ")", ";", "}", "String", "results", "=", "benchmark", ".", "format", "(", "benchmark", ".", "results", "(", ")", ",", "Benchmark", ".", "TableShape", ".", "Horizontal", ",", "Benchmark", ".", "TableContents", ".", "Body", ")", "+", "\"\\n\"", ";", "if", "(", "writer", "!=", "null", ")", "{", "double", "[", "]", "times", "=", "new", "double", "[", "benchmark", ".", "getTimes", "(", ")", ".", "size", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "benchmark", ".", "getTimes", "(", ")", ".", "size", "(", ")", ";", "++", "i", ")", "{", "times", "[", "i", "]", "=", "benchmark", ".", "getTimes", "(", ")", ".", "get", "(", "i", ")", ";", "}", "FuzzyLite", ".", "logger", "(", ")", ".", "log", "(", "Level", ".", "INFO", ",", "\"\\tMean(t)={0}\"", ",", "Op", ".", "str", "(", "Op", ".", "mean", "(", "times", ")", ")", ")", ";", "writer", ".", "write", "(", "results", ")", ";", "writer", ".", "flush", "(", ")", ";", "}", "else", "{", "System", ".", "out", ".", "println", "(", "results", ")", ";", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "ex", ";", "}", "finally", "{", "reader", ".", "close", "(", ")", ";", "}", "}" ]
Benchmarks the engine described in the FLL file against the dataset contained in the FLD file. @param fllFile is the file describing the engine in FLL format @param fldFile is the file containing the dataset in FLD format @param runs is the number of runs to evaluate the benchmarks @param writer is the output where the results will be written to @throws Exception if something goes wrong reading the files, importing the engines or evaluating the benchmark
[ "Benchmarks", "the", "engine", "described", "in", "the", "FLL", "file", "against", "the", "dataset", "contained", "in", "the", "FLD", "file", "." ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Console.java#L954-L991
3,468
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/Console.java
Console.benchmarks
public void benchmarks(File fllFileList, File fldFileList, int runs, Writer writer) throws Exception { List<String> fllFiles = new ArrayList<String>(); List<String> fldFiles = new ArrayList<String>(); { BufferedReader fllReader = new BufferedReader( new InputStreamReader(new FileInputStream(fllFileList), FuzzyLite.UTF_8)); BufferedReader fldReader = new BufferedReader( new InputStreamReader(new FileInputStream(fldFileList), FuzzyLite.UTF_8)); try { String fllLine, fldLine; while ((fllLine = fllReader.readLine()) != null && (fldLine = fldReader.readLine()) != null) { fllLine = fllLine.trim(); fldLine = fldLine.trim(); if (fllLine.isEmpty() || fllLine.charAt(0) == '#') { continue; } fllFiles.add(fllLine); fldFiles.add(fldLine); } } catch (Exception ex) { throw ex; } finally { fllReader.close(); fldReader.close(); } } if (writer != null) { writer.write(Op.join(new Benchmark().header(runs, true), "\t") + "\n"); writer.flush(); } else { System.out.println(Op.join(new Benchmark().header(runs, true), "\t")); } for (int i = 0; i < fllFiles.size(); ++i) { if (writer != null) { FuzzyLite.logger().log(Level.INFO, "Benchmark {0}/{1}: {2}", new Object[]{i + 1, fllFiles.size(), fllFiles.get(i)}); } benchmark(new File(fllFiles.get(i)), new File(fldFiles.get(i)), runs, writer); } }
java
public void benchmarks(File fllFileList, File fldFileList, int runs, Writer writer) throws Exception { List<String> fllFiles = new ArrayList<String>(); List<String> fldFiles = new ArrayList<String>(); { BufferedReader fllReader = new BufferedReader( new InputStreamReader(new FileInputStream(fllFileList), FuzzyLite.UTF_8)); BufferedReader fldReader = new BufferedReader( new InputStreamReader(new FileInputStream(fldFileList), FuzzyLite.UTF_8)); try { String fllLine, fldLine; while ((fllLine = fllReader.readLine()) != null && (fldLine = fldReader.readLine()) != null) { fllLine = fllLine.trim(); fldLine = fldLine.trim(); if (fllLine.isEmpty() || fllLine.charAt(0) == '#') { continue; } fllFiles.add(fllLine); fldFiles.add(fldLine); } } catch (Exception ex) { throw ex; } finally { fllReader.close(); fldReader.close(); } } if (writer != null) { writer.write(Op.join(new Benchmark().header(runs, true), "\t") + "\n"); writer.flush(); } else { System.out.println(Op.join(new Benchmark().header(runs, true), "\t")); } for (int i = 0; i < fllFiles.size(); ++i) { if (writer != null) { FuzzyLite.logger().log(Level.INFO, "Benchmark {0}/{1}: {2}", new Object[]{i + 1, fllFiles.size(), fllFiles.get(i)}); } benchmark(new File(fllFiles.get(i)), new File(fldFiles.get(i)), runs, writer); } }
[ "public", "void", "benchmarks", "(", "File", "fllFileList", ",", "File", "fldFileList", ",", "int", "runs", ",", "Writer", "writer", ")", "throws", "Exception", "{", "List", "<", "String", ">", "fllFiles", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "List", "<", "String", ">", "fldFiles", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "{", "BufferedReader", "fllReader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "new", "FileInputStream", "(", "fllFileList", ")", ",", "FuzzyLite", ".", "UTF_8", ")", ")", ";", "BufferedReader", "fldReader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "new", "FileInputStream", "(", "fldFileList", ")", ",", "FuzzyLite", ".", "UTF_8", ")", ")", ";", "try", "{", "String", "fllLine", ",", "fldLine", ";", "while", "(", "(", "fllLine", "=", "fllReader", ".", "readLine", "(", ")", ")", "!=", "null", "&&", "(", "fldLine", "=", "fldReader", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "fllLine", "=", "fllLine", ".", "trim", "(", ")", ";", "fldLine", "=", "fldLine", ".", "trim", "(", ")", ";", "if", "(", "fllLine", ".", "isEmpty", "(", ")", "||", "fllLine", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "continue", ";", "}", "fllFiles", ".", "add", "(", "fllLine", ")", ";", "fldFiles", ".", "add", "(", "fldLine", ")", ";", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "ex", ";", "}", "finally", "{", "fllReader", ".", "close", "(", ")", ";", "fldReader", ".", "close", "(", ")", ";", "}", "}", "if", "(", "writer", "!=", "null", ")", "{", "writer", ".", "write", "(", "Op", ".", "join", "(", "new", "Benchmark", "(", ")", ".", "header", "(", "runs", ",", "true", ")", ",", "\"\\t\"", ")", "+", "\"\\n\"", ")", ";", "writer", ".", "flush", "(", ")", ";", "}", "else", "{", "System", ".", "out", ".", "println", "(", "Op", ".", "join", "(", "new", "Benchmark", "(", ")", ".", "header", "(", "runs", ",", "true", ")", ",", "\"\\t\"", ")", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "fllFiles", ".", "size", "(", ")", ";", "++", "i", ")", "{", "if", "(", "writer", "!=", "null", ")", "{", "FuzzyLite", ".", "logger", "(", ")", ".", "log", "(", "Level", ".", "INFO", ",", "\"Benchmark {0}/{1}: {2}\"", ",", "new", "Object", "[", "]", "{", "i", "+", "1", ",", "fllFiles", ".", "size", "(", ")", ",", "fllFiles", ".", "get", "(", "i", ")", "}", ")", ";", "}", "benchmark", "(", "new", "File", "(", "fllFiles", ".", "get", "(", "i", ")", ")", ",", "new", "File", "(", "fldFiles", ".", "get", "(", "i", ")", ")", ",", "runs", ",", "writer", ")", ";", "}", "}" ]
Benchmarks the list of engines against the list of datasets, both described as absolute or relative paths @param fllFileList is the file containing the list of paths of engines in FLL format @param fldFileList is the file containing the list of paths of datasets in FLD format @param runs is the number of runs to evaluate the benchmarks @param writer is the output where the results will be written to @throws Exception if something goes wrong reading the files, importing the engines or evaluating the benchmark
[ "Benchmarks", "the", "list", "of", "engines", "against", "the", "list", "of", "datasets", "both", "described", "as", "absolute", "or", "relative", "paths" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/Console.java#L1006-L1048
3,469
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/variable/Variable.java
Variable.setValue
public void setValue(double value) { this.value = lockValueInRange ? Op.bound(value, minimum, maximum) : value; }
java
public void setValue(double value) { this.value = lockValueInRange ? Op.bound(value, minimum, maximum) : value; }
[ "public", "void", "setValue", "(", "double", "value", ")", "{", "this", ".", "value", "=", "lockValueInRange", "?", "Op", ".", "bound", "(", "value", ",", "minimum", ",", "maximum", ")", ":", "value", ";", "}" ]
Sets the value of the variable @param value is the input value of an InputVariable, or the output value of an OutputVariable
[ "Sets", "the", "value", "of", "the", "variable" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/variable/Variable.java#L124-L128
3,470
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/variable/Variable.java
Variable.fuzzify
public String fuzzify(double x) { StringBuilder sb = new StringBuilder(); for (Term term : getTerms()) { double fx = term.membership(x); if (sb.length() == 0) { sb.append(Op.str(fx)); } else if (Double.isNaN(fx) || Op.isGE(fx, 0.0)) { sb.append(" + ").append(Op.str(fx)); } else { sb.append(" - ").append(Op.str(fx)); } sb.append("/").append(term.getName()); } return sb.toString(); }
java
public String fuzzify(double x) { StringBuilder sb = new StringBuilder(); for (Term term : getTerms()) { double fx = term.membership(x); if (sb.length() == 0) { sb.append(Op.str(fx)); } else if (Double.isNaN(fx) || Op.isGE(fx, 0.0)) { sb.append(" + ").append(Op.str(fx)); } else { sb.append(" - ").append(Op.str(fx)); } sb.append("/").append(term.getName()); } return sb.toString(); }
[ "public", "String", "fuzzify", "(", "double", "x", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "Term", "term", ":", "getTerms", "(", ")", ")", "{", "double", "fx", "=", "term", ".", "membership", "(", "x", ")", ";", "if", "(", "sb", ".", "length", "(", ")", "==", "0", ")", "{", "sb", ".", "append", "(", "Op", ".", "str", "(", "fx", ")", ")", ";", "}", "else", "if", "(", "Double", ".", "isNaN", "(", "fx", ")", "||", "Op", ".", "isGE", "(", "fx", ",", "0.0", ")", ")", "{", "sb", ".", "append", "(", "\" + \"", ")", ".", "append", "(", "Op", ".", "str", "(", "fx", ")", ")", ";", "}", "else", "{", "sb", ".", "append", "(", "\" - \"", ")", ".", "append", "(", "Op", ".", "str", "(", "fx", ")", ")", ";", "}", "sb", ".", "append", "(", "\"/\"", ")", ".", "append", "(", "term", ".", "getName", "(", ")", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Evaluates the membership function of value `x` for each term `i`, resulting in a fuzzy value in the form `\tilde{x}=\sum_i{\mu_i(x)/i}` @param x is the value to fuzzify @return the fuzzy value expressed as `\sum_i{\mu_i(x)/i}`
[ "Evaluates", "the", "membership", "function", "of", "value", "x", "for", "each", "term", "i", "resulting", "in", "a", "fuzzy", "value", "in", "the", "form" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/variable/Variable.java#L276-L292
3,471
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/variable/Variable.java
Variable.highestMembership
public Op.Pair<Double, Term> highestMembership(double x) { Op.Pair<Double, Term> result = new Op.Pair<Double, Term>(0.0, null); for (Term term : terms) { double y = term.membership(x); if (Op.isGt(y, result.getFirst())) { result.setFirst(y); result.setSecond(term); } } return result; }
java
public Op.Pair<Double, Term> highestMembership(double x) { Op.Pair<Double, Term> result = new Op.Pair<Double, Term>(0.0, null); for (Term term : terms) { double y = term.membership(x); if (Op.isGt(y, result.getFirst())) { result.setFirst(y); result.setSecond(term); } } return result; }
[ "public", "Op", ".", "Pair", "<", "Double", ",", "Term", ">", "highestMembership", "(", "double", "x", ")", "{", "Op", ".", "Pair", "<", "Double", ",", "Term", ">", "result", "=", "new", "Op", ".", "Pair", "<", "Double", ",", "Term", ">", "(", "0.0", ",", "null", ")", ";", "for", "(", "Term", "term", ":", "terms", ")", "{", "double", "y", "=", "term", ".", "membership", "(", "x", ")", ";", "if", "(", "Op", ".", "isGt", "(", "y", ",", "result", ".", "getFirst", "(", ")", ")", ")", "{", "result", ".", "setFirst", "(", "y", ")", ";", "result", ".", "setSecond", "(", "term", ")", ";", "}", "}", "return", "result", ";", "}" ]
Gets the term which has the highest membership function value for `x`. @param x is the value of interest @return a pair containing the highest membership function value and the term `i` that maximizes `\mu_i(x)`.
[ "Gets", "the", "term", "which", "has", "the", "highest", "membership", "function", "value", "for" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/variable/Variable.java#L303-L313
3,472
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/variable/Variable.java
Variable.sort
public void sort() { PriorityQueue<Op.Pair<Term, Double>> termCentroids = new PriorityQueue<Op.Pair<Term, Double>>( terms.size(), new Ascending()); Defuzzifier defuzzifier = new Centroid(); for (Term term : terms) { double centroid; try { if (term instanceof Constant || term instanceof Linear) { centroid = term.membership(0); } else { centroid = defuzzifier.defuzzify(term, getMinimum(), getMaximum()); } } catch (Exception ex) { centroid = Double.POSITIVE_INFINITY; } termCentroids.offer(new Op.Pair<Term, Double>(term, centroid)); } List<Term> sortedTerms = new ArrayList<Term>(terms.size()); while (!termCentroids.isEmpty()) { sortedTerms.add(termCentroids.poll().getFirst()); } setTerms(sortedTerms); }
java
public void sort() { PriorityQueue<Op.Pair<Term, Double>> termCentroids = new PriorityQueue<Op.Pair<Term, Double>>( terms.size(), new Ascending()); Defuzzifier defuzzifier = new Centroid(); for (Term term : terms) { double centroid; try { if (term instanceof Constant || term instanceof Linear) { centroid = term.membership(0); } else { centroid = defuzzifier.defuzzify(term, getMinimum(), getMaximum()); } } catch (Exception ex) { centroid = Double.POSITIVE_INFINITY; } termCentroids.offer(new Op.Pair<Term, Double>(term, centroid)); } List<Term> sortedTerms = new ArrayList<Term>(terms.size()); while (!termCentroids.isEmpty()) { sortedTerms.add(termCentroids.poll().getFirst()); } setTerms(sortedTerms); }
[ "public", "void", "sort", "(", ")", "{", "PriorityQueue", "<", "Op", ".", "Pair", "<", "Term", ",", "Double", ">", ">", "termCentroids", "=", "new", "PriorityQueue", "<", "Op", ".", "Pair", "<", "Term", ",", "Double", ">", ">", "(", "terms", ".", "size", "(", ")", ",", "new", "Ascending", "(", ")", ")", ";", "Defuzzifier", "defuzzifier", "=", "new", "Centroid", "(", ")", ";", "for", "(", "Term", "term", ":", "terms", ")", "{", "double", "centroid", ";", "try", "{", "if", "(", "term", "instanceof", "Constant", "||", "term", "instanceof", "Linear", ")", "{", "centroid", "=", "term", ".", "membership", "(", "0", ")", ";", "}", "else", "{", "centroid", "=", "defuzzifier", ".", "defuzzify", "(", "term", ",", "getMinimum", "(", ")", ",", "getMaximum", "(", ")", ")", ";", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "centroid", "=", "Double", ".", "POSITIVE_INFINITY", ";", "}", "termCentroids", ".", "offer", "(", "new", "Op", ".", "Pair", "<", "Term", ",", "Double", ">", "(", "term", ",", "centroid", ")", ")", ";", "}", "List", "<", "Term", ">", "sortedTerms", "=", "new", "ArrayList", "<", "Term", ">", "(", "terms", ".", "size", "(", ")", ")", ";", "while", "(", "!", "termCentroids", ".", "isEmpty", "(", ")", ")", "{", "sortedTerms", ".", "add", "(", "termCentroids", ".", "poll", "(", ")", ".", "getFirst", "(", ")", ")", ";", "}", "setTerms", "(", "sortedTerms", ")", ";", "}" ]
Sorts the terms in ascending order according to their centroids
[ "Sorts", "the", "terms", "in", "ascending", "order", "according", "to", "their", "centroids" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/variable/Variable.java#L352-L376
3,473
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/variable/Variable.java
Variable.getTerm
public Term getTerm(String name) { for (Term term : this.terms) { if (name.equals(term.getName())) { return term; } } return null; }
java
public Term getTerm(String name) { for (Term term : this.terms) { if (name.equals(term.getName())) { return term; } } return null; }
[ "public", "Term", "getTerm", "(", "String", "name", ")", "{", "for", "(", "Term", "term", ":", "this", ".", "terms", ")", "{", "if", "(", "name", ".", "equals", "(", "term", ".", "getName", "(", ")", ")", ")", "{", "return", "term", ";", "}", "}", "return", "null", ";", "}" ]
Gets the term of the given name. @param name is the name of the term to retrieve @return the term of the given name
[ "Gets", "the", "term", "of", "the", "given", "name", "." ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/variable/Variable.java#L413-L420
3,474
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/variable/Variable.java
Variable.removeTerm
public Term removeTerm(String name) { Iterator<Term> it = this.terms.iterator(); while (it.hasNext()) { Term term = it.next(); if (term.getName().equals(name)) { it.remove(); return term; } } return null; }
java
public Term removeTerm(String name) { Iterator<Term> it = this.terms.iterator(); while (it.hasNext()) { Term term = it.next(); if (term.getName().equals(name)) { it.remove(); return term; } } return null; }
[ "public", "Term", "removeTerm", "(", "String", "name", ")", "{", "Iterator", "<", "Term", ">", "it", "=", "this", ".", "terms", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "Term", "term", "=", "it", ".", "next", "(", ")", ";", "if", "(", "term", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", ")", "{", "it", ".", "remove", "(", ")", ";", "return", "term", ";", "}", "}", "return", "null", ";", "}" ]
Removes the term @param name is the name of the term to remove @return the removed term or null if not found
[ "Removes", "the", "term" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/variable/Variable.java#L448-L458
3,475
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/FuzzyLite.java
FuzzyLite.setDecimals
public static void setDecimals(int decimals) { FuzzyLite.decimals = decimals; DecimalFormat decimalFormat = FORMATTER.get(); decimalFormat.setMinimumFractionDigits(decimals); decimalFormat.setMaximumFractionDigits(decimals); }
java
public static void setDecimals(int decimals) { FuzzyLite.decimals = decimals; DecimalFormat decimalFormat = FORMATTER.get(); decimalFormat.setMinimumFractionDigits(decimals); decimalFormat.setMaximumFractionDigits(decimals); }
[ "public", "static", "void", "setDecimals", "(", "int", "decimals", ")", "{", "FuzzyLite", ".", "decimals", "=", "decimals", ";", "DecimalFormat", "decimalFormat", "=", "FORMATTER", ".", "get", "(", ")", ";", "decimalFormat", ".", "setMinimumFractionDigits", "(", "decimals", ")", ";", "decimalFormat", ".", "setMaximumFractionDigits", "(", "decimals", ")", ";", "}" ]
Sets the number of decimals utilized when formatting scalar values @param decimals is the number of decimals utilized when formatting scalar values
[ "Sets", "the", "number", "of", "decimals", "utilized", "when", "formatting", "scalar", "values" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/FuzzyLite.java#L126-L131
3,476
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/FuzzyLite.java
FuzzyLite.setLogging
public static void setLogging(boolean logging) { if (logging) { logger.setLevel(debugging ? Level.FINE : Level.INFO); } else { logger.setLevel(Level.OFF); } }
java
public static void setLogging(boolean logging) { if (logging) { logger.setLevel(debugging ? Level.FINE : Level.INFO); } else { logger.setLevel(Level.OFF); } }
[ "public", "static", "void", "setLogging", "(", "boolean", "logging", ")", "{", "if", "(", "logging", ")", "{", "logger", ".", "setLevel", "(", "debugging", "?", "Level", ".", "FINE", ":", "Level", ".", "INFO", ")", ";", "}", "else", "{", "logger", ".", "setLevel", "(", "Level", ".", "OFF", ")", ";", "}", "}" ]
Sets whether the library is set to log information @param logging indicates whether the library is set to log information
[ "Sets", "whether", "the", "library", "is", "set", "to", "log", "information" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/FuzzyLite.java#L160-L166
3,477
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/FuzzyLite.java
FuzzyLite.setDebugging
public static void setDebugging(boolean debugging) { FuzzyLite.debugging = debugging; if (isLogging()) { logger.setLevel(debugging ? Level.FINE : Level.INFO); } }
java
public static void setDebugging(boolean debugging) { FuzzyLite.debugging = debugging; if (isLogging()) { logger.setLevel(debugging ? Level.FINE : Level.INFO); } }
[ "public", "static", "void", "setDebugging", "(", "boolean", "debugging", ")", "{", "FuzzyLite", ".", "debugging", "=", "debugging", ";", "if", "(", "isLogging", "(", ")", ")", "{", "logger", ".", "setLevel", "(", "debugging", "?", "Level", ".", "FINE", ":", "Level", ".", "INFO", ")", ";", "}", "}" ]
Sets whether the library is set to run in debug mode @param debugging indicates whether the library is set to run in debug mode
[ "Sets", "whether", "the", "library", "is", "set", "to", "run", "in", "debug", "mode" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/FuzzyLite.java#L182-L187
3,478
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/imex/Importer.java
Importer.fromFile
public Engine fromFile(File file) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader( new FileInputStream(file), FuzzyLite.UTF_8)); String line; StringBuilder textEngine = new StringBuilder(); try { while ((line = reader.readLine()) != null) { textEngine.append(line).append("\n"); } } catch (IOException ex) { throw ex; } finally { reader.close(); } return fromString(textEngine.toString()); }
java
public Engine fromFile(File file) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader( new FileInputStream(file), FuzzyLite.UTF_8)); String line; StringBuilder textEngine = new StringBuilder(); try { while ((line = reader.readLine()) != null) { textEngine.append(line).append("\n"); } } catch (IOException ex) { throw ex; } finally { reader.close(); } return fromString(textEngine.toString()); }
[ "public", "Engine", "fromFile", "(", "File", "file", ")", "throws", "IOException", "{", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "new", "FileInputStream", "(", "file", ")", ",", "FuzzyLite", ".", "UTF_8", ")", ")", ";", "String", "line", ";", "StringBuilder", "textEngine", "=", "new", "StringBuilder", "(", ")", ";", "try", "{", "while", "(", "(", "line", "=", "reader", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "textEngine", ".", "append", "(", "line", ")", ".", "append", "(", "\"\\n\"", ")", ";", "}", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "ex", ";", "}", "finally", "{", "reader", ".", "close", "(", ")", ";", "}", "return", "fromString", "(", "textEngine", ".", "toString", "(", ")", ")", ";", "}" ]
Imports the engine from the given file @param file is the file containing the engine to import @return the engine represented by the file @throws IOException if any error occurs upon reading the file
[ "Imports", "the", "engine", "from", "the", "given", "file" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/imex/Importer.java#L56-L71
3,479
fuzzylite/jfuzzylite
jfuzzylite/src/main/java/com/fuzzylite/norm/t/HamacherProduct.java
HamacherProduct.compute
@Override public double compute(double a, double b) { if (Op.isEq(a + b, 0.0)) return 0.0; return (a * b) / (a + b - a * b); }
java
@Override public double compute(double a, double b) { if (Op.isEq(a + b, 0.0)) return 0.0; return (a * b) / (a + b - a * b); }
[ "@", "Override", "public", "double", "compute", "(", "double", "a", ",", "double", "b", ")", "{", "if", "(", "Op", ".", "isEq", "(", "a", "+", "b", ",", "0.0", ")", ")", "return", "0.0", ";", "return", "(", "a", "*", "b", ")", "/", "(", "a", "+", "b", "-", "a", "*", "b", ")", ";", "}" ]
Computes the Hamacher product of two membership function values @param a is a membership function value @param b is a membership function value @return `(a \times b) / (a+b- a \times b)`
[ "Computes", "the", "Hamacher", "product", "of", "two", "membership", "function", "values" ]
583ac1928f39512af75de80d560e67448039595a
https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/norm/t/HamacherProduct.java#L42-L46
3,480
FINRAOS/JTAF-ExtWebDriver
src/main/java/org/finra/jtaf/ewd/session/SessionManager.java
SessionManager.getCurrentSession
public ExtWebDriver getCurrentSession(boolean createIfNotFound) { for (int i = 0; i < MAX_RETRIES; i++) { ExtWebDriver sel = sessions.get(currentSessionId); try { if ((sel == null) && (createIfNotFound)) { sel = getNewSession(); } return sel; } catch (Exception e) { // if the exception is of type UnreachableBrowserException, try // again if (!(e instanceof UnreachableBrowserException)) { e.printStackTrace(); } } } return null; }
java
public ExtWebDriver getCurrentSession(boolean createIfNotFound) { for (int i = 0; i < MAX_RETRIES; i++) { ExtWebDriver sel = sessions.get(currentSessionId); try { if ((sel == null) && (createIfNotFound)) { sel = getNewSession(); } return sel; } catch (Exception e) { // if the exception is of type UnreachableBrowserException, try // again if (!(e instanceof UnreachableBrowserException)) { e.printStackTrace(); } } } return null; }
[ "public", "ExtWebDriver", "getCurrentSession", "(", "boolean", "createIfNotFound", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "MAX_RETRIES", ";", "i", "++", ")", "{", "ExtWebDriver", "sel", "=", "sessions", ".", "get", "(", "currentSessionId", ")", ";", "try", "{", "if", "(", "(", "sel", "==", "null", ")", "&&", "(", "createIfNotFound", ")", ")", "{", "sel", "=", "getNewSession", "(", ")", ";", "}", "return", "sel", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// if the exception is of type UnreachableBrowserException, try", "// again", "if", "(", "!", "(", "e", "instanceof", "UnreachableBrowserException", ")", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "return", "null", ";", "}" ]
Get the current session associated with this thread. Because a SessionManager instance is thread-local, the notion of current is also specific to a thread. @param createIfNotFound set to true if a session should be created if no session is associated with the current sessionId @return ExtWebDriver an ExtWebDriver instance @see getCurrentSession() @see getSession(String) @see switchToSession(String)
[ "Get", "the", "current", "session", "associated", "with", "this", "thread", ".", "Because", "a", "SessionManager", "instance", "is", "thread", "-", "local", "the", "notion", "of", "current", "is", "also", "specific", "to", "a", "thread", "." ]
78d646def1bf0904f79b19a81df0241e07f2c73a
https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/session/SessionManager.java#L111-L129
3,481
FINRAOS/JTAF-ExtWebDriver
src/main/java/org/finra/jtaf/ewd/session/SessionManager.java
SessionManager.getNewSession
public ExtWebDriver getNewSession(boolean setAsCurrent) throws Exception { Map<String, String> options = sessionFactory.get().createDefaultOptions(); return getNewSessionDo(options, setAsCurrent); }
java
public ExtWebDriver getNewSession(boolean setAsCurrent) throws Exception { Map<String, String> options = sessionFactory.get().createDefaultOptions(); return getNewSessionDo(options, setAsCurrent); }
[ "public", "ExtWebDriver", "getNewSession", "(", "boolean", "setAsCurrent", ")", "throws", "Exception", "{", "Map", "<", "String", ",", "String", ">", "options", "=", "sessionFactory", ".", "get", "(", ")", ".", "createDefaultOptions", "(", ")", ";", "return", "getNewSessionDo", "(", "options", ",", "setAsCurrent", ")", ";", "}" ]
Create and return new ExtWebDriver instance with default options. If setAsCurrent is true, set the new session as the current session for this SessionManager. @param setAsCurrent set to true if the new session should become the current session for this SessionManager @return A new ExtWebDriver session @throws Exception
[ "Create", "and", "return", "new", "ExtWebDriver", "instance", "with", "default", "options", ".", "If", "setAsCurrent", "is", "true", "set", "the", "new", "session", "as", "the", "current", "session", "for", "this", "SessionManager", "." ]
78d646def1bf0904f79b19a81df0241e07f2c73a
https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/session/SessionManager.java#L248-L251
3,482
FINRAOS/JTAF-ExtWebDriver
src/main/java/org/finra/jtaf/ewd/utils/ScreenshotUtils.java
ScreenshotUtils.similarity
private static double similarity(BufferedImage var, BufferedImage cont) { double[] varArr = new double[var.getWidth()*var.getHeight()*3]; double[] contArr = new double[cont.getWidth()*cont.getHeight()*3]; if (varArr.length!=contArr.length) throw new IllegalStateException("The pictures are different sizes!"); //unroll pixels for(int i = 0; i < var.getHeight(); i++) { for(int j = 0; j < var.getWidth(); j++) { varArr[i*var.getWidth() + j + 0] = new Color(var.getRGB(j, i)).getRed(); contArr[i*cont.getWidth() + j + 0] = new Color(cont.getRGB(j, i)).getRed(); varArr[i*var.getWidth() + j + 1] = new Color(var.getRGB(j, i)).getGreen(); contArr[i*cont.getWidth() + j + 1] = new Color(cont.getRGB(j, i)).getGreen(); varArr[i*var.getWidth() + j + 2] = new Color(var.getRGB(j, i)).getBlue(); contArr[i*cont.getWidth() + j + 2] = new Color(cont.getRGB(j, i)).getBlue(); } } double mins=0; double maxs=0; for(int i=0;i!=varArr.length;i++){ if (varArr[i]>contArr[i]){ mins+=contArr[i]; maxs+=varArr[i]; } else { mins+=varArr[i]; maxs+=contArr[i]; } } return mins/maxs; }
java
private static double similarity(BufferedImage var, BufferedImage cont) { double[] varArr = new double[var.getWidth()*var.getHeight()*3]; double[] contArr = new double[cont.getWidth()*cont.getHeight()*3]; if (varArr.length!=contArr.length) throw new IllegalStateException("The pictures are different sizes!"); //unroll pixels for(int i = 0; i < var.getHeight(); i++) { for(int j = 0; j < var.getWidth(); j++) { varArr[i*var.getWidth() + j + 0] = new Color(var.getRGB(j, i)).getRed(); contArr[i*cont.getWidth() + j + 0] = new Color(cont.getRGB(j, i)).getRed(); varArr[i*var.getWidth() + j + 1] = new Color(var.getRGB(j, i)).getGreen(); contArr[i*cont.getWidth() + j + 1] = new Color(cont.getRGB(j, i)).getGreen(); varArr[i*var.getWidth() + j + 2] = new Color(var.getRGB(j, i)).getBlue(); contArr[i*cont.getWidth() + j + 2] = new Color(cont.getRGB(j, i)).getBlue(); } } double mins=0; double maxs=0; for(int i=0;i!=varArr.length;i++){ if (varArr[i]>contArr[i]){ mins+=contArr[i]; maxs+=varArr[i]; } else { mins+=varArr[i]; maxs+=contArr[i]; } } return mins/maxs; }
[ "private", "static", "double", "similarity", "(", "BufferedImage", "var", ",", "BufferedImage", "cont", ")", "{", "double", "[", "]", "varArr", "=", "new", "double", "[", "var", ".", "getWidth", "(", ")", "*", "var", ".", "getHeight", "(", ")", "*", "3", "]", ";", "double", "[", "]", "contArr", "=", "new", "double", "[", "cont", ".", "getWidth", "(", ")", "*", "cont", ".", "getHeight", "(", ")", "*", "3", "]", ";", "if", "(", "varArr", ".", "length", "!=", "contArr", ".", "length", ")", "throw", "new", "IllegalStateException", "(", "\"The pictures are different sizes!\"", ")", ";", "//unroll pixels", "for", "(", "int", "i", "=", "0", ";", "i", "<", "var", ".", "getHeight", "(", ")", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "var", ".", "getWidth", "(", ")", ";", "j", "++", ")", "{", "varArr", "[", "i", "*", "var", ".", "getWidth", "(", ")", "+", "j", "+", "0", "]", "=", "new", "Color", "(", "var", ".", "getRGB", "(", "j", ",", "i", ")", ")", ".", "getRed", "(", ")", ";", "contArr", "[", "i", "*", "cont", ".", "getWidth", "(", ")", "+", "j", "+", "0", "]", "=", "new", "Color", "(", "cont", ".", "getRGB", "(", "j", ",", "i", ")", ")", ".", "getRed", "(", ")", ";", "varArr", "[", "i", "*", "var", ".", "getWidth", "(", ")", "+", "j", "+", "1", "]", "=", "new", "Color", "(", "var", ".", "getRGB", "(", "j", ",", "i", ")", ")", ".", "getGreen", "(", ")", ";", "contArr", "[", "i", "*", "cont", ".", "getWidth", "(", ")", "+", "j", "+", "1", "]", "=", "new", "Color", "(", "cont", ".", "getRGB", "(", "j", ",", "i", ")", ")", ".", "getGreen", "(", ")", ";", "varArr", "[", "i", "*", "var", ".", "getWidth", "(", ")", "+", "j", "+", "2", "]", "=", "new", "Color", "(", "var", ".", "getRGB", "(", "j", ",", "i", ")", ")", ".", "getBlue", "(", ")", ";", "contArr", "[", "i", "*", "cont", ".", "getWidth", "(", ")", "+", "j", "+", "2", "]", "=", "new", "Color", "(", "cont", ".", "getRGB", "(", "j", ",", "i", ")", ")", ".", "getBlue", "(", ")", ";", "}", "}", "double", "mins", "=", "0", ";", "double", "maxs", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "!=", "varArr", ".", "length", ";", "i", "++", ")", "{", "if", "(", "varArr", "[", "i", "]", ">", "contArr", "[", "i", "]", ")", "{", "mins", "+=", "contArr", "[", "i", "]", ";", "maxs", "+=", "varArr", "[", "i", "]", ";", "}", "else", "{", "mins", "+=", "varArr", "[", "i", "]", ";", "maxs", "+=", "contArr", "[", "i", "]", ";", "}", "}", "return", "mins", "/", "maxs", ";", "}" ]
Returns a double between 0 and 1.0
[ "Returns", "a", "double", "between", "0", "and", "1", ".", "0" ]
78d646def1bf0904f79b19a81df0241e07f2c73a
https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/utils/ScreenshotUtils.java#L203-L235
3,483
FINRAOS/JTAF-ExtWebDriver
src/main/java/org/finra/jtaf/ewd/widget/element/html/Table.java
Table.generateXPathLocator
private String generateXPathLocator() throws WidgetException { if(xPathLocator == null) { IElement elem = new Element(getByLocator()); String key = "tablewidgetattribute"; long value = System.currentTimeMillis(); elem.eval("arguments[0].setAttribute('" + key + "', '" + value + "')"); xPathLocator = "//*[@" + key + "='" + value + "']"; } return xPathLocator; }
java
private String generateXPathLocator() throws WidgetException { if(xPathLocator == null) { IElement elem = new Element(getByLocator()); String key = "tablewidgetattribute"; long value = System.currentTimeMillis(); elem.eval("arguments[0].setAttribute('" + key + "', '" + value + "')"); xPathLocator = "//*[@" + key + "='" + value + "']"; } return xPathLocator; }
[ "private", "String", "generateXPathLocator", "(", ")", "throws", "WidgetException", "{", "if", "(", "xPathLocator", "==", "null", ")", "{", "IElement", "elem", "=", "new", "Element", "(", "getByLocator", "(", ")", ")", ";", "String", "key", "=", "\"tablewidgetattribute\"", ";", "long", "value", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "elem", ".", "eval", "(", "\"arguments[0].setAttribute('\"", "+", "key", "+", "\"', '\"", "+", "value", "+", "\"')\"", ")", ";", "xPathLocator", "=", "\"//*[@\"", "+", "key", "+", "\"='\"", "+", "value", "+", "\"']\"", ";", "}", "return", "xPathLocator", ";", "}" ]
unique attribute value
[ "unique", "attribute", "value" ]
78d646def1bf0904f79b19a81df0241e07f2c73a
https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/widget/element/html/Table.java#L87-L97
3,484
FINRAOS/JTAF-ExtWebDriver
src/main/java/org/finra/jtaf/ewd/widget/element/Element.java
Element.isElementPresent_internal
private boolean isElementPresent_internal() throws WidgetException { try { try { final boolean isPotentiallyXpathWithLocator = (locator instanceof EByFirstMatching) || (locator instanceof EByXpath); if (isPotentiallyXpathWithLocator && isElementPresentJavaXPath()) return true; } catch (Exception e) { // Continue } findElement(); return true; } catch (NoSuchElementException e) { return false; } }
java
private boolean isElementPresent_internal() throws WidgetException { try { try { final boolean isPotentiallyXpathWithLocator = (locator instanceof EByFirstMatching) || (locator instanceof EByXpath); if (isPotentiallyXpathWithLocator && isElementPresentJavaXPath()) return true; } catch (Exception e) { // Continue } findElement(); return true; } catch (NoSuchElementException e) { return false; } }
[ "private", "boolean", "isElementPresent_internal", "(", ")", "throws", "WidgetException", "{", "try", "{", "try", "{", "final", "boolean", "isPotentiallyXpathWithLocator", "=", "(", "locator", "instanceof", "EByFirstMatching", ")", "||", "(", "locator", "instanceof", "EByXpath", ")", ";", "if", "(", "isPotentiallyXpathWithLocator", "&&", "isElementPresentJavaXPath", "(", ")", ")", "return", "true", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// Continue", "}", "findElement", "(", ")", ";", "return", "true", ";", "}", "catch", "(", "NoSuchElementException", "e", ")", "{", "return", "false", ";", "}", "}" ]
Use the JavaXPath to determine if element is present. If not, then try finding element. Return false if the element does not exist @return true or false @throws WidgetException
[ "Use", "the", "JavaXPath", "to", "determine", "if", "element", "is", "present", ".", "If", "not", "then", "try", "finding", "element", ".", "Return", "false", "if", "the", "element", "does", "not", "exist" ]
78d646def1bf0904f79b19a81df0241e07f2c73a
https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/widget/element/Element.java#L131-L147
3,485
FINRAOS/JTAF-ExtWebDriver
src/main/java/org/finra/jtaf/ewd/widget/element/Element.java
Element.waitForNotVisible
public void waitForNotVisible(final long time) throws WidgetException { try { waitForCommand(new ITimerCallback() { @Override public boolean execute() throws WidgetException { return !isVisible(); } @Override public String toString() { return "Waiting for element with locator: " + locator + " to not be visible"; } }, time); } catch (Exception e) { throw new WidgetException("Error while waiting for element to be not visible", locator, e); } }
java
public void waitForNotVisible(final long time) throws WidgetException { try { waitForCommand(new ITimerCallback() { @Override public boolean execute() throws WidgetException { return !isVisible(); } @Override public String toString() { return "Waiting for element with locator: " + locator + " to not be visible"; } }, time); } catch (Exception e) { throw new WidgetException("Error while waiting for element to be not visible", locator, e); } }
[ "public", "void", "waitForNotVisible", "(", "final", "long", "time", ")", "throws", "WidgetException", "{", "try", "{", "waitForCommand", "(", "new", "ITimerCallback", "(", ")", "{", "@", "Override", "public", "boolean", "execute", "(", ")", "throws", "WidgetException", "{", "return", "!", "isVisible", "(", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"Waiting for element with locator: \"", "+", "locator", "+", "\" to not be visible\"", ";", "}", "}", ",", "time", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "WidgetException", "(", "\"Error while waiting for element to be not visible\"", ",", "locator", ",", "e", ")", ";", "}", "}" ]
Waits for specific element at locator to be not visible within period of specified time @param time Milliseconds @throws WidgetException
[ "Waits", "for", "specific", "element", "at", "locator", "to", "be", "not", "visible", "within", "period", "of", "specified", "time" ]
78d646def1bf0904f79b19a81df0241e07f2c73a
https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/widget/element/Element.java#L417-L434
3,486
FINRAOS/JTAF-ExtWebDriver
src/main/java/org/finra/jtaf/ewd/widget/element/Element.java
Element.eval
@Override public void eval(String javascript) throws WidgetException { WebElement element = findElement(false); WebDriver wd = getGUIDriver().getWrappedDriver(); try { ((JavascriptExecutor) wd).executeScript(javascript, element); } catch (Exception e) { long time = System.currentTimeMillis() + 2000; boolean success = false; while (!success && System.currentTimeMillis() < time) { try { ((JavascriptExecutor) wd).executeScript(javascript, element); success = true; } catch (Exception e2) { try { Thread.sleep(500); } catch (InterruptedException e1) { // Ignore } e = e2; } } if (!success) { throw new RuntimeException(e); } } }
java
@Override public void eval(String javascript) throws WidgetException { WebElement element = findElement(false); WebDriver wd = getGUIDriver().getWrappedDriver(); try { ((JavascriptExecutor) wd).executeScript(javascript, element); } catch (Exception e) { long time = System.currentTimeMillis() + 2000; boolean success = false; while (!success && System.currentTimeMillis() < time) { try { ((JavascriptExecutor) wd).executeScript(javascript, element); success = true; } catch (Exception e2) { try { Thread.sleep(500); } catch (InterruptedException e1) { // Ignore } e = e2; } } if (!success) { throw new RuntimeException(e); } } }
[ "@", "Override", "public", "void", "eval", "(", "String", "javascript", ")", "throws", "WidgetException", "{", "WebElement", "element", "=", "findElement", "(", "false", ")", ";", "WebDriver", "wd", "=", "getGUIDriver", "(", ")", ".", "getWrappedDriver", "(", ")", ";", "try", "{", "(", "(", "JavascriptExecutor", ")", "wd", ")", ".", "executeScript", "(", "javascript", ",", "element", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "long", "time", "=", "System", ".", "currentTimeMillis", "(", ")", "+", "2000", ";", "boolean", "success", "=", "false", ";", "while", "(", "!", "success", "&&", "System", ".", "currentTimeMillis", "(", ")", "<", "time", ")", "{", "try", "{", "(", "(", "JavascriptExecutor", ")", "wd", ")", ".", "executeScript", "(", "javascript", ",", "element", ")", ";", "success", "=", "true", ";", "}", "catch", "(", "Exception", "e2", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "500", ")", ";", "}", "catch", "(", "InterruptedException", "e1", ")", "{", "// Ignore", "}", "e", "=", "e2", ";", "}", "}", "if", "(", "!", "success", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "}" ]
Executes JavaScript code on the current element in the current frame or window. @param javascript the javascript code to be executed
[ "Executes", "JavaScript", "code", "on", "the", "current", "element", "in", "the", "current", "frame", "or", "window", "." ]
78d646def1bf0904f79b19a81df0241e07f2c73a
https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/widget/element/Element.java#L751-L778
3,487
FINRAOS/JTAF-ExtWebDriver
src/main/java/org/finra/jtaf/ewd/widget/element/Element.java
Element.waitForCommand
protected void waitForCommand(ITimerCallback callback, long timeout) throws WidgetTimeoutException { WaitForConditionTimer t = new WaitForConditionTimer(getByLocator(), callback); t.waitUntil(timeout); }
java
protected void waitForCommand(ITimerCallback callback, long timeout) throws WidgetTimeoutException { WaitForConditionTimer t = new WaitForConditionTimer(getByLocator(), callback); t.waitUntil(timeout); }
[ "protected", "void", "waitForCommand", "(", "ITimerCallback", "callback", ",", "long", "timeout", ")", "throws", "WidgetTimeoutException", "{", "WaitForConditionTimer", "t", "=", "new", "WaitForConditionTimer", "(", "getByLocator", "(", ")", ",", "callback", ")", ";", "t", ".", "waitUntil", "(", "timeout", ")", ";", "}" ]
wait for timeout amount of time @param callback @param timeout @throws WidgetTimeoutException
[ "wait", "for", "timeout", "amount", "of", "time" ]
78d646def1bf0904f79b19a81df0241e07f2c73a
https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/widget/element/Element.java#L797-L800
3,488
FINRAOS/JTAF-ExtWebDriver
src/main/java/org/finra/jtaf/ewd/widget/element/Element.java
Element.isElementPresentJavaXPath
private boolean isElementPresentJavaXPath() throws Exception { String xpath = ((StringLocatorAwareBy)getByLocator()).getLocator(); try { xpath = formatXPathForJavaXPath(xpath); NodeList nodes = getNodeListUsingJavaXPath(xpath); if (nodes.getLength() > 0) { return true; } else { return false; } } catch (Exception e) { throw new Exception("Error performing isElement present using Java XPath: " + xpath, e); } }
java
private boolean isElementPresentJavaXPath() throws Exception { String xpath = ((StringLocatorAwareBy)getByLocator()).getLocator(); try { xpath = formatXPathForJavaXPath(xpath); NodeList nodes = getNodeListUsingJavaXPath(xpath); if (nodes.getLength() > 0) { return true; } else { return false; } } catch (Exception e) { throw new Exception("Error performing isElement present using Java XPath: " + xpath, e); } }
[ "private", "boolean", "isElementPresentJavaXPath", "(", ")", "throws", "Exception", "{", "String", "xpath", "=", "(", "(", "StringLocatorAwareBy", ")", "getByLocator", "(", ")", ")", ".", "getLocator", "(", ")", ";", "try", "{", "xpath", "=", "formatXPathForJavaXPath", "(", "xpath", ")", ";", "NodeList", "nodes", "=", "getNodeListUsingJavaXPath", "(", "xpath", ")", ";", "if", "(", "nodes", ".", "getLength", "(", ")", ">", "0", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "Exception", "(", "\"Error performing isElement present using Java XPath: \"", "+", "xpath", ",", "e", ")", ";", "}", "}" ]
Use the Java Xpath API to determine if the element is present or not @return boolean true or false as the case is @throws Exception
[ "Use", "the", "Java", "Xpath", "API", "to", "determine", "if", "the", "element", "is", "present", "or", "not" ]
78d646def1bf0904f79b19a81df0241e07f2c73a
https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/widget/element/Element.java#L808-L821
3,489
FINRAOS/JTAF-ExtWebDriver
src/main/java/org/finra/jtaf/ewd/widget/element/Element.java
Element.formatXPathForJavaXPath
private static String formatXPathForJavaXPath(String xpath) throws Exception { String newXPath = ""; if (xpath.startsWith("xpath=")) { xpath = xpath.replace("xpath=", ""); } boolean convertIndicator = true; boolean onSlash = false; boolean onSingleQuote = false; boolean onDoubleQuote = false; for (int i = 0; i < xpath.length(); i++) { char c = xpath.charAt(i); if (c == '/') { if (!onSingleQuote && !onDoubleQuote) { if (convertIndicator) { if (!onSlash) { onSlash = true; } else { onSlash = false; } } else { convertIndicator = true; onSlash = true; } } } else if (c == '[') { if (!onSingleQuote && !onDoubleQuote) convertIndicator = false; } else if (c == ']') { if (!onSingleQuote && !onDoubleQuote) convertIndicator = true; } else if (c == '\'') { if (!onSingleQuote) onSingleQuote = true; else onSingleQuote = false; } else if (c == '\"') { if (!onDoubleQuote) onDoubleQuote = true; else onDoubleQuote = false; } if (convertIndicator) newXPath = newXPath + String.valueOf(c).toLowerCase(); else newXPath = newXPath + String.valueOf(c); } return newXPath; }
java
private static String formatXPathForJavaXPath(String xpath) throws Exception { String newXPath = ""; if (xpath.startsWith("xpath=")) { xpath = xpath.replace("xpath=", ""); } boolean convertIndicator = true; boolean onSlash = false; boolean onSingleQuote = false; boolean onDoubleQuote = false; for (int i = 0; i < xpath.length(); i++) { char c = xpath.charAt(i); if (c == '/') { if (!onSingleQuote && !onDoubleQuote) { if (convertIndicator) { if (!onSlash) { onSlash = true; } else { onSlash = false; } } else { convertIndicator = true; onSlash = true; } } } else if (c == '[') { if (!onSingleQuote && !onDoubleQuote) convertIndicator = false; } else if (c == ']') { if (!onSingleQuote && !onDoubleQuote) convertIndicator = true; } else if (c == '\'') { if (!onSingleQuote) onSingleQuote = true; else onSingleQuote = false; } else if (c == '\"') { if (!onDoubleQuote) onDoubleQuote = true; else onDoubleQuote = false; } if (convertIndicator) newXPath = newXPath + String.valueOf(c).toLowerCase(); else newXPath = newXPath + String.valueOf(c); } return newXPath; }
[ "private", "static", "String", "formatXPathForJavaXPath", "(", "String", "xpath", ")", "throws", "Exception", "{", "String", "newXPath", "=", "\"\"", ";", "if", "(", "xpath", ".", "startsWith", "(", "\"xpath=\"", ")", ")", "{", "xpath", "=", "xpath", ".", "replace", "(", "\"xpath=\"", ",", "\"\"", ")", ";", "}", "boolean", "convertIndicator", "=", "true", ";", "boolean", "onSlash", "=", "false", ";", "boolean", "onSingleQuote", "=", "false", ";", "boolean", "onDoubleQuote", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "xpath", ".", "length", "(", ")", ";", "i", "++", ")", "{", "char", "c", "=", "xpath", ".", "charAt", "(", "i", ")", ";", "if", "(", "c", "==", "'", "'", ")", "{", "if", "(", "!", "onSingleQuote", "&&", "!", "onDoubleQuote", ")", "{", "if", "(", "convertIndicator", ")", "{", "if", "(", "!", "onSlash", ")", "{", "onSlash", "=", "true", ";", "}", "else", "{", "onSlash", "=", "false", ";", "}", "}", "else", "{", "convertIndicator", "=", "true", ";", "onSlash", "=", "true", ";", "}", "}", "}", "else", "if", "(", "c", "==", "'", "'", ")", "{", "if", "(", "!", "onSingleQuote", "&&", "!", "onDoubleQuote", ")", "convertIndicator", "=", "false", ";", "}", "else", "if", "(", "c", "==", "'", "'", ")", "{", "if", "(", "!", "onSingleQuote", "&&", "!", "onDoubleQuote", ")", "convertIndicator", "=", "true", ";", "}", "else", "if", "(", "c", "==", "'", "'", ")", "{", "if", "(", "!", "onSingleQuote", ")", "onSingleQuote", "=", "true", ";", "else", "onSingleQuote", "=", "false", ";", "}", "else", "if", "(", "c", "==", "'", "'", ")", "{", "if", "(", "!", "onDoubleQuote", ")", "onDoubleQuote", "=", "true", ";", "else", "onDoubleQuote", "=", "false", ";", "}", "if", "(", "convertIndicator", ")", "newXPath", "=", "newXPath", "+", "String", ".", "valueOf", "(", "c", ")", ".", "toLowerCase", "(", ")", ";", "else", "newXPath", "=", "newXPath", "+", "String", ".", "valueOf", "(", "c", ")", ";", "}", "return", "newXPath", ";", "}" ]
Format the xpath to work with Java XPath API @param xpath the xpath to be formatted @return String the formatted xpath @throws Exception
[ "Format", "the", "xpath", "to", "work", "with", "Java", "XPath", "API" ]
78d646def1bf0904f79b19a81df0241e07f2c73a
https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/widget/element/Element.java#L831-L882
3,490
FINRAOS/JTAF-ExtWebDriver
src/main/java/org/finra/jtaf/ewd/widget/element/Element.java
Element.getNodeListUsingJavaXPath
private NodeList getNodeListUsingJavaXPath(String xpath) throws Exception { XPathFactory xpathFac = XPathFactory.newInstance(); XPath theXpath = xpathFac.newXPath(); String html = getGUIDriver().getHtmlSource(); html = html.replaceAll(">\\s+<", "><"); InputStream input = new ByteArrayInputStream(html.getBytes(Charset.forName("UTF-8"))); XMLReader reader = new Parser(); reader.setFeature(Parser.namespacesFeature, false); Transformer transformer = TransformerFactory.newInstance().newTransformer(); DOMResult result = new DOMResult(); transformer.transform(new SAXSource(reader, new InputSource(input)), result); Node htmlNode = result.getNode(); // This code gets a Node from the // result. NodeList nodes = (NodeList) theXpath.evaluate(xpath, htmlNode, XPathConstants.NODESET); return nodes; }
java
private NodeList getNodeListUsingJavaXPath(String xpath) throws Exception { XPathFactory xpathFac = XPathFactory.newInstance(); XPath theXpath = xpathFac.newXPath(); String html = getGUIDriver().getHtmlSource(); html = html.replaceAll(">\\s+<", "><"); InputStream input = new ByteArrayInputStream(html.getBytes(Charset.forName("UTF-8"))); XMLReader reader = new Parser(); reader.setFeature(Parser.namespacesFeature, false); Transformer transformer = TransformerFactory.newInstance().newTransformer(); DOMResult result = new DOMResult(); transformer.transform(new SAXSource(reader, new InputSource(input)), result); Node htmlNode = result.getNode(); // This code gets a Node from the // result. NodeList nodes = (NodeList) theXpath.evaluate(xpath, htmlNode, XPathConstants.NODESET); return nodes; }
[ "private", "NodeList", "getNodeListUsingJavaXPath", "(", "String", "xpath", ")", "throws", "Exception", "{", "XPathFactory", "xpathFac", "=", "XPathFactory", ".", "newInstance", "(", ")", ";", "XPath", "theXpath", "=", "xpathFac", ".", "newXPath", "(", ")", ";", "String", "html", "=", "getGUIDriver", "(", ")", ".", "getHtmlSource", "(", ")", ";", "html", "=", "html", ".", "replaceAll", "(", "\">\\\\s+<\"", ",", "\"><\"", ")", ";", "InputStream", "input", "=", "new", "ByteArrayInputStream", "(", "html", ".", "getBytes", "(", "Charset", ".", "forName", "(", "\"UTF-8\"", ")", ")", ")", ";", "XMLReader", "reader", "=", "new", "Parser", "(", ")", ";", "reader", ".", "setFeature", "(", "Parser", ".", "namespacesFeature", ",", "false", ")", ";", "Transformer", "transformer", "=", "TransformerFactory", ".", "newInstance", "(", ")", ".", "newTransformer", "(", ")", ";", "DOMResult", "result", "=", "new", "DOMResult", "(", ")", ";", "transformer", ".", "transform", "(", "new", "SAXSource", "(", "reader", ",", "new", "InputSource", "(", "input", ")", ")", ",", "result", ")", ";", "Node", "htmlNode", "=", "result", ".", "getNode", "(", ")", ";", "// This code gets a Node from the", "// result.", "NodeList", "nodes", "=", "(", "NodeList", ")", "theXpath", ".", "evaluate", "(", "xpath", ",", "htmlNode", ",", "XPathConstants", ".", "NODESET", ")", ";", "return", "nodes", ";", "}" ]
Get the list of nodes which satisfy the xpath expression passed in @param xpath the input xpath expression @return the nodeset of matching elements @throws Exception
[ "Get", "the", "list", "of", "nodes", "which", "satisfy", "the", "xpath", "expression", "passed", "in" ]
78d646def1bf0904f79b19a81df0241e07f2c73a
https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/widget/element/Element.java#L892-L912
3,491
FINRAOS/JTAF-ExtWebDriver
src/main/java/org/finra/jtaf/ewd/widget/element/Element.java
Element.waitForAttributePatternMatcher
private void waitForAttributePatternMatcher(String attributeName, String pattern, long timeout, boolean waitCondition) throws WidgetException { long start = System.currentTimeMillis(); long end = start + timeout; while (System.currentTimeMillis() < end) { String attribute = getAttribute(attributeName); if (attribute != null && attribute.matches(pattern) == waitCondition) return; try { Thread.sleep(DEFAULT_INTERVAL); } catch (InterruptedException e) { throw new RuntimeException(e); } } throw new TimeOutException("waitForAttribute " + " : timeout : Locator : " + locator + " Attribute : " + attributeName); }
java
private void waitForAttributePatternMatcher(String attributeName, String pattern, long timeout, boolean waitCondition) throws WidgetException { long start = System.currentTimeMillis(); long end = start + timeout; while (System.currentTimeMillis() < end) { String attribute = getAttribute(attributeName); if (attribute != null && attribute.matches(pattern) == waitCondition) return; try { Thread.sleep(DEFAULT_INTERVAL); } catch (InterruptedException e) { throw new RuntimeException(e); } } throw new TimeOutException("waitForAttribute " + " : timeout : Locator : " + locator + " Attribute : " + attributeName); }
[ "private", "void", "waitForAttributePatternMatcher", "(", "String", "attributeName", ",", "String", "pattern", ",", "long", "timeout", ",", "boolean", "waitCondition", ")", "throws", "WidgetException", "{", "long", "start", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "long", "end", "=", "start", "+", "timeout", ";", "while", "(", "System", ".", "currentTimeMillis", "(", ")", "<", "end", ")", "{", "String", "attribute", "=", "getAttribute", "(", "attributeName", ")", ";", "if", "(", "attribute", "!=", "null", "&&", "attribute", ".", "matches", "(", "pattern", ")", "==", "waitCondition", ")", "return", ";", "try", "{", "Thread", ".", "sleep", "(", "DEFAULT_INTERVAL", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "throw", "new", "TimeOutException", "(", "\"waitForAttribute \"", "+", "\" : timeout : Locator : \"", "+", "locator", "+", "\" Attribute : \"", "+", "attributeName", ")", ";", "}" ]
Matches an attribute value to a pattern that is passed. @param attributeName the attribute whose value os to be compared @param pattern the pattern to which to match @param timeout time in milliseconds after which request timeout occurs @param waitCondition true to match the attribute value and false to not match the value @throws WidgetException
[ "Matches", "an", "attribute", "value", "to", "a", "pattern", "that", "is", "passed", "." ]
78d646def1bf0904f79b19a81df0241e07f2c73a
https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/widget/element/Element.java#L980-L994
3,492
FINRAOS/JTAF-ExtWebDriver
src/main/java/org/finra/jtaf/ewd/widget/element/Element.java
Element.fireEvent
@Override public void fireEvent(String event) throws WidgetException { try { String javaScript = null; if (event.startsWith("mouse")) { javaScript = "if(document.createEvent){var evObj = document.createEvent('MouseEvents');evObj.initEvent('" + event + "', true, false); arguments[0].dispatchEvent(evObj);} else if(document.createEventObject) { arguments[0].fireEvent('on" + event + "');}"; } else { javaScript = "if(document.createEvent){var evObj = document.createEvent('HTMLEvents');evObj.initEvent('" + event + "', true, false); arguments[0].dispatchEvent(evObj);} else if(document.createEventObject) { arguments[0].fireEvent('on" + event + "');}"; } eval(javaScript); } catch (Exception e) { throw new WidgetException("Error while trying to fire event", getByLocator(), e); } }
java
@Override public void fireEvent(String event) throws WidgetException { try { String javaScript = null; if (event.startsWith("mouse")) { javaScript = "if(document.createEvent){var evObj = document.createEvent('MouseEvents');evObj.initEvent('" + event + "', true, false); arguments[0].dispatchEvent(evObj);} else if(document.createEventObject) { arguments[0].fireEvent('on" + event + "');}"; } else { javaScript = "if(document.createEvent){var evObj = document.createEvent('HTMLEvents');evObj.initEvent('" + event + "', true, false); arguments[0].dispatchEvent(evObj);} else if(document.createEventObject) { arguments[0].fireEvent('on" + event + "');}"; } eval(javaScript); } catch (Exception e) { throw new WidgetException("Error while trying to fire event", getByLocator(), e); } }
[ "@", "Override", "public", "void", "fireEvent", "(", "String", "event", ")", "throws", "WidgetException", "{", "try", "{", "String", "javaScript", "=", "null", ";", "if", "(", "event", ".", "startsWith", "(", "\"mouse\"", ")", ")", "{", "javaScript", "=", "\"if(document.createEvent){var evObj = document.createEvent('MouseEvents');evObj.initEvent('\"", "+", "event", "+", "\"', true, false); arguments[0].dispatchEvent(evObj);} else if(document.createEventObject) { arguments[0].fireEvent('on\"", "+", "event", "+", "\"');}\"", ";", "}", "else", "{", "javaScript", "=", "\"if(document.createEvent){var evObj = document.createEvent('HTMLEvents');evObj.initEvent('\"", "+", "event", "+", "\"', true, false); arguments[0].dispatchEvent(evObj);} else if(document.createEventObject) { arguments[0].fireEvent('on\"", "+", "event", "+", "\"');}\"", ";", "}", "eval", "(", "javaScript", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "WidgetException", "(", "\"Error while trying to fire event\"", ",", "getByLocator", "(", ")", ",", "e", ")", ";", "}", "}" ]
Fires a javascript event on a web element @param event the javascript code for the event
[ "Fires", "a", "javascript", "event", "on", "a", "web", "element" ]
78d646def1bf0904f79b19a81df0241e07f2c73a
https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/widget/element/Element.java#L1143-L1158
3,493
FINRAOS/JTAF-ExtWebDriver
src/main/java/org/finra/jtaf/ewd/widget/element/Element.java
Element.getChildNodesValuesText
@Override public String[] getChildNodesValuesText() throws WidgetException { WebElement we = new Element(getByLocator()).getWebElement(); List<WebElement> childNodes = we.findElements(By.xpath("./*")); String[] childText = new String[childNodes.size()]; int i = 0; for (WebElement element : childNodes) { childText[i] = element.getText(); i++; } return childText; }
java
@Override public String[] getChildNodesValuesText() throws WidgetException { WebElement we = new Element(getByLocator()).getWebElement(); List<WebElement> childNodes = we.findElements(By.xpath("./*")); String[] childText = new String[childNodes.size()]; int i = 0; for (WebElement element : childNodes) { childText[i] = element.getText(); i++; } return childText; }
[ "@", "Override", "public", "String", "[", "]", "getChildNodesValuesText", "(", ")", "throws", "WidgetException", "{", "WebElement", "we", "=", "new", "Element", "(", "getByLocator", "(", ")", ")", ".", "getWebElement", "(", ")", ";", "List", "<", "WebElement", ">", "childNodes", "=", "we", ".", "findElements", "(", "By", ".", "xpath", "(", "\"./*\"", ")", ")", ";", "String", "[", "]", "childText", "=", "new", "String", "[", "childNodes", ".", "size", "(", ")", "]", ";", "int", "i", "=", "0", ";", "for", "(", "WebElement", "element", ":", "childNodes", ")", "{", "childText", "[", "i", "]", "=", "element", ".", "getText", "(", ")", ";", "i", "++", ";", "}", "return", "childText", ";", "}" ]
Returns the text contained in the child nodes of the current element @return Array of texts in children nodes
[ "Returns", "the", "text", "contained", "in", "the", "child", "nodes", "of", "the", "current", "element" ]
78d646def1bf0904f79b19a81df0241e07f2c73a
https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/widget/element/Element.java#L1165-L1176
3,494
FINRAOS/JTAF-ExtWebDriver
src/main/java/org/finra/jtaf/ewd/widget/element/Element.java
Element.highlight
public void highlight(HIGHLIGHT_MODES mode) throws WidgetException { if (mode.equals(HIGHLIGHT_MODES.NONE)) return; else highlight(mode.toString()); }
java
public void highlight(HIGHLIGHT_MODES mode) throws WidgetException { if (mode.equals(HIGHLIGHT_MODES.NONE)) return; else highlight(mode.toString()); }
[ "public", "void", "highlight", "(", "HIGHLIGHT_MODES", "mode", ")", "throws", "WidgetException", "{", "if", "(", "mode", ".", "equals", "(", "HIGHLIGHT_MODES", ".", "NONE", ")", ")", "return", ";", "else", "highlight", "(", "mode", ".", "toString", "(", ")", ")", ";", "}" ]
Find the current element and highlight it according to the mode If mode is NONE, do nothing @param mode @throws WidgetException
[ "Find", "the", "current", "element", "and", "highlight", "it", "according", "to", "the", "mode", "If", "mode", "is", "NONE", "do", "nothing" ]
78d646def1bf0904f79b19a81df0241e07f2c73a
https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/widget/element/Element.java#L1209-L1215
3,495
FINRAOS/JTAF-ExtWebDriver
src/main/java/org/finra/jtaf/ewd/widget/element/Element.java
Element.doHighlight
private void doHighlight(String colorMode) throws WidgetException { if (!(getGUIDriver() instanceof HighlightProvider)) { return; } HighlightProvider highDriver = (HighlightProvider) getGUIDriver(); if (highDriver.isHighlight()) { setBackgroundColor(highDriver.getHighlightColor(colorMode)); } }
java
private void doHighlight(String colorMode) throws WidgetException { if (!(getGUIDriver() instanceof HighlightProvider)) { return; } HighlightProvider highDriver = (HighlightProvider) getGUIDriver(); if (highDriver.isHighlight()) { setBackgroundColor(highDriver.getHighlightColor(colorMode)); } }
[ "private", "void", "doHighlight", "(", "String", "colorMode", ")", "throws", "WidgetException", "{", "if", "(", "!", "(", "getGUIDriver", "(", ")", "instanceof", "HighlightProvider", ")", ")", "{", "return", ";", "}", "HighlightProvider", "highDriver", "=", "(", "HighlightProvider", ")", "getGUIDriver", "(", ")", ";", "if", "(", "highDriver", ".", "isHighlight", "(", ")", ")", "{", "setBackgroundColor", "(", "highDriver", ".", "getHighlightColor", "(", "colorMode", ")", ")", ";", "}", "}" ]
Highlight a web element by getting its color from the map loaded from client properties file @param colorMode the mode which decides the color of highlight @throws WidgetException
[ "Highlight", "a", "web", "element", "by", "getting", "its", "color", "from", "the", "map", "loaded", "from", "client", "properties", "file" ]
78d646def1bf0904f79b19a81df0241e07f2c73a
https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/widget/element/Element.java#L1225-L1234
3,496
FINRAOS/JTAF-ExtWebDriver
src/main/java/org/finra/jtaf/ewd/widget/element/html/CheckBox.java
CheckBox.setValue
@Override public void setValue(Object value) throws WidgetException { boolean set = false; try { if (value instanceof String) { if (((String) value).equalsIgnoreCase(UNCHECK)) { doAction(true); } else if (((String) value).equalsIgnoreCase(CHECK)) { doAction(false); } set = true; } else { throw new WidgetRuntimeException( "value must be a String of either 'check' or 'uncheck'", getByLocator()); } } catch (Exception e) { throw new WidgetException("Error while checking/unchecking", getByLocator(), e); } if (!set) throw new WidgetException( "Invalid set value for checkbox. It must be either 'check' or 'uncheck'", getByLocator()); }
java
@Override public void setValue(Object value) throws WidgetException { boolean set = false; try { if (value instanceof String) { if (((String) value).equalsIgnoreCase(UNCHECK)) { doAction(true); } else if (((String) value).equalsIgnoreCase(CHECK)) { doAction(false); } set = true; } else { throw new WidgetRuntimeException( "value must be a String of either 'check' or 'uncheck'", getByLocator()); } } catch (Exception e) { throw new WidgetException("Error while checking/unchecking", getByLocator(), e); } if (!set) throw new WidgetException( "Invalid set value for checkbox. It must be either 'check' or 'uncheck'", getByLocator()); }
[ "@", "Override", "public", "void", "setValue", "(", "Object", "value", ")", "throws", "WidgetException", "{", "boolean", "set", "=", "false", ";", "try", "{", "if", "(", "value", "instanceof", "String", ")", "{", "if", "(", "(", "(", "String", ")", "value", ")", ".", "equalsIgnoreCase", "(", "UNCHECK", ")", ")", "{", "doAction", "(", "true", ")", ";", "}", "else", "if", "(", "(", "(", "String", ")", "value", ")", ".", "equalsIgnoreCase", "(", "CHECK", ")", ")", "{", "doAction", "(", "false", ")", ";", "}", "set", "=", "true", ";", "}", "else", "{", "throw", "new", "WidgetRuntimeException", "(", "\"value must be a String of either 'check' or 'uncheck'\"", ",", "getByLocator", "(", ")", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "WidgetException", "(", "\"Error while checking/unchecking\"", ",", "getByLocator", "(", ")", ",", "e", ")", ";", "}", "if", "(", "!", "set", ")", "throw", "new", "WidgetException", "(", "\"Invalid set value for checkbox. It must be either 'check' or 'uncheck'\"", ",", "getByLocator", "(", ")", ")", ";", "}" ]
Sets the value of the CheckBox @param value - String that can be one of two values: CHECK - sets checkbox from UNCHECKED to CHECK UNCHECK - sets checkbox from CHECKED to UNCHECKED
[ "Sets", "the", "value", "of", "the", "CheckBox" ]
78d646def1bf0904f79b19a81df0241e07f2c73a
https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/widget/element/html/CheckBox.java#L83-L107
3,497
FINRAOS/JTAF-ExtWebDriver
src/main/java/org/finra/jtaf/ewd/widget/element/html/CheckBox.java
CheckBox.waitForChecked
public void waitForChecked(final long time) throws WidgetException { super.waitForCommand(new ITimerCallback() { @Override public boolean execute() { WebElement elem = null; try { elem = getWebElement(); } catch (WidgetException e) { } boolean isSelected = false; try { isSelected = isSelected(elem); } catch (Exception e) { throw new RuntimeException(e); } return (elem != null && isSelected); } @Override public String toString() { return "Waiting for element with the locator: " + getByLocator() + "to be checked"; } }, time); }
java
public void waitForChecked(final long time) throws WidgetException { super.waitForCommand(new ITimerCallback() { @Override public boolean execute() { WebElement elem = null; try { elem = getWebElement(); } catch (WidgetException e) { } boolean isSelected = false; try { isSelected = isSelected(elem); } catch (Exception e) { throw new RuntimeException(e); } return (elem != null && isSelected); } @Override public String toString() { return "Waiting for element with the locator: " + getByLocator() + "to be checked"; } }, time); }
[ "public", "void", "waitForChecked", "(", "final", "long", "time", ")", "throws", "WidgetException", "{", "super", ".", "waitForCommand", "(", "new", "ITimerCallback", "(", ")", "{", "@", "Override", "public", "boolean", "execute", "(", ")", "{", "WebElement", "elem", "=", "null", ";", "try", "{", "elem", "=", "getWebElement", "(", ")", ";", "}", "catch", "(", "WidgetException", "e", ")", "{", "}", "boolean", "isSelected", "=", "false", ";", "try", "{", "isSelected", "=", "isSelected", "(", "elem", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "return", "(", "elem", "!=", "null", "&&", "isSelected", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"Waiting for element with the locator: \"", "+", "getByLocator", "(", ")", "+", "\"to be checked\"", ";", "}", "}", ",", "time", ")", ";", "}" ]
Waits for element at locator to be checked within period of specified time @param time Milliseoncds @throws WidgetTimeoutException
[ "Waits", "for", "element", "at", "locator", "to", "be", "checked", "within", "period", "of", "specified", "time" ]
78d646def1bf0904f79b19a81df0241e07f2c73a
https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/widget/element/html/CheckBox.java#L197-L223
3,498
FINRAOS/JTAF-ExtWebDriver
src/main/java/org/finra/jtaf/ewd/impl/DefaultExtWebDriver.java
DefaultExtWebDriver.getGeneratedHtmlSourceRecursive
private Map<String, String> getGeneratedHtmlSourceRecursive( FrameNode currentFrame, String currFrameId) throws Exception { Map<String, String> frames = new HashMap<String, String>(); if (!currentFrame.isRoot()) { wd.switchTo().defaultContent(); Stack<FrameNode> framesToSelect = new Stack<FrameNode>(); FrameNode currFrame = currentFrame; while (currFrame.getParent() != null) { framesToSelect.push(currFrame); currFrame = currFrame.getParent(); } while (!framesToSelect.isEmpty()) { FrameNode fn = framesToSelect.pop(); wd.switchTo().frame(fn.getFrame()); } } else { wd.switchTo().defaultContent(); } // Add current frame frames.put(currFrameId, wd.getPageSource()); int iframeCount = wd.findElements(By.xpath("//iframe")).size(); if (iframeCount == 0) { return frames; } for (int i = 1; i <= iframeCount; i++) { if (!currentFrame.isRoot()) { wd.switchTo().defaultContent(); Stack<FrameNode> framesToSelect = new Stack<FrameNode>(); FrameNode currFrame = currentFrame; while (currFrame.getParent() != null) { framesToSelect.push(currFrame); currFrame = currFrame.getParent(); } while (!framesToSelect.isEmpty()) { FrameNode fn = framesToSelect.pop(); wd.switchTo().frame(fn.getFrame()); } } else { wd.switchTo().defaultContent(); } FrameNode nextFrame = new FrameNode(currentFrame, By.xpath("(//iframe)[" + i + "]"), this.getWrappedDriver().findElement(By.xpath("(//iframe)[" + i + "]"))); String nextFrameId = currFrameId.substring(0, currFrameId.length() - 1) + "-" + i + "]"; // Recursively add next frames frames.putAll(getGeneratedHtmlSourceRecursive(nextFrame, nextFrameId)); } return frames; }
java
private Map<String, String> getGeneratedHtmlSourceRecursive( FrameNode currentFrame, String currFrameId) throws Exception { Map<String, String> frames = new HashMap<String, String>(); if (!currentFrame.isRoot()) { wd.switchTo().defaultContent(); Stack<FrameNode> framesToSelect = new Stack<FrameNode>(); FrameNode currFrame = currentFrame; while (currFrame.getParent() != null) { framesToSelect.push(currFrame); currFrame = currFrame.getParent(); } while (!framesToSelect.isEmpty()) { FrameNode fn = framesToSelect.pop(); wd.switchTo().frame(fn.getFrame()); } } else { wd.switchTo().defaultContent(); } // Add current frame frames.put(currFrameId, wd.getPageSource()); int iframeCount = wd.findElements(By.xpath("//iframe")).size(); if (iframeCount == 0) { return frames; } for (int i = 1; i <= iframeCount; i++) { if (!currentFrame.isRoot()) { wd.switchTo().defaultContent(); Stack<FrameNode> framesToSelect = new Stack<FrameNode>(); FrameNode currFrame = currentFrame; while (currFrame.getParent() != null) { framesToSelect.push(currFrame); currFrame = currFrame.getParent(); } while (!framesToSelect.isEmpty()) { FrameNode fn = framesToSelect.pop(); wd.switchTo().frame(fn.getFrame()); } } else { wd.switchTo().defaultContent(); } FrameNode nextFrame = new FrameNode(currentFrame, By.xpath("(//iframe)[" + i + "]"), this.getWrappedDriver().findElement(By.xpath("(//iframe)[" + i + "]"))); String nextFrameId = currFrameId.substring(0, currFrameId.length() - 1) + "-" + i + "]"; // Recursively add next frames frames.putAll(getGeneratedHtmlSourceRecursive(nextFrame, nextFrameId)); } return frames; }
[ "private", "Map", "<", "String", ",", "String", ">", "getGeneratedHtmlSourceRecursive", "(", "FrameNode", "currentFrame", ",", "String", "currFrameId", ")", "throws", "Exception", "{", "Map", "<", "String", ",", "String", ">", "frames", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "if", "(", "!", "currentFrame", ".", "isRoot", "(", ")", ")", "{", "wd", ".", "switchTo", "(", ")", ".", "defaultContent", "(", ")", ";", "Stack", "<", "FrameNode", ">", "framesToSelect", "=", "new", "Stack", "<", "FrameNode", ">", "(", ")", ";", "FrameNode", "currFrame", "=", "currentFrame", ";", "while", "(", "currFrame", ".", "getParent", "(", ")", "!=", "null", ")", "{", "framesToSelect", ".", "push", "(", "currFrame", ")", ";", "currFrame", "=", "currFrame", ".", "getParent", "(", ")", ";", "}", "while", "(", "!", "framesToSelect", ".", "isEmpty", "(", ")", ")", "{", "FrameNode", "fn", "=", "framesToSelect", ".", "pop", "(", ")", ";", "wd", ".", "switchTo", "(", ")", ".", "frame", "(", "fn", ".", "getFrame", "(", ")", ")", ";", "}", "}", "else", "{", "wd", ".", "switchTo", "(", ")", ".", "defaultContent", "(", ")", ";", "}", "// Add current frame", "frames", ".", "put", "(", "currFrameId", ",", "wd", ".", "getPageSource", "(", ")", ")", ";", "int", "iframeCount", "=", "wd", ".", "findElements", "(", "By", ".", "xpath", "(", "\"//iframe\"", ")", ")", ".", "size", "(", ")", ";", "if", "(", "iframeCount", "==", "0", ")", "{", "return", "frames", ";", "}", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "iframeCount", ";", "i", "++", ")", "{", "if", "(", "!", "currentFrame", ".", "isRoot", "(", ")", ")", "{", "wd", ".", "switchTo", "(", ")", ".", "defaultContent", "(", ")", ";", "Stack", "<", "FrameNode", ">", "framesToSelect", "=", "new", "Stack", "<", "FrameNode", ">", "(", ")", ";", "FrameNode", "currFrame", "=", "currentFrame", ";", "while", "(", "currFrame", ".", "getParent", "(", ")", "!=", "null", ")", "{", "framesToSelect", ".", "push", "(", "currFrame", ")", ";", "currFrame", "=", "currFrame", ".", "getParent", "(", ")", ";", "}", "while", "(", "!", "framesToSelect", ".", "isEmpty", "(", ")", ")", "{", "FrameNode", "fn", "=", "framesToSelect", ".", "pop", "(", ")", ";", "wd", ".", "switchTo", "(", ")", ".", "frame", "(", "fn", ".", "getFrame", "(", ")", ")", ";", "}", "}", "else", "{", "wd", ".", "switchTo", "(", ")", ".", "defaultContent", "(", ")", ";", "}", "FrameNode", "nextFrame", "=", "new", "FrameNode", "(", "currentFrame", ",", "By", ".", "xpath", "(", "\"(//iframe)[\"", "+", "i", "+", "\"]\"", ")", ",", "this", ".", "getWrappedDriver", "(", ")", ".", "findElement", "(", "By", ".", "xpath", "(", "\"(//iframe)[\"", "+", "i", "+", "\"]\"", ")", ")", ")", ";", "String", "nextFrameId", "=", "currFrameId", ".", "substring", "(", "0", ",", "currFrameId", ".", "length", "(", ")", "-", "1", ")", "+", "\"-\"", "+", "i", "+", "\"]\"", ";", "// Recursively add next frames", "frames", ".", "putAll", "(", "getGeneratedHtmlSourceRecursive", "(", "nextFrame", ",", "nextFrameId", ")", ")", ";", "}", "return", "frames", ";", "}" ]
Gets the current html source from the dom for the every frame in the current window recursively @param currentFrame the current FrameNode @param currFrameId the locator of the current frame @return a map of each frame locator to the generated source @see #getGeneratedHtmlSource() TODO: check/enforce currFrameId format
[ "Gets", "the", "current", "html", "source", "from", "the", "dom", "for", "the", "every", "frame", "in", "the", "current", "window", "recursively" ]
78d646def1bf0904f79b19a81df0241e07f2c73a
https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/impl/DefaultExtWebDriver.java#L462-L522
3,499
FINRAOS/JTAF-ExtWebDriver
src/main/java/org/finra/jtaf/ewd/impl/DefaultSessionFactory.java
DefaultSessionFactory.removeWebDriverTempOldFolders
private static void removeWebDriverTempOldFolders(ClientProperties properties) { String tempFolder = System.getProperty("java.io.tmpdir"); int numberOfDaysToKeepTempFolders = properties.getNumberOfDaysToKeepTempFolders(); if (numberOfDaysToKeepTempFolders < 0) { numberOfDaysToKeepTempFolders = 7; } List<String> tempFolderNameContainsList = new ArrayList<String>(); tempFolderNameContainsList.add("anonymous"); tempFolderNameContainsList.add("scoped_dir"); tempFolderNameContainsList.add("webdriver-ie"); // add parameters from config file String tempFolderNameContainsListFromProp = properties.getTempFolderNameContainsList(); if (tempFolderNameContainsListFromProp != null) { String[] tempFolderNameContainsListFromPropSpit = tempFolderNameContainsListFromProp .split(","); for (String name : tempFolderNameContainsListFromPropSpit) { tempFolderNameContainsList.add(name); } } removeFolders(tempFolder, tempFolderNameContainsList, numberOfDaysToKeepTempFolders); }
java
private static void removeWebDriverTempOldFolders(ClientProperties properties) { String tempFolder = System.getProperty("java.io.tmpdir"); int numberOfDaysToKeepTempFolders = properties.getNumberOfDaysToKeepTempFolders(); if (numberOfDaysToKeepTempFolders < 0) { numberOfDaysToKeepTempFolders = 7; } List<String> tempFolderNameContainsList = new ArrayList<String>(); tempFolderNameContainsList.add("anonymous"); tempFolderNameContainsList.add("scoped_dir"); tempFolderNameContainsList.add("webdriver-ie"); // add parameters from config file String tempFolderNameContainsListFromProp = properties.getTempFolderNameContainsList(); if (tempFolderNameContainsListFromProp != null) { String[] tempFolderNameContainsListFromPropSpit = tempFolderNameContainsListFromProp .split(","); for (String name : tempFolderNameContainsListFromPropSpit) { tempFolderNameContainsList.add(name); } } removeFolders(tempFolder, tempFolderNameContainsList, numberOfDaysToKeepTempFolders); }
[ "private", "static", "void", "removeWebDriverTempOldFolders", "(", "ClientProperties", "properties", ")", "{", "String", "tempFolder", "=", "System", ".", "getProperty", "(", "\"java.io.tmpdir\"", ")", ";", "int", "numberOfDaysToKeepTempFolders", "=", "properties", ".", "getNumberOfDaysToKeepTempFolders", "(", ")", ";", "if", "(", "numberOfDaysToKeepTempFolders", "<", "0", ")", "{", "numberOfDaysToKeepTempFolders", "=", "7", ";", "}", "List", "<", "String", ">", "tempFolderNameContainsList", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "tempFolderNameContainsList", ".", "add", "(", "\"anonymous\"", ")", ";", "tempFolderNameContainsList", ".", "add", "(", "\"scoped_dir\"", ")", ";", "tempFolderNameContainsList", ".", "add", "(", "\"webdriver-ie\"", ")", ";", "// add parameters from config file", "String", "tempFolderNameContainsListFromProp", "=", "properties", ".", "getTempFolderNameContainsList", "(", ")", ";", "if", "(", "tempFolderNameContainsListFromProp", "!=", "null", ")", "{", "String", "[", "]", "tempFolderNameContainsListFromPropSpit", "=", "tempFolderNameContainsListFromProp", ".", "split", "(", "\",\"", ")", ";", "for", "(", "String", "name", ":", "tempFolderNameContainsListFromPropSpit", ")", "{", "tempFolderNameContainsList", ".", "add", "(", "name", ")", ";", "}", "}", "removeFolders", "(", "tempFolder", ",", "tempFolderNameContainsList", ",", "numberOfDaysToKeepTempFolders", ")", ";", "}" ]
This method cleans out folders where the WebDriver temp information is stored. @param properties client properties specified
[ "This", "method", "cleans", "out", "folders", "where", "the", "WebDriver", "temp", "information", "is", "stored", "." ]
78d646def1bf0904f79b19a81df0241e07f2c73a
https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/impl/DefaultSessionFactory.java#L662-L686