// Function to retrieve reply and format input to give illusion of a response
Function to retrieve reply and format input to give illusion of a response
// Function to retrieve reply and format input to give illusion of a response
func ReplyTo(input string) string {
    input = preprocess(input)
    for pattern, responses := range phrases {
        re := regexp.MustCompile(pattern)
        matches := re.FindStringSubmatch(input)
        if len(matches) > 0 {
            var fragment string
            if len(matches) > 1 {
                fragment = reflect(matches[1])
            }
            output := randChoice(responses)
            if strings.Contains(output, "%s") {
                output = fmt.Sprintf(output, fragment)
            }
            return output
        }
    }
    return randChoice(conversationFail)
}
func ReplyTo ( input string ) string { input = preprocess ( input ) for pattern , responses := range phrases { re := regexp . MustCompile ( pattern ) matches := re . FindStringSubmatch ( input ) if len ( matches ) > 0 { var fragment string if len ( matches ) > 1 { fragment = reflect ( matches [ 1 ] ) } output := randChoice ( responses ) if strings . Contains ( output , " " ) { output = fmt . Sprintf ( output , fragment ) } return output } } return randChoice ( conversationFail ) }
Function to retrieve reply and format input to give illusion of a response
Function to retrieve reply and format input to give illusion of a response
// Passes input into preprocess function // Function then sends back input // The output becomes a random choice of responses from the selection of responses // If user enter "I don't know if you are a bot" the program will search to see if it has responses for "I don't" or any other key word // Once a keyword is found it then randomizes a response from inside the keywords selection (Could have only 1 response, could have 10) // Merges output and input to give illusion of intellegence // If %s is found it  // Returns the output to the 'elizaInterface' function // If a response cannot be found a random conversation starter is selected