/*FUNCTION DESCRIPTION THANKS * simply says thanks based on which register theyre talking in */ public string senseThanks(PairParamaters q, ConversationalParamaters conversationalParamaters) { String output = ""; if (conversationalParamaters.registerType == ConversationalParamaters.RegisterType.formal_register) { output = "thankyou"; } else if (conversationalParamaters.registerType == ConversationalParamaters.RegisterType.intimate_register) { output = "cheers!"; } else //casual { output = "thanks"; } //80% chance of adding name/title //if (r.NextDouble() > 0.8f) // output += q.respondingSpeaker.name(q.initiatingSpeaker) //80% chance of explamation point if (r.NextDouble() > 0.8f) { output += "!"; } return(formatOutput(output)); }
//i'm well thanks public string senseGreetingAnswer(PairParamaters q, ConversationalParamaters conversationalParamaters) { String output = ""; if (conversationalParamaters.registerType == ConversationalParamaters.RegisterType.formal_register) { output = vocabDictionary.generateRandom("hibye/greetingAnswer/formal"); //% chance of using the interlocutors name if (conversationalParamaters.r.Next(3, 7) <= q.politeness)//greater the politeness the greater the chance of using their name/honorific { output += " ," + senseThanks(q, conversationalParamaters); } } else if (conversationalParamaters.registerType == ConversationalParamaters.RegisterType.casual_register) { output = vocabDictionary.generateRandom("hibye/greetingAnswer/casual"); } else if (conversationalParamaters.registerType == ConversationalParamaters.RegisterType.intimate_register) { output = vocabDictionary.generateRandom("hibye/greetingAnswer/intimate"); } return(output); }
/*FUNCTION DESCRIPTION YES*/ public string sense_response_yesNo(PairParamaters q, ConversationalParamaters conversationalParamaters, Boolean condition) { String output = ""; if (condition) { if (conversationalParamaters.registerType == ConversationalParamaters.RegisterType.intimate_register) { output = "yeah"; } else { output = "yes"; } } else { if (conversationalParamaters.registerType == ConversationalParamaters.RegisterType.intimate_register) { output = "nah"; } else { output = "no"; } } return(formatOutput(output)); }
/*give compliment sense * could be complimenting: * appearance of the interlocutor (entity to compliment is the interlocutor) * ability of the interlocutor (something madeby/done by interlocutor) * thing owned or made or chosen by the interlocutor (something owned by interlocutor) * * e.g. the cake is so good! (which you made) * e.g. you make great cakes! you make cakes well * e.g. your dog is so good! * e.g. you look good today! * * TODO: I like your scarf */ public string sense_compliment_give(PairParamaters q, ConversationalParamaters conversationalParamaters, PhysicalEntity entityToCompliment) { String output = ""; String libraryDirectory = "compliments"; //check whether we're complimenting a thing or a person if (entityToCompliment == q.respondingSpeaker) { libraryDirectory += "/person"; //TODO check if its a man and woman etc. //TODO check if they're in love output = "you look good today"; } else { //TODO check what the relationship is. e.g. does the interlocutor own it or did he/she make it //output = the/your thingToCompliment.noun is good //output = you thingToCompliment.verbOrigin really well (you bake cakes really well) output = "the " + entityToCompliment.getRandomCommonNoun() + "is really good"; } /* * if (conversationalParamaters.registerType == ConversationalParamaters.RegisterType.formal_register) * { * output = vocabDictionary.generateRandom(libraryDirectory + "/formal"); * * //% chance of using the interlocutors name * if (conversationalParamaters.r.Next(3, 7) <= q.politeness)//greater the politeness the greater the chance of using their name/honorific * output += " ," + senseThanks(q.respondingSpeaker.name(q.initiatingSpeaker)); * } * else if (conversationalParamaters.registerType == ConversationalParamaters.RegisterType.casual_register) * { * output = vocabDictionary.generateRandom(libraryDirectory + "/casual"); * } * else if (conversationalParamaters.registerType == ConversationalParamaters.RegisterType.intimate_register) * { * output = vocabDictionary.generateRandom(libraryDirectory + "/intimate"); * } * * //50% chance of using other persons name/title * if (r.NextDouble() > 0.5f) * output += " " + q.respondingSpeaker.name(q.initiatingSpeaker); * * //50% chance of explamation point * if (r.NextDouble() > 0.5f) * output += "!"; */ return(output); }
/*SENSE DECLARE FEELINGS * two main production rules * 1 I like x because. * 2.X is/are great because. * * example output: * I like horses * Horses are great. * I like horses because x * I don't like horses because x * I like Harry because... * * Horses are great because... * Yes, horses are great because * * Horses are so cuddly. i like them. * * NOTES: currently unnafected by register or politeness. perhaps turn the 'isn't' into 'is not' in formal register? */ //the reason for this overload is that the user may choose to override politeness when needed //TODO doesnt take into acount tense. would actually be perhaps the easiest place in the whole system to implement tense public String sense_discuss_giveFeelings(PairParamaters q, ConversationalParamaters conversationalParamaters, Opinion speakersOpinion, Opinion interlocutorsOpinion) { string output = ""; //TODO put in a proper algorithm here, at least with registers, at best a special agree/disagree function that it can call if (speakersOpinion.likes == interlocutorsOpinion.likes) { output += "yes, "; } else { output += "no, "; } return(sense_discuss_giveFeelings(q, conversationalParamaters, speakersOpinion)); }
private Queue <Turn> outputQueue;//queue of utterances public Conversation(World w, LinguisticDictionary.LinguisticDictionary v, ConversationalParamaters paramaters) { world = w; vocabDictionary = v; conversationalParamaters = paramaters; r = new Random(); topicQueue = new Queue <Topic>(); adjacencyPairRoot = new ProductionLayers.AdjacencyPairs.AdjacencyPair(); adjacencyPairQueue = new Queue <ProductionLayers.AdjacencyPairs.AdjacencyPair>(); MovesQueue = new Queue <MovesQueueItem>(); outputQueue = new Queue <Turn>(); initQUD(); //place greeting sequence, if appropriate go(); //immediately begin processing }
/*SENSE ASK INTERLOCUTOR HIS OPINION ABOUT TOPIC X * topic can be either a type or an entity (later events etc. can be introduced) * two main production rules * 1. is X good (only for entities, not for types) * 2. do you like x? * * example output: * Do you like horses? * /TODO/Is the cake good? * Do you like your cake? * * NOTES: currently unnafected by register or politeness. perhaps turn the 'isn't' into 'is not' in formal register? */ //the reason for this overload is that the user may choose to override politeness when needed //TODO doesnt take into acount tense. would actually be perhaps the easiest place in the whole system to implement tense public String sense_discuss_askFeelings(PairParamaters q, ConversationalParamaters conversationalParamaters, Opinion thingToAskAbout) { String output = ""; //String declaration = "";//not actually verb, more like 'is good' 'are not good' String punctuation = "?"; //String constituent_one = ""; String constituent_two = ""; //String rendered_reason = ""; //String isAre = "";//auxilliary verb just to distringuish plural and singular /*ASSEMBLE*/ //TODO gendered pronouns he and she, and plurals e.g. they/them output = "Do you like " + renderConstituent(thingToAskAbout._subject, thingToAskAbout._subject.GetType() == typeof(TypeDefinition)); return(formatOutput(output) + punctuation); }
//and how are you then? public string senseGreetingQuestionReciprocating(PairParamaters q, ConversationalParamaters conversationalParamaters) { String output = ""; if (conversationalParamaters.registerType == ConversationalParamaters.RegisterType.formal_register) { output = vocabDictionary.generateRandom("hibye/greetingQuestionReciprocating/formal"); } else if (conversationalParamaters.registerType == ConversationalParamaters.RegisterType.casual_register) { output = vocabDictionary.generateRandom("hibye/greetingQuestionReciprocating/casual"); } else if (conversationalParamaters.registerType == ConversationalParamaters.RegisterType.intimate_register) { output = vocabDictionary.generateRandom("hibye/greetingQuestionReciprocating/intimate"); } return(output + "?"); }
/*### END HELPER FUNCTIONS ###*/ /*##### SENSE FUNCTIONS #####*/ /*BEGIN GREETING AND FAREWELL SENSES*/ //Hi! public string senseGreeting(PairParamaters q, ConversationalParamaters conversationalParamaters) { String output = ""; if (conversationalParamaters.registerType == ConversationalParamaters.RegisterType.formal_register) { output = vocabDictionary.generateRandom("hibye/greeting/formal"); //% chance of using the interlocutors name if (conversationalParamaters.r.Next(3, 7) <= q.politeness)//greater the politeness the greater the chance of using their name/honorific { output += " ," + senseThanks(q, conversationalParamaters); } } else if (conversationalParamaters.registerType == ConversationalParamaters.RegisterType.casual_register) { output = vocabDictionary.generateRandom("hibye/greeting/casual"); } else if (conversationalParamaters.registerType == ConversationalParamaters.RegisterType.intimate_register) { output = vocabDictionary.generateRandom("hibye/greeting/intimate"); } //50% chance of using other persons name/title if (r.NextDouble() > 0.5f) { output += " " + q.respondingSpeaker.name(q.initiatingSpeaker); } //50% chance of explamation point. if its not formal if (r.NextDouble() > 0.5f && conversationalParamaters.registerType != ConversationalParamaters.RegisterType.formal_register) { output += "!"; } return(output); }
public String sense_discuss_giveFeelings(PairParamaters q, ConversationalParamaters conversationalParamaters, Opinion speakersOpinion) { String output = ""; String declaration = ""; //not actually verb, more like 'is good' 'are not good' String punctuation = "."; String constituent_one = ""; String constituent_two = ""; String rendered_reason = ""; String isAre = ""; //auxilliary verb just to distringuish plural and singular if (speakersOpinion._subject.GetType() == typeof(PhysicalEntity)) //specific entity -> singular { isAre = "is"; } else //type == { isAre = "are"; } int productionRule = conversationalParamaters.r.Next(1, 2); if (productionRule == 1) { constituent_one = "I "; if (speakersOpinion.likes) { declaration = " like "; } else { declaration = " don't like "; } constituent_two = renderConstituent(speakersOpinion._subject, false); } else //if productoin rule == 2 { //if talking about a type rather than a singular, render it in plural if (speakersOpinion._subject.GetType() == typeof(PhysicalEntity)) { constituent_one = renderConstituent(speakersOpinion._subject, false); } else { constituent_one = renderConstituent(speakersOpinion._subject, true); } if (speakersOpinion.likes) { declaration = isAre + " good "; } else //doesnt like { declaration = isAre + "n't good "; } } //will almost always explain why they have an opinion if (speakersOpinion.reason != null) { rendered_reason = " " + renderOpinionReason(speakersOpinion, q.initiatingSpeaker, q.respondingSpeaker); } /*ASSEMBLE*/ //reason can either come before or after the declaration. e.g. 'horses are cuddly. i love them' vs 'i love horses. they are cuddly' if (productionRule == 2) //I like horses because x { output = constituent_one + declaration + rendered_reason; } else //production rule == 1 //horses are great because x { output = constituent_one + declaration + constituent_two + rendered_reason; } return(formatOutput(output) + punctuation); }
public void newConversation(ConversationalParamaters paramaters) { conversation = new Conversation(worldManager.world, vocabDictionary, paramaters); //conversation.getOutput(); }