T
- the class that represents keywords in this classificationpublic class KeywordClassification<T> extends ClassificationWithConfidenceBase<T> implements java.io.Serializable, ModifiableParametric
KeywordClassifier
operates.UNKNOWN_CONFIDENCE
DEFAULT_INITIAL_CAPACITY
Constructor and Description |
---|
KeywordClassification(java.lang.Class<? extends T> keywordClass,
ClassificationWithConfidence<?> classification)
Creates a new instance of keyword classification copying the settings from the given classification.
|
KeywordClassification(java.lang.Class<? extends T> keywordClass,
float lowestConfidence,
float highestConfidence)
Creates a new instance of keyword classification for the given keyword-representing class.
|
KeywordClassification(ClassificationWithConfidence<? extends T> classification)
Creates a new instance of keyword classification copying the settings from the given classification.
|
Modifier and Type | Method and Description |
---|---|
ClassificationWithConfidenceBase<T> |
add(T category,
float confidence)
Adds the given category with confidence to this classification.
|
protected void |
addKeywordConfidence(T keyword,
float confidence)
Update multi confidence for the given keyword.
|
void |
addKeywordParameter(java.lang.String name,
T keyword,
java.io.Serializable value)
Add a new parameter
name of the given keyword with the given value . |
void |
addParameter(java.lang.String name,
java.io.Serializable value)
Add a new parameter
name with the given value. |
boolean |
containsParameter(java.lang.String name)
Returns whether a parameter with the given
name exists in this parametric object. |
java.util.List<java.lang.Float> |
getAllConfidence(T keyword)
Returns all confidences seen for the given keyword in this classification.
|
int |
getAllConfidenceCount(T keyword)
Returns the number of confidences seen for the given keyword in this classification.
|
java.util.List<java.lang.Float> |
getAllNormalizedConfidence(T keyword)
Returns all confidences seen for the given keyword in this classification
normalized by subtracting the seen minimal value and dividing by the difference
of the seen minimal and maximal values.
|
float |
getKeywordBoostedScore(T keyword)
Returns the score of the given keyword.
|
java.io.Serializable |
getKeywordParameter(java.lang.String name,
T keyword)
Returns an additional parameter with the given
name for the given keyword . |
java.util.Map<T,java.io.Serializable> |
getKeywordParameterMap(java.lang.String name,
boolean create)
Returns the keyword parameter map for the given parameter
name . |
java.io.Serializable |
getParameter(java.lang.String name)
Returns an additional parameter with the given
name . |
<P> P |
getParameter(java.lang.String name,
java.lang.Class<? extends P> parameterClass)
Returns an additional parameter with the given
name . |
<T> T |
getParameter(java.lang.String name,
java.lang.Class<? extends T> parameterClass,
T defaultValue)
Returns an additional parameter with the given
name . |
int |
getParameterCount()
Returns the number of additional parameters.
|
java.util.Map<java.lang.String,? extends java.io.Serializable> |
getParameterMap()
Returns the map of all additional parameters.
|
java.util.Collection<java.lang.String> |
getParameterNames()
Returns a set of additional parameter names present in this object.
|
java.io.Serializable |
getRequiredParameter(java.lang.String name)
Returns an additional parameter with the given
name . |
<T> T |
getRequiredParameter(java.lang.String name,
java.lang.Class<? extends T> parameterClass)
Returns an additional parameter with the given
name . |
java.io.Serializable |
removeKeywordParameter(java.lang.String name,
T keyword)
Removes the parameter
name of the given keyword . |
java.io.Serializable |
removeParameter(java.lang.String name)
Removes an additional parameter with the given
name . |
java.io.Serializable |
setKeywordParameter(java.lang.String name,
T keyword,
java.io.Serializable value)
Set the parameter
name of the given keyword to the given value . |
java.io.Serializable |
setParameter(java.lang.String name,
java.lang.Object value)
Set an additional parameter with the given
name to the given value . |
boolean |
updateConfidence(T category,
float confidence)
Updates confidence of the given category.
|
add, addAll, addAll, addAll, addAll, addAll, addArray, addArray, append, appendCategory, getConfidence, getHighestConfidence, getLowestConfidence, checkValidConfidence, isUpdatingConfidence, toString, updateAllConfidences
castToStored, contains, createDefaultStorage, getStoredClass, iterator, remove, size
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
contains, getStoredClass, iterator, size
public KeywordClassification(java.lang.Class<? extends T> keywordClass, float lowestConfidence, float highestConfidence)
keywordClass
- the class that represents keywords in this classificationlowestConfidence
- the lowest possible confidence of this classificationhighestConfidence
- the highest possible confidence of this classificationpublic KeywordClassification(java.lang.Class<? extends T> keywordClass, ClassificationWithConfidence<?> classification)
keywordClass
- the class that represents keywords in this classificationclassification
- the classification to copy the class, the lowest/highest confidence, and parameters frompublic KeywordClassification(ClassificationWithConfidence<? extends T> classification)
classification
- the classification to copy the class, the lowest/highest confidence, and parameters fromprotected void addKeywordConfidence(T keyword, float confidence)
keyword
- the keyword for which the confidence parameters are updatedconfidence
- the added confidencepublic ClassificationWithConfidenceBase<T> add(T category, float confidence) throws java.lang.IllegalArgumentException
ClassificationWithConfidenceBase
add
in class ClassificationWithConfidenceBase<T>
category
- the category to addconfidence
- the confidence of the category to addjava.lang.IllegalArgumentException
- if the confidence is not within the boundspublic boolean updateConfidence(T category, float confidence) throws java.lang.IllegalArgumentException
ClassificationWithConfidenceBase
updateConfidence
in class ClassificationWithConfidenceBase<T>
category
- the category for which to update the confidenceconfidence
- the new confidence valuejava.lang.IllegalArgumentException
- if the confidence is not within the boundspublic java.util.List<java.lang.Float> getAllConfidence(T keyword)
keyword
- the keyword the get the list of confidences forpublic java.util.List<java.lang.Float> getAllNormalizedConfidence(T keyword)
keyword
- the keyword the get the list of confidences forpublic int getAllConfidenceCount(T keyword)
keyword
- the keyword the get the number of confidences forpublic float getKeywordBoostedScore(T keyword)
keyword
- the keyword the get the normalized confidence forpublic int getParameterCount()
Parametric
getParameterCount
in interface Parametric
public java.util.Collection<java.lang.String> getParameterNames()
Parametric
getParameterNames
in interface Parametric
public boolean containsParameter(java.lang.String name)
Parametric
name
exists in this parametric object.containsParameter
in interface Parametric
name
- the name of the additional parameter to getname
or false if it does notpublic java.io.Serializable getParameter(java.lang.String name)
Parametric
name
.getParameter
in interface Parametric
name
- the name of the additional parameter to getname
or null if it is not setpublic <P> P getParameter(java.lang.String name, java.lang.Class<? extends P> parameterClass)
Parametric
name
.
If the parameter name
exists but it is not an instance of
parameterClass
, null is returned.getParameter
in interface Parametric
P
- the class of the parametername
- the name of the additional parameter to getparameterClass
- the class of the parameter to getname
or null if it is not setpublic java.io.Serializable getRequiredParameter(java.lang.String name) throws java.lang.IllegalArgumentException
Parametric
name
.
If the parameter with the given name
is not set, an exception is thrown.getRequiredParameter
in interface Parametric
name
- the name of the additional parameter to getname
java.lang.IllegalArgumentException
- if the parameter with the given name
is not setpublic <T> T getRequiredParameter(java.lang.String name, java.lang.Class<? extends T> parameterClass) throws java.lang.IllegalArgumentException, java.lang.ClassCastException
Parametric
name
.
If the parameter with the given name
is not set or is not an
instance of parameterClass
, an exception is thrown.getRequiredParameter
in interface Parametric
T
- the class of the parametername
- the name of the additional parameter to getparameterClass
- the class of the parameter to getjava.lang.IllegalArgumentException
- if the parameter with the given name
is not setjava.lang.ClassCastException
- if the parameter with the given name
is not an instance of parameterClass
public <T> T getParameter(java.lang.String name, java.lang.Class<? extends T> parameterClass, T defaultValue)
Parametric
name
.
If the parameter is not set or is not an instance of parameterClass
,
the defaultValue
is returned instead.getParameter
in interface Parametric
T
- the class of the parametername
- the name of the additional parameter to getparameterClass
- the class of the parameter to getdefaultValue
- the default value to use if the parameter is nullpublic java.util.Map<java.lang.String,? extends java.io.Serializable> getParameterMap()
Parametric
getParameterMap
in interface Parametric
public java.io.Serializable setParameter(java.lang.String name, java.lang.Object value) throws java.lang.ClassCastException
ModifiableParametric
name
to the given value
.
Note that the previous value is replaced with the new one.setParameter
in interface ModifiableParametric
name
- the name of the additional parameter to setvalue
- the new value for the parametername
or null if it was not setjava.lang.ClassCastException
- if the given value is not Serializable
public java.io.Serializable removeParameter(java.lang.String name)
ModifiableParametric
name
.removeParameter
in interface ModifiableParametric
name
- the name of the additional parameter to removename
that was removed or null if it was not setpublic void addParameter(java.lang.String name, java.io.Serializable value) throws java.lang.IllegalArgumentException
name
with the given value.
If the parameter with the given name
already exists,
IllegalArgumentException is thrown.name
- the parameter name to setvalue
- the new value for the parameterjava.lang.IllegalArgumentException
- if the parameter with the given name
already existspublic java.util.Map<T,java.io.Serializable> getKeywordParameterMap(java.lang.String name, boolean create)
name
.
This is internal utility that is used in keyword-parameter methods.name
- the name of the keyword parameter to getcreate
- flag whether to create the parameter if it does not existpublic java.io.Serializable getKeywordParameter(java.lang.String name, T keyword)
name
for the given keyword
.name
- the name of the additional parameter to getkeyword
- the keyword for which to get the additional parametername
or null if it is not setpublic java.io.Serializable setKeywordParameter(java.lang.String name, T keyword, java.io.Serializable value)
name
of the given keyword
to the given value
.
Note that the previous value is replaced with the new one.name
- the parameter name to setkeyword
- the parameter keyword to setvalue
- the new value for the parameterpublic void addKeywordParameter(java.lang.String name, T keyword, java.io.Serializable value)
name
of the given keyword
with the given value
.
If the parameter with the given name
already exists for the given keyword
,
an IllegalArgumentException is thrown.name
- the parameter name to setkeyword
- the parameter keyword to setvalue
- the new value for the parameterjava.lang.IllegalArgumentException
- if the parameter with the given name
already existspublic java.io.Serializable removeKeywordParameter(java.lang.String name, T keyword)
name
of the given keyword
.name
- the parameter name to removekeyword
- the parameter keyword to remove