eu.semaine.components.dialogue.actionproposers
Class UtteranceActionProposer

java.lang.Object
  extended by java.lang.Thread
      extended by eu.semaine.components.Component
          extended by eu.semaine.components.dialogue.actionproposers.UtteranceActionProposer
All Implemented Interfaces:
SEMAINEMessageAvailableListener, java.lang.Runnable

public class UtteranceActionProposer
extends Component

The UtteranceActionProposer determines what to say based on the current context. TODO: uitbreiden, precieze werking beschrijven in details Input AgentStateReceiver('emaine.data.state.agent') --> take/release turn messages UserStateReceiver('semaine.data.state.user.behaviour') --> user speaking state and detected emotions XMLReceiver('semaine.data.state.context') --> For context information such as user present and the current character Output FMLSender('semaine.data.action.candidate.function') --> utterances to the output modules DialogStateSender('semaine.data.state.dialog') --> dialog state (speaker & listener) XMLSender('semaine.data.state.context') --> For context information such as user present and the current character

Author:
MaatM

Nested Class Summary
 
Nested classes/interfaces inherited from class eu.semaine.components.Component
Component.State
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 int agentSpeakingState
           
static int CHANGE_ASKED
           
static int CHAR_ASKED
           
static int CHAR_ASKED_2
           
static int CHAR_SUGGESTED
           
static int CHAR_SUGGESTED_2
           
 int charChangeState
           
 int charStartupState
           
static float HIGH_AROUSAL
           
static int HOW_ARE_YOU_ASKED
           
static int INTRODUCED
           
static int LISTENING
           
static float LOW_AROUSAL
           
static int NEUTRAL
           
static int OBADIAH
           
static int POPPY
           
static int PREPARING_TO_SPEAK
           
static int PRUDENCE
           
static long SMALL_UTTERANCE
           
static int SPEAKING
           
static int SPIKE
           
 int suggestedChar
           
static int WAITING
           
 
Fields inherited from class eu.semaine.components.Component
inputWaiting, isInput, isOutput, log, meta, receivers, senders, state, waitingTime
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
UtteranceActionProposer()
          Constructor of UtteranceActionProposer Initializes the senders and receivers, randomly determines the first character and initializes some data
 
