Package org.nlpub.watset.util
Interface Maximizer
-
public interface MaximizerUtilities for searching arguments of the maxima of the function.
-
-
Method Summary
Static Methods Modifier and Type Method Description static <T> Predicate<T>alwaysFalse()A predicate that is always false.static <T> Predicate<T>alwaysTrue()A predicate that is always true.static <V,S extends Comparable<S>>
Optional<V>argmax(Iterator<V> it, Function<V,S> scorer)Find the first argument of the maximum (argmax) of the function.static <V,S extends Comparable<S>>
Optional<V>argmax(Iterator<V> it, Predicate<V> checker, Function<V,S> scorer)Find the first argument of the maximum (argmax) of the function.static <V,S extends Comparable<S>>
Optional<V>argmaxRandom(Iterator<V> it, Function<V,S> scorer, Random random)Find the arguments of the maxima (argmax) of the function and randomly choose any of them.
-
-
-
Method Detail
-
alwaysTrue
static <T> Predicate<T> alwaysTrue()
A predicate that is always true.- Type Parameters:
T- the type- Returns:
- the absolute truth
-
alwaysFalse
static <T> Predicate<T> alwaysFalse()
A predicate that is always false.- Type Parameters:
T- the type- Returns:
- the absolute non-truth
-
argmax
static <V,S extends Comparable<S>> Optional<V> argmax(Iterator<V> it, Predicate<V> checker, Function<V,S> scorer)
Find the first argument of the maximum (argmax) of the function.- Type Parameters:
V- the argument typeS- the score type- Parameters:
it- the finite iteratorchecker- the predicate that evaluates the suitability of the argumentscorer- the scoring function- Returns:
- a non-empty optional that contains the first found argmax, otherwise the empty one
-
argmax
static <V,S extends Comparable<S>> Optional<V> argmax(Iterator<V> it, Function<V,S> scorer)
Find the first argument of the maximum (argmax) of the function.- Type Parameters:
V- the argument typeS- the score type- Parameters:
it- the finite iteratorscorer- the scoring function- Returns:
- a non-empty optional that contains the first found argmax, otherwise the empty one
- See Also:
argmax(Iterator, Predicate, Function)
-
argmaxRandom
static <V,S extends Comparable<S>> Optional<V> argmaxRandom(Iterator<V> it, Function<V,S> scorer, Random random)
Find the arguments of the maxima (argmax) of the function and randomly choose any of them.- Type Parameters:
V- the argument typeS- the score type- Parameters:
it- the finite iteratorscorer- the scoring functionrandom- the random number generator- Returns:
- a non-empty optional that contains the randomly chosen argmax, otherwise the empty one
-
-