dasher
Class CRemoteAlphabetManager

java.lang.Object
  extended by dasher.CNodeManager
      extended by dasher.CAlphabetManager
          extended by dasher.CRemoteAlphabetManager
All Implemented Interfaces:
ProbsListener

public class CRemoteAlphabetManager
extends CAlphabetManager
implements ProbsListener

This is part of an experiment with remote language modelling. It is designed for use with the CRemotePPM language model.

This class is designed to allow us to update nodes asynchronously whilst using as much of Dasher's existing code as possible. Historically, the task would go:

My new schema is: When asked to populate a node, we note the details of the request and place it in a queue. We directly notify the language model of the requirement, supplying the model-calculated normalisation constant, the generation of which has been refactored out into a seperate function, getNonUniformNorm(int iNorm).

When the reply comes back, we apply the model's post-processing by calling AdjustProbs(long[] probs), which again used to be a part of the getProbs sequence but is now a seperate function so that the model *can* do its modifications on probabilities which come from elsewhere. The main codepath has been modified so that it calls the appropriate refactored functions, also increasing code readability.


Nested Class Summary
(package private)  class CRemoteAlphabetManager.PendingPopulate
          Struct describing a pending PopulateChildrenWithSymbol
 
Field Summary
private  java.util.Queue<CRemoteAlphabetManager.PendingPopulate> pendingPopulates
          Queue of requests pending with the remote server
 
Fields inherited from class dasher.CAlphabetManager
ContSymbol, ConvertSymbol, m_Alphabet, m_Colours, m_DisplayText, m_LanguageModel, m_Model, SPSymbol
 
Fields inherited from class dasher.CNodeManager
m_iID
 
Constructor Summary
CRemoteAlphabetManager(CDasherModel model, CLanguageModel langmodel)
          Create a new RemoteAlphabetManager which uses a given Model and LanguageModel to produce probabilities.
 
Method Summary
 void PopulateChildrenWithSymbol(CDasherNode Node, int iExistingSymbol, CDasherNode ExistingChild)
          Override of CAlphabetManager's PopulateChildrenWithSymbol method.
 void probsArrived(long[] probs)
          Called by the LanguageModel when a request sent to the remote language modelling server responds to a request.
 
Methods inherited from class dasher.CAlphabetManager
ClearNode, GetRoot, Output, PopulateChildren, PopulateChildrenWithSymbol, RebuildParent, Ref, Undo, Unref, WaitForChildren
 
Methods inherited from class dasher.CNodeManager
Enter, GetID, Leave
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pendingPopulates

private java.util.Queue<CRemoteAlphabetManager.PendingPopulate> pendingPopulates
Queue of requests pending with the remote server

Constructor Detail

CRemoteAlphabetManager

public CRemoteAlphabetManager(CDasherModel model,
                              CLanguageModel langmodel)
Create a new RemoteAlphabetManager which uses a given Model and LanguageModel to produce probabilities.

Parameters:
model - Model which knows how to mangle probabilities
langmodel - LanguageModel which produces probabilities
Method Detail

PopulateChildrenWithSymbol

public void PopulateChildrenWithSymbol(CDasherNode Node,
                                       int iExistingSymbol,
                                       CDasherNode ExistingChild)
Override of CAlphabetManager's PopulateChildrenWithSymbol method.

Requests that our remote language model should produce probabilities appropriate to this Node and returns without actually populating the Node's children.

The population itself will be performed when our asynchronous request completes; at this point, probsArrived() will be called.

Overrides:
PopulateChildrenWithSymbol in class CAlphabetManager
Parameters:
Node - Node whose children we are to populate
iExistingSymbol - Symbol of the Node's existing child, if any
ExistingChild - Pre-existing child of the Node we are to populate, if any. Null if none.

probsArrived

public void probsArrived(long[] probs)
Called by the LanguageModel when a request sent to the remote language modelling server responds to a request.

This will perform the actual population by calling the ordinary AlphabetManager's PopulateChildrenWithSymbol method.

Specified by:
probsArrived in interface ProbsListener
Parameters:
probs - Probabilities received