Method Summary
 void act()
          TODO: Herschrijven
 void adaptQualityToHistory(java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance> utterances)
           
 void addDetectedDActs(StateInfo stateInfo)
          Reads the received Message and tries to filter out the detected Dialogue Acts.
 void addDetectedEmotions(StateInfo userInfo)
          Reads the received Message and tries to filter out the detected Emotion Events.
 boolean agentShouldSpeak(SEMAINEMessage m)
          Reads the messages from the TurnTakingInterpreter and decides if the agent should start speaking or not.
 java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance> convertToSpokenUtterances(java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentUtterance> uttrs)
           
 eu.semaine.components.dialogue.datastructures.AgentUtterance findAgentUtterance(java.lang.String utterance, java.lang.String newType)
           
 eu.semaine.components.dialogue.datastructures.DialogueAct getCombinedUserDialogueAct()
          Combines the detected Dialogue Acts of the previous user turn into 1 DialogueAct
 java.lang.String getMaxScorer(java.util.HashMap<java.lang.String,java.lang.Integer> scores)
          Returns the best possible utterance from the given map with responses and scores Only returns utterances with a score higher than 0.
 eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance getMaxUtterance(java.util.HashMap<java.lang.String,java.lang.Integer> scores, java.lang.String type)
           
 eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance getResponse()
          Determines what to say based on the context Calls different suggestion-methods which return a set of suggestions, with for each suggestion a certain quality.
 java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance> getUtterancesFromCategory(java.lang.String category, double quality)
          Based on the given type of sentence this method tries to find an utterance of that type that hasn't been said for the last x agent utterances.
 boolean giveIntro()
           
 java.util.HashMap<java.lang.String,java.lang.Integer> giveResponseRatings(eu.semaine.components.dialogue.datastructures.DialogueAct act)
          Returns a map with all possible responses plus the ratings of those responses (based on the response model)
 void initData()
          Initializes the utterances of the characters, the character names, and the character history
 eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance manageAgentStart()
          Manages the agent startup process If the user is in this process it will determine what the next step in the process is and return an AgentUtterance to speak.
 eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance manageCharChange()
          Manages the character change process.
 eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance pickUtterances(java.lang.String type)
          Based on the given type of sentence this method tries to find an utterance of that type that hasn't been said for the last x agent utterances.
 void processUtteranceEnd()
          Called when the output module messages that the utterance is finished.
 void react(SEMAINEMessage m)
          Sets context variables if updates are received.
 void sendConvState()
          Sends around that the agent is silent
 void sendListening()
          Sends around that the agent is silent
 void sendNewCharacter(int character)
          Sends around that the system has changed to a new character
 void sendSpeaking()
          Sends around that the agent is speaking
 java.lang.String sendUtterance(eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance utterance)
          Sends the given utterance to the output modules.
 void setUserSpeakingState(StateInfo userInfo)
          Reads the received Message and tries to filter out the detected user speaking state.
 boolean speechReady(SEMAINEXMLMessage xm)
          This method checks if the given message contains the end signal of the animation that the agent is playing.
 boolean speechStarted(SEMAINEXMLMessage xm)
          This method checks if the given message contains the start signal of the animation that the agent is going to play next.
 java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance> suggestAfterSilence()
          Returns a list of possible responses based on the fact that a user did not start speaking after the agent's turn.
 java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance> suggestLastOptions(eu.semaine.components.dialogue.datastructures.DialogueAct act)
          Returns a list of generic responses with a very low quality.
 java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance> suggestLinkingSentence(eu.semaine.components.dialogue.datastructures.DialogueAct act)
          Returns a list of possible linking utterances based on the previous agent utterance and the user's response.
 java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance> suggestOnArousal()
          Returns a list of possible responses based on the arousal.
 java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance> suggestOnContentFeatures(eu.semaine.components.dialogue.datastructures.DialogueAct act)
          Returns a list of possible responses based on the detected Content Features in the given DialogueAct
 void updateCharacterAndUser(StateInfo stateInfo)
          Checks the StateInfo for updates about user presence and character changes.
 void userAppeared()
          Called when a user is detected in the screen.
 void userDisappeared()
          Called when the user disappears from the screen
 java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentUtterance> utteranceCopy(java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentUtterance> utterances)
          Makes a deepcopy of the given ArrayList
 
Methods inherited from class eu.semaine.components.Component
customStartIO, exitRequested, messageAvailableFrom, requestExit, run
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

WAITING

public static final int WAITING
See Also:
Constant Field Values

LISTENING

public static final int LISTENING
See Also:
Constant Field Values

PREPARING_TO_SPEAK

public static final int PREPARING_TO_SPEAK
See Also:
Constant Field Values

SPEAKING

public static final int SPEAKING
See Also:
Constant Field Values

POPPY

public static final int POPPY
See Also:
Constant Field Values

PRUDENCE

public static final int PRUDENCE
See Also:
Constant Field Values

SPIKE

public static final int SPIKE
See Also:
Constant Field Values

OBADIAH

public static final int OBADIAH
See Also:
Constant Field Values

NEUTRAL

public static final int NEUTRAL
See Also:
Constant Field Values

CHANGE_ASKED

public static final int CHANGE_ASKED
See Also:
Constant Field Values

CHAR_SUGGESTED

public static final int CHAR_SUGGESTED
See Also:
Constant Field Values

CHAR_ASKED

public static final int CHAR_ASKED
See Also:
Constant Field Values

CHAR_SUGGESTED_2

public static final int CHAR_SUGGESTED_2
See Also:
Constant Field Values

CHAR_ASKED_2

public static final int CHAR_ASKED_2
See Also:
Constant Field Values

INTRODUCED

public static final int INTRODUCED
See Also:
Constant Field Values

HOW_ARE_YOU_ASKED

public static final int HOW_ARE_YOU_ASKED
See Also:
Constant Field Values

HIGH_AROUSAL

public static final float HIGH_AROUSAL
See Also:
Constant Field Values

LOW_AROUSAL

public static final float LOW_AROUSAL
See Also:
Constant Field Values

SMALL_UTTERANCE

public static final long SMALL_UTTERANCE
See Also:
Constant Field Values

agentSpeakingState

public int agentSpeakingState

charChangeState

public int charChangeState

charStartupState

public int charStartupState

