|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdasher.CDasherComponent
dasher.CLanguageModel
public abstract class CLanguageModel
LanguageModels are responsible for predicting / guessing the probabilities associated with members of a given alphabet in a given context.
They have no internal state except for knowledge of the alphabet in which they make predictions; rather they produce, modify and destroy Context objects (subclasses of CContextBase) which represent the context in which they were working. This enables the impression of multiple diverging models, when in fact the model is only capable of answering one question: "What comes next in this context?"
Models can adapt themselves in response to user input, and should do so if they are capable when LearnSymbol is called. Calls to EnterSymbol on the other hand should modify their context without altering the model.
| Field Summary | |
|---|---|
protected CSymbolAlphabet |
m_Alphabet
Alphabet in which we make predictions |
static CContextBase |
nullContext
Value to be returned when we need a null context. |
| Fields inherited from class dasher.CDasherComponent |
|---|
m_EventHandler, m_SettingsStore |
| Constructor Summary | |
|---|---|
CLanguageModel(CEventHandler EventHandler,
CSettingsStore SettingsStore,
CSymbolAlphabet Alphabet)
Creates a LanguageModel working in a given alphabet. |
|
| Method Summary | |
|---|---|
abstract CContextBase |
CloneContext(CContextBase Context)
Clones a given context; changes to one clone must not effect the state of the other. |
abstract CContextBase |
CreateEmptyContext()
Creates an empty context |
abstract void |
EnterSymbol(CContextBase context,
int Symbol)
Modifies the supplied context, appending a given symbol. |
abstract int |
GetMemory()
Get some measure of the memory usage for diagnostic purposes. |
abstract long[] |
GetProbs(CContextBase Context,
long iNorm)
Given a context and a normalisation value to which all probabilities must add up, this should produce an array in which each term corresponds to the relative probability of that symbol coming next. |
protected int |
GetSize()
Gets the number of characters in our alphabet |
void |
HandleEvent(CEvent Event)
Ignores all events |
boolean |
isRemote()
Indicates whether this is a remote/asynchronous model with respect to returning probabilities. |
abstract void |
LearnSymbol(CContextBase context,
int Symbol)
Modifies the supplied context, appending a given symbol. |
abstract void |
ReleaseContext(CContextBase Context)
Releases a given context; if the LanguageModel is keeping track of them internally or doing allocation work, it should release their storage. |
CSymbolAlphabet |
SymbolAlphabet()
Gets our working alphabet |
| Methods inherited from class dasher.CDasherComponent |
|---|
GetBoolParameter, GetLongParameter, GetParameterName, GetParameterType, GetStringParameter, InsertEvent, SetBoolParameter, SetLongParameter, SetStringParameter, UnregisterComponent |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final CContextBase nullContext
protected CSymbolAlphabet m_Alphabet
| Constructor Detail |
|---|
public CLanguageModel(CEventHandler EventHandler,
CSettingsStore SettingsStore,
CSymbolAlphabet Alphabet)
EventHandler - Event handler with which to register ourselvesSettingsStore - Settings repository to useAlphabet - Alphabet to work in| Method Detail |
|---|
public void HandleEvent(CEvent Event)
HandleEvent in class CDasherComponentEvent - Event received.public boolean isRemote()
public abstract CContextBase CreateEmptyContext()
public abstract CContextBase CloneContext(CContextBase Context)
Context - Context to clone
public abstract void ReleaseContext(CContextBase Context)
Context - Context to release
public abstract void EnterSymbol(CContextBase context,
int Symbol)
The model should not alter its predictions based upon this entry.
context - Context to modifySymbol - Symbol to enter
public abstract void LearnSymbol(CContextBase context,
int Symbol)
The model should learn from this if it can in order to make better predictions in future.
If the model is not capable of learning, this should behave precisely as EnterSymbol.
context - Context to modifySymbol - Symbol to enter
public abstract long[] GetProbs(CContextBase Context,
long iNorm)
The indices assigned to symbols should match those in the SymbolAlphabet we're working with.
The size of the array returned should be equal to the number of symbols in our current alphabet.
public abstract int GetMemory()
public CSymbolAlphabet SymbolAlphabet()
protected int GetSize()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||