Package org.predict4all.nlp.words.model
Class UserWord
- java.lang.Object
-
- org.predict4all.nlp.words.model.AbstractWord
-
- org.predict4all.nlp.words.model.SimpleWord
-
- org.predict4all.nlp.words.model.UserWord
-
- All Implemented Interfaces:
Word
public class UserWord extends SimpleWord
-
-
Field Summary
-
Fields inherited from class org.predict4all.nlp.words.model.SimpleWord
forceInvalid, forceValid, modifiedBySystem, modifiedByUser, probFactor, word
-
Fields inherited from interface org.predict4all.nlp.words.model.Word
TYPE_EQUIVALENCE_CLASS, TYPE_NGRAM_TAG, TYPE_SIMPLE, TYPE_USER_WORD
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Word
clone(int newId)
Create a clone of this word.
This allow duplication existing word, an new id should be provided.static UserWord
create(int id, String word)
static UserWord
create(int id, String word, double probFactor, boolean forceInvalid, boolean forceValid, long updateDate, int count)
long
getLastUseDate()
byte
getType()
int
getUsageCount()
void
incrementUsageCount()
To increase the "usage" count of this wordboolean
isUserWord()
boolean
isValidToBePredicted(PredictionParameter predictionParameter)
To check if this word can be displayed as a prediction result.
This typically return true for original words, but can be sensible to computation for user words.
This can also return true/false regardingWord.isForceInvalid()
orWord.isForceValid()
Also, user word are valid for prediction regardingPredictionParameter.getMinUseCountToValidateNewWord()
String
toString()
-
Methods inherited from class org.predict4all.nlp.words.model.SimpleWord
createModified, getProbFactor, getWord, isForceInvalid, isForceValid, isModifiedBySystem, isModifiedByUser, isModifiedByUserOrSystem, setForceInvalid, setForceValid, setModifiedByUser, setProbFactor
-
Methods inherited from class org.predict4all.nlp.words.model.AbstractWord
getEquivalenceClass, getEquivalenceClassId, getID, getNGramTag, getNGramTagId, isEquivalenceClass, isNGramTag, isValidForSaving, setModifiedBySystem
-
-
-
-
Method Detail
-
getUsageCount
public int getUsageCount()
- Specified by:
getUsageCount
in interfaceWord
- Overrides:
getUsageCount
in classAbstractWord
- Returns:
- the number of times this word was seen "used" in user text.
This count is update byWordPredictor
when training the dynamic model.
-
incrementUsageCount
public void incrementUsageCount()
Description copied from interface:Word
To increase the "usage" count of this word- Specified by:
incrementUsageCount
in interfaceWord
- Overrides:
incrementUsageCount
in classAbstractWord
-
getLastUseDate
public long getLastUseDate()
- Specified by:
getLastUseDate
in interfaceWord
- Overrides:
getLastUseDate
in classAbstractWord
- Returns:
- the timestamp of the last usage (typically the last call to
Word.incrementUsageCount()
)
-
isUserWord
public boolean isUserWord()
- Specified by:
isUserWord
in interfaceWord
- Overrides:
isUserWord
in classAbstractWord
- Returns:
- true if this word is
UserWord
instance
-
isValidToBePredicted
public boolean isValidToBePredicted(PredictionParameter predictionParameter)
Description copied from interface:Word
To check if this word can be displayed as a prediction result.
This typically return true for original words, but can be sensible to computation for user words.
This can also return true/false regardingWord.isForceInvalid()
orWord.isForceValid()
Also, user word are valid for prediction regardingPredictionParameter.getMinUseCountToValidateNewWord()
- Specified by:
isValidToBePredicted
in interfaceWord
- Overrides:
isValidToBePredicted
in classSimpleWord
- Parameters:
predictionParameter
- the prediction parameter, could be use to validate the word- Returns:
- true if the word can be displayed in prediction result
-
toString
public String toString()
- Overrides:
toString
in classAbstractWord
-
getType
public byte getType()
- Specified by:
getType
in interfaceWord
- Overrides:
getType
in classSimpleWord
- Returns:
- the byte to save this word type (using TYPE_EQUIVALENCE_CLASS, TYPE_NGRAM_TAG, etc...)
Used inWordFileInputStream
andWordFileOutputStream
-
create
public static UserWord create(int id, String word, double probFactor, boolean forceInvalid, boolean forceValid, long updateDate, int count)
-
clone
public Word clone(int newId)
Description copied from interface:Word
Create a clone of this word.
This allow duplication existing word, an new id should be provided.- Specified by:
clone
in interfaceWord
- Overrides:
clone
in classSimpleWord
- Parameters:
newId
- the word new id- Returns:
- a clone of this word, with the new id
-
-