suggestedChar

public int suggestedChar
Constructor Detail

UtteranceActionProposer

public UtteranceActionProposer()
                        throws javax.jms.JMSException
Constructor of UtteranceActionProposer Initializes the senders and receivers, randomly determines the first character and initializes some data

Throws:
javax.jms.JMSException
Method Detail

initData

public void initData()
Initializes the utterances of the characters, the character names, and the character history


act

public void act()
         throws javax.jms.JMSException
TODO: Herschrijven

Overrides:
act in class Component
Throws:
javax.jms.JMSException - if communication with the JMS server goes wrong.

react

public void react(SEMAINEMessage m)
           throws javax.jms.JMSException
Sets context variables if updates are received. If it receives the message that the agent should start talking it will determine what to say and output this.

Overrides:
react in class Component
Throws:
javax.jms.JMSException - if communication with the JMS server goes wrong.

speechReady

public boolean speechReady(SEMAINEXMLMessage xm)
                    throws javax.jms.JMSException
This method checks if the given message contains the end signal of the animation that the agent is playing.

Parameters:
xm - the message to check
Returns:
true if the message contains the end signal, false if it does not.
Throws:
javax.jms.JMSException

speechStarted

public boolean speechStarted(SEMAINEXMLMessage xm)
This method checks if the given message contains the start signal of the animation that the agent is going to play next.

Parameters:
xm - the message to check
Returns:
true if the message contains the start signal, false if it does not.

updateCharacterAndUser

public void updateCharacterAndUser(StateInfo stateInfo)
                            throws javax.jms.JMSException
Checks the StateInfo for updates about user presence and character changes.

Parameters:
stateInfo -
Throws:
javax.jms.JMSException

userAppeared

public void userAppeared()
                  throws javax.jms.JMSException
Called when a user is detected in the screen.

Throws:
javax.jms.JMSException

giveIntro

public boolean giveIntro()
                  throws javax.jms.JMSException
Returns:
true if a next utterance is started
Throws:
javax.jms.JMSException

userDisappeared

public void userDisappeared()
                     throws javax.jms.JMSException
Called when the user disappears from the screen

Throws:
javax.jms.JMSException

manageCharChange

public eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance manageCharChange()
                                                                                    throws javax.jms.JMSException
Manages the character change process. If the user is in this process it will determine what the next step is and return an AgentUtterance to speak. If the user is not in the character change process it will return null

Throws:
javax.jms.JMSException

manageAgentStart

public eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance manageAgentStart()
Manages the agent startup process If the user is in this process it will determine what the next step in the process is and return an AgentUtterance to speak. If the user is not in this process it will return null.


agentShouldSpeak

public boolean agentShouldSpeak(SEMAINEMessage m)
Reads the messages from the TurnTakingInterpreter and decides if the agent should start speaking or not.

Parameters:
m - - the received message
Returns:
- true if the user should speak, false it if shouldn't

getResponse

public eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance getResponse()
Determines what to say based on the context Calls different suggestion-methods which return a set of suggestions, with for each suggestion a certain quality. The final list of possible utterances is then modified to take history into account, and from this list the best (highest quality) option is chosen.

Returns:
the AgentUtterance to speak next

suggestAfterSilence

public java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance> suggestAfterSilence()
Returns a list of possible responses based on the fact that a user did not start speaking after the agent's turn.

Returns:
a list of possible responses

suggestLinkingSentence

public java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance> suggestLinkingSentence(eu.semaine.components.dialogue.datastructures.DialogueAct act)
Returns a list of possible linking utterances based on the previous agent utterance and the user's response.

Parameters:
act - the DialogueAct of the user's previous turn
Returns:
a list of possible responses

suggestOnContentFeatures

public java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance> suggestOnContentFeatures(eu.semaine.components.dialogue.datastructures.DialogueAct act)
Returns a list of possible responses based on the detected Content Features in the given DialogueAct

Parameters:
act - the DialogueAct of the user's previous turn
Returns:
a list of possible responses

suggestOnArousal

public java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance> suggestOnArousal()
Returns a list of possible responses based on the arousal.

Parameters:
act - the DialogueAct of the user's previous turn
Returns:
a list of possible responses

suggestLastOptions

