Skip to content

TheAlbatross279/Gustafo

Repository files navigation

#CSC 481: Knowledge Based System Chatbot aka Gustafo

Gustafo is a chatbot that helps answer programming questions in addition to having a great personality.

Gustafo relies on a knowledge resource from Stack Overflow and will help you find the answer to your programming questions by using magical question answering techniques and a little bit of NLP voodoo to process your question and help you find the answer you're looking for.

If you get bored of programming questions, Gustafo also doubles as a surrogate friend who will ask you how you're doing and pretend to listen to you.

Adding New States

Here is an example of a very simple greeting state:

from state import State

# All states must inherit from another state
class HelloState(State):

  # The recognize method takes in a POS tagged message and returns a confidence value that
  # the given message belongs in this state along with any information the respond method
  # would need to formulate a response.
  @staticmethod
  def recognize(self, msg):
    if msg[0][0] == 'Hello':
      return (1, {})
    else:
      return (0, {})

  # The respond method is called if the confidence value returned in the recognize method is
  # higher than any other valud stat. It takes in the context returned from the recognize method
  # and does any processing the state would like to do in response. If a string is returned, the
  # message is sent to the chat, if None is returned, nothing happens.
  @staticmethod
  def respond(self, context):
    # The nickname of the user who messaged the bot will always be available in the context
    # under the '_nick' key.
    return "Hello there, " + context['_nick'] + "!"

# Immediately after the state is defined it is registered
# with the bot. The register method takes in a boolean which determines whether this state can
# be used to initiate conversation with a user. This value defaults to False.
State.register(HelloState, True)

About

481 Knowledge Based System Chatbot Gustafo 2.0

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages