org.pandora.thought.language
Class Language

java.lang.Object
  extended by org.pandora.thought.BasicThought
      extended by org.pandora.thought.language.Language
All Implemented Interfaces:
Thought

public class Language
extends BasicThought

Processes words to determine meaning and response.


Nested Class Summary
static class Language.LanguageState
          Defines the various language conversational states.
 
Field Summary
static float CONVERSATION_MATCH_PERCENTAGE
           
static int COVERSATIONAL_RESPONSE_DELAY
           
static float DISCUSSION_MATCH_PERCENTAGE
           
static int MAX_FILE_SIZE
           
static boolean PROCESS_HTTP
           
 
Constructor Summary
Language()
          Create a new thought.
 
Method Summary
static void addToConversation(Vertex input, Vertex conversation)
          Add the input to the conversation.
 Vertex checkDuplicateResponse(Vertex response, Vertex sentence, Network network, boolean allowMatch)
          Check if the previous response was the same and try to find a new one.
 void checkQuestion(Vertex sentence, Network network)
          Mark the sentence as a question.
 Vertex checkState(Vertex root, java.util.List<Vertex> states, int index, java.util.List<Vertex> inputs, java.util.Map<Vertex,Vertex> variables, java.util.List<Vertex> stateStack, float correctnessRequired, Network network)
          Apply each state machine vertex to the sentence of words.
 Vertex createSetenceText(Vertex vertex, Network network)
          Create the text for the sentence.
 Vertex evaluateFormula(Vertex formula, java.util.Map<Vertex,Vertex> variables, Network network)
          Evaluate the sentence formula in the context of the input.
 Relationship findResponseMatch(Vertex sentence, Vertex previousResponse, Network network, float percentage)
          Find the best match for the sentence.
 Vertex getLastQuotient()
           
 Vertex getLastState()
           
 Vertex getLastStateMachine()
           
 Vertex getWord(Vertex vertex, Network network)
          Return the sentence or word for the vertex.
 Vertex getWordFollowing(Vertex vertex, Vertex previousWord, Network network)
          Return the sentence or word for the vertex.
 void loadSelfFile(java.io.File file)
          Load, compile, and add the state machine from the .self file.
 void loadSelfFile(java.io.InputStream stream, int maxSize)
          Load, compile, and add the state machine from the .self file stream.
 void loadSelfFile(java.net.URL url)
          Load, compile, and add the state machine from the .self file.
 Vertex processAssociation(Vertex text, Network network)
          Associate the word to the current context selection.
 java.util.List<Vertex> processCompoundWords(java.util.List<Relationship> words)
          Transform the list of words, into a list of compound words.
 Vertex processConversational(Vertex input, Vertex sentence, Network network, boolean learning)
          Process the conversational sentence.
 Vertex processCorrection(Vertex input, Vertex correction, Vertex speaker, Vertex target, Network network)
          Process the correction to the last question.
 Vertex processDiscussion(Vertex input, Vertex sentence, Vertex conversation, Network network)
          Process the discussion sentence.
 void processHttp(Vertex sentence, Network network)
          Lookup any urls in the text.
 Vertex processListening(Vertex input, Vertex sentence, Vertex speaker, Vertex conversation, java.util.List<Relationship> targets, Network network)
          Associate the response, attempt to understand.
 void processOffensive(Vertex input, Vertex speaker, Vertex target, Network network)
          Process a offensive response.
 Vertex processUnderstanding(Vertex input, Vertex sentence, float correctnessRequired, Network network)
          Attempt to understand the sentence using state machines.
 void setLastQuotient(Vertex lastQuotient)
           
 void setLastState(Vertex lastState)
           
 void setLastStateMachine(Vertex lastStateMachine)
           
 void stop()
          Stop analysing network.
 void think()
          Analyse the active memory for language.
 
Methods inherited from class org.pandora.thought.BasicThought
awake, getName, getPandora, getPrimitive, getShortTermMemory, initialize, isConscious, log, log, setName, setPandora, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONVERSATION_MATCH_PERCENTAGE

public static float CONVERSATION_MATCH_PERCENTAGE

DISCUSSION_MATCH_PERCENTAGE

public static float DISCUSSION_MATCH_PERCENTAGE

COVERSATIONAL_RESPONSE_DELAY

public static int COVERSATIONAL_RESPONSE_DELAY

MAX_FILE_SIZE

public static int MAX_FILE_SIZE