public java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance> suggestLastOptions(eu.semaine.components.dialogue.datastructures.DialogueAct act)
Returns a list of generic responses with a very low quality.

Parameters:
act - the DialogueAct of the user's previous turn
Returns:
a list of possible responses

getUtterancesFromCategory

public java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance> getUtterancesFromCategory(java.lang.String category,
                                                                                                                         double quality)
Based on the given type of sentence this method tries to find an utterance of that type that hasn't been said for the last x agent utterances.

Parameters:
type - - the type of the utterance
Returns:
- the AgentUtterance which includes the utterance type and the utterance itself

convertToSpokenUtterances

public java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance> convertToSpokenUtterances(java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentUtterance> uttrs)

adaptQualityToHistory

public void adaptQualityToHistory(java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance> utterances)

pickUtterances

public eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance pickUtterances(java.lang.String type)
Based on the given type of sentence this method tries to find an utterance of that type that hasn't been said for the last x agent utterances.

Parameters:
type - - the type of the utterance
Returns:
- the AgentUtterance which includes the utterance type and the utterance itself

findAgentUtterance

public eu.semaine.components.dialogue.datastructures.AgentUtterance findAgentUtterance(java.lang.String utterance,
                                                                                       java.lang.String newType)

processUtteranceEnd

public void processUtteranceEnd()
                         throws javax.jms.JMSException
Called when the output module messages that the utterance is finished. Will put the agent state on listening again and send this state around.

Throws:
javax.jms.JMSException

sendUtterance

public java.lang.String sendUtterance(eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance utterance)
                               throws javax.jms.JMSException
Sends the given utterance to the output modules.

Parameters:
utterance -
Returns:
the id of the speech-part
Throws:
javax.jms.JMSException

sendSpeaking

public void sendSpeaking()
                  throws javax.jms.JMSException
Sends around that the agent is speaking

Throws:
javax.jms.JMSException

sendListening

public void sendListening()
                   throws javax.jms.JMSException
Sends around that the agent is silent

Throws:
javax.jms.JMSException

sendConvState

public void sendConvState()
                   throws javax.jms.JMSException
Sends around that the agent is silent

Throws:
javax.jms.JMSException

sendNewCharacter

public void sendNewCharacter(int character)
                      throws javax.jms.JMSException
Sends around that the system has changed to a new character

Parameters:
character - the new character
Throws:
javax.jms.JMSException

setUserSpeakingState

public void setUserSpeakingState(StateInfo userInfo)
Reads the received Message and tries to filter out the detected user speaking state.

Parameters:
m - - the received message

addDetectedEmotions

public void addDetectedEmotions(StateInfo userInfo)
Reads the received Message and tries to filter out the detected Emotion Events.

Parameters:
m -

addDetectedDActs

public void addDetectedDActs(StateInfo stateInfo)
                      throws javax.jms.JMSException
Reads the received Message and tries to filter out the detected Dialogue Acts.

Parameters:
m -
Throws:
javax.jms.JMSException

giveResponseRatings

public java.util.HashMap<java.lang.String,java.lang.Integer> giveResponseRatings(eu.semaine.components.dialogue.datastructures.DialogueAct act)
Returns a map with all possible responses plus the ratings of those responses (based on the response model)

Parameters:
act -
Returns:

getMaxScorer

public java.lang.String getMaxScorer(java.util.HashMap<java.lang.String,java.lang.Integer> scores)
Returns the best possible utterance from the given map with responses and scores Only returns utterances with a score higher than 0. When the highest score <= 0 is will return null.

Parameters:
scores -
Returns:

getMaxUtterance

public eu.semaine.components.dialogue.datastructures.AgentSpokenUtterance getMaxUtterance(java.util.HashMap<java.lang.String,java.lang.Integer> scores,
                                                                                          java.lang.String type)

utteranceCopy

public java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentUtterance> utteranceCopy(java.util.ArrayList<eu.semaine.components.dialogue.datastructures.AgentUtterance> utterances)
Makes a deepcopy of the given ArrayList

Parameters:
utterances - - the list to copy
Returns:

getCombinedUserDialogueAct

public eu.semaine.components.dialogue.datastructures.DialogueAct getCombinedUserDialogueAct()
Combines the detected Dialogue Acts of the previous user turn into 1 DialogueAct

Returns:
the combined DialogueAct