Exemplo n.º 1
0
 /** Process the text sentence. */
 public void inputSentence(
     String text, String userName, List<String> targetUserNames, Network network) {
   Vertex input = createInputSentence(text.trim(), network);
   input.addRelationship(Primitive.INSTANTIATION, Primitive.CHAT);
   // Process speaker.
   Vertex user = network.createSpeaker(userName);
   input.addRelationship(Primitive.SPEAKER, user);
   // Process target speakers.
   Set<String> uniqueTargetUserNames = new HashSet<String>();
   for (String targetUserName : targetUserNames) {
     if (!targetUserName.equals(userName) && !uniqueTargetUserNames.contains(targetUserName)) {
       uniqueTargetUserNames.add(targetUserName);
       Vertex targetUser = null;
       if (targetUserName.equals(getNick()) || targetUserName.equals(getNickAlt())) {
         targetUser = network.createVertex(Primitive.SELF);
       } else {
         targetUser = network.createSpeaker(targetUserName);
       }
       input.addRelationship(Primitive.TARGET, targetUser);
     }
   }
   user.addRelationship(Primitive.INPUT, input);
   // Process conversation.
   Vertex conversation = getConversation(network);
   if (conversation == null) {
     conversation = network.createInstance(Primitive.CONVERSATION);
     conversation.addRelationship(Primitive.TYPE, Primitive.CHAT);
     setConversation(conversation);
     conversation.addRelationship(Primitive.SPEAKER, Primitive.SELF);
     for (String eachUser : getUsers()) {
       conversation.addRelationship(Primitive.SPEAKER, network.createSpeaker(eachUser));
     }
   }
   Language.addToConversation(input, conversation);
   network.save();
   getBot().memory().addActiveMemory(input);
 }
Exemplo n.º 2
0
 /** Return the current conversation. */
 public Vertex getConversation(Network network) {
   if (this.conversation == null) {
     return null;
   }
   return network.findById(conversation);
 }