PROCESS_HTTP

public static boolean PROCESS_HTTP
Constructor Detail

Language

public Language()
Create a new thought.

Method Detail

addToConversation

public static void addToConversation(Vertex input,
                                     Vertex conversation)
Add the input to the conversation.


stop

public void stop()
Stop analysing network.

Specified by:
stop in interface Thought
Overrides:
stop in class BasicThought

think

public void think()
Analyse the active memory for language.

Specified by:
think in interface Thought
Overrides:
think in class BasicThought

evaluateFormula

public Vertex evaluateFormula(Vertex formula,
                              java.util.Map<Vertex,Vertex> variables,
                              Network network)
Evaluate the sentence formula in the context of the input.


processAssociation

public Vertex processAssociation(Vertex text,
                                 Network network)
Associate the word to the current context selection.


checkQuestion

public void checkQuestion(Vertex sentence,
                          Network network)
Mark the sentence as a question.


processHttp

public void processHttp(Vertex sentence,
                        Network network)
Lookup any urls in the text.


processCorrection

public Vertex processCorrection(Vertex input,
                                Vertex correction,
                                Vertex speaker,
                                Vertex target,
                                Network network)
Process the correction to the last question.


processOffensive

public void processOffensive(Vertex input,
                             Vertex speaker,
                             Vertex target,
                             Network network)
Process a offensive response. Remove the sentence.


processDiscussion

public Vertex processDiscussion(Vertex input,
                                Vertex sentence,
                                Vertex conversation,
                                Network network)
Process the discussion sentence. Only response if a question and understood, or has an exact known response.


checkDuplicateResponse

public Vertex checkDuplicateResponse(Vertex response,
                                     Vertex sentence,
                                     Network network,
                                     boolean allowMatch)
Check if the previous response was the same and try to find a new one.


processConversational

public Vertex processConversational(Vertex input,
                                    Vertex sentence,
                                    Network network,
                                    boolean learning)
Process the conversational sentence. Try to understand, otherwise, determine the best know response, if there is no known response, then resort to mimicry.


processListening

public Vertex processListening(Vertex input,
                               Vertex sentence,
                               Vertex speaker,
                               Vertex conversation,
                               java.util.List<Relationship> targets,
                               Network network)
Associate the response, attempt to understand.


findResponseMatch

public Relationship findResponseMatch(Vertex sentence,
                                      Vertex previousResponse,
                                      Network network,
                                      float percentage)
Find the best match for the sentence. Traverse its words to find other sentences they are used in, and pick other sentence with the most words in common.


processUnderstanding

public Vertex processUnderstanding(Vertex input,
                                   Vertex sentence,
                                   float correctnessRequired,
                                   Network network)
Attempt to understand the sentence using state machines.


processCompoundWords

public java.util.List<Vertex> processCompoundWords(java.util.List<Relationship> words)
Transform the list of words, into a list of compound words.


checkState

public Vertex checkState(Vertex root,
                         java.util.List<Vertex> states,
                         int index,
                         java.util.List<Vertex> inputs,
                         java.util.Map<Vertex,Vertex> variables,
                         java.util.List<Vertex> stateStack,
                         float correctnessRequired,
                         Network network)
Apply each state machine vertex to the sentence of words. If the state machine finds a match, it will record the real vertices mapped to the state machine variables.


createSetenceText

public Vertex createSetenceText(Vertex vertex,
                                Network network)
Create the text for the sentence.


getWord

public Vertex getWord(Vertex vertex,
                      Network network)
Return the sentence or word for the vertex.


getWordFollowing

public Vertex getWordFollowing(Vertex vertex,
                               Vertex previousWord,
                               Network network)
Return the sentence or word for the vertex.


getLastStateMachine

public Vertex getLastStateMachine()

setLastStateMachine

public void setLastStateMachine(Vertex lastStateMachine)

getLastState

public Vertex getLastState()

setLastState

public void setLastState(Vertex lastState)

getLastQuotient

public Vertex getLastQuotient()

setLastQuotient

public void setLastQuotient(Vertex lastQuotient)

loadSelfFile

public void loadSelfFile(java.io.File file)
Load, compile, and add the state machine from the .self file.


loadSelfFile

public void loadSelfFile(java.net.URL url)
Load, compile, and add the state machine from the .self file.


loadSelfFile

public void loadSelfFile(java.io.InputStream stream,
                         int maxSize)
Load, compile, and add the state machine from the .self file stream.