示例#1
0
    def can_process(self, statement):
        self.normalized = normalize(str(statement))

        if "debug" in self.normalized:
            return True
        else:
            return False
示例#2
0
 def can_process(self, statement):
     self.normalized = normalize(str(statement).lower())
     if (('akinator' in self.normalized)
             and akinator_exists) and ('not' not in self.normalized):
         return True
     else:
         return self.chatbot.globals['akinator']['enabled']
示例#3
0
 def can_process(self, statement):
     self.normalized = normalize(str(statement).lower())
     if (("akinator" in self.normalized)
             and akinator_exists) and ("not" not in self.normalized):
         return True
     else:
         return self.chatbot.globals["akinator"]["enabled"]
示例#4
0
 def can_process(self, statement):
     self.normalized = normalize(str(statement))
     self.token = pos_tag(self.normalized)
     if str(statement).strip().lower().startswith("are"):
         return True
     else:
         return False
示例#5
0
 def can_process(self, statement):
     self.normalized = tuple(x.lower() for x in normalize(str(statement)))
     if len(self.normalized) > 1 and self.normalized[0] in ("let",
                                                            "assume"):
         return True
     else:
         return False
示例#6
0
    def can_process(self, statement):
        self.normalized = normalize(str(statement).lower())

        if "reader" in self.normalized:
            return True
        else:
            return False
示例#7
0
    def can_process(self, statement):
        self.normalized = normalize(str(statement))

        if 'because' in self.normalized:
            return True
        else:
            return False
示例#8
0
 def can_process(self, statement):
     self.normalized = normalize(str(statement))
     if any_in(["covid", "covid19", "covid-19", "corona", "coronavirus"],
               self.normalized):
         return True
     else:
         return False
示例#9
0
 def can_process(self, statement):
     self.normalized = normalize(str(statement))
     self.token = pos_tag(self.normalized)
     if 'feel' in self.normalized:
         return True
     else:
         return False
示例#10
0
 def can_process(self, statement):
     self.normalized = normalize(str(statement))
     self.intersect = set(self.normalized).intersection(set(TIME))
     if self.intersect:
         return True
     else:
         return False
示例#11
0
 def can_process(self, statement):
     self.tokenized = spac_token(statement, chatbot=self.chatbot)
     self.normalized = normalize(str(statement))
     for i in self.tokenized:
         if i.tag_ == 'WRB':
             return True
     else:
         return False
示例#12
0
 def can_process(self, statement):
     self.normalized = normalize(str(statement))
     self.dis = None
     for i in self.normalized:
         if i.startswith("dis"):
             self.dis = i
             return True
     else:
         return False
示例#13
0
 def can_process(self, statement):
     self.normalized = normalize(str(statement).lower())
     text = word_tokenize(str(statement))
     self.tagged = nltk.pos_tag(text)
     for k in self.tagged:
         if k[1].startswith("MD"):
             return True
     else:
         return False
示例#14
0
 def can_process(self, statement):
     self.normalized = normalize(str(statement))
     if self.chatbot.globals["history"]["total"][-1] == 0:
         return False
     if "what" in self.normalized:
         try:
             word_before_what = self.normalized[
                 self.normalized.index("what") - 1]
         except IndexError:
             return False
         self.last_word = normalize(
             str(self.chatbot.globals["history"]["total"][-1]))
         if word_before_what in self.last_word:
             self.last_word_idx = self.last_word.index(word_before_what)
             return True
         else:
             return False
     else:
         return False
示例#15
0
 def can_process(self, statement):
     self.normalized = normalize(str(statement))
     more_words = len(self.normalized) > 3
     logging.info("ImitatorSensei: userhistory {}, history: {}".format(
         self.chatbot.globals['history']['user'],
         self.chatbot.globals['history']['total']))
     if self.chatbot.globals['history']['user'][-1] and self.chatbot.globals[
             'history']['total'][-1] and more_words:
         return True
     else:
         return False
示例#16
0
 def can_process(self, statement):
     normalized = normalize(str(statement))
     if (("think" in normalized) or
         ("ask" in normalized)) and ("me" in normalized):
         return True
     else:
         if self.chatbot.lp.similarity(str(statement),
                                       "What can you do?") > 0.9:
             return True
         else:
             return False
示例#17
0
 def can_process(self, statement):
     normalized = normalize(str(statement))
     if (('think' in normalized) or
         ('ask' in normalized)) and ('me' in normalized):
         return True
     else:
         if self.chatbot.lp.similarity(str(statement),
                                       'What can you do?') > 0.9:
             return True
         else:
             return False
示例#18
0
 def can_process(self, statement):
     self.normalized = normalize(str(statement).lower())
     if ('yes' in self.normalized) or ('no' in self.normalized) or ('true' in self.normalized) or \
             ('false' in self.normalized):
         boolean = True
     else:
         boolean = False
     if self.chatbot.globals['trivia_answer'] and boolean:
         return True
     else:
         self.chatbot.globals['trivia_answer'] = None
         return False
示例#19
0
 def can_process(self, statement):
     self.normalized = normalize(str(statement))
     if len(self.normalized) >= 2:
         for i in range(0, len(self.normalized) - 2):
             if (self.normalized[i] == "see") and (self.normalized[i + 1]
                                                   == "you"):
                 return True
     self.intersect = set(self.normalized).intersection(set(BYE))
     if self.intersect and not ("can" in self.normalized):
         return True
     else:
         return False
示例#20
0
 def can_process(self, statement):
     self.normalized = normalize(str(statement))
     more_words = len(self.normalized) > 3
     logging.info("ImitatorSensei: userhistory {}, history: {}".format(
         self.chatbot.globals["history"]["user"],
         self.chatbot.globals["history"]["total"],
     ))
     if (self.chatbot.globals["history"]["user"][-1]
             and self.chatbot.globals["history"]["total"][-1]
             and more_words):
         return True
     else:
         return False
示例#21
0
 def can_process(self, statement):
     self.normalized = normalize(str(statement).lower())
     if (("yes" in self.normalized) or ("no" in self.normalized)
             or ("true" in self.normalized)
             or ("false" in self.normalized)):
         boolean = True
     else:
         boolean = False
     if self.chatbot.globals["trivia_answer"] and boolean:
         return True
     else:
         self.chatbot.globals["trivia_answer"] = None
         return False
示例#22
0
 def can_process(self, statement):
     normalized = normalize(str(statement).lower())
     if (("tell" in normalized) or ("say" in normalized) or
         ("crack" in normalized)) and ("joke" in normalized):
         return True
     elif (len(normalized) == 1) and (self.chatbot.lp.similarity(
             "joke",
             str(statement).lower()) >= 0.9):
         return True
     elif "joke" in normalized:
         return True
     else:
         return False
示例#23
0
    def can_process(self, statement):
        self.normalized = normalize(str(statement))

        if len(self.normalized) == 2:
            return True
        elif len(self.normalized) == 3:
            self.tokenized = pos_tag(self.normalized)
            if self.tokenized[2][1] == ".":
                return True
            else:
                return False
        else:
            return False
示例#24
0
 def can_process(self, statement):
     normalized = normalize(str(statement).lower())
     if (('tell' in normalized) or ('say' in normalized) or
         ('crack' in normalized)) and ('joke' in normalized):
         return True
     elif (len(normalized) == 1) and (self.chatbot.lp.similarity(
             "joke",
             str(statement).lower()) >= 0.9):
         return True
     elif 'joke' in normalized:
         return True
     else:
         return False
示例#25
0
 def can_process(self, statement):
     self.normalized = normalize(str(statement).lower())
     if self.chatbot.globals["akinator"]["enabled"]:
         return False
     elif ('yes' in self.normalized) or ('yea' in self.normalized) or (
             'no' in self.normalized) or ('true' in self.normalized) or (
                 'false' in self.normalized):
         if ('yes' in self.normalized) or ('yea' in self.normalized) or (
                 'true' in self.normalized):
             self.bool = True
         else:
             self.bool = False
         return True
     else:
         return False
示例#26
0
 def can_process(self, statement):
     self.normalized = normalize(str(statement).lower())
     if self.chatbot.globals["akinator"]["enabled"]:
         return False
     elif (("yes" in self.normalized) or ("yea" in self.normalized)
           or ("no" in self.normalized) or ("true" in self.normalized)
           or ("false" in self.normalized)):
         if (("yes" in self.normalized) or ("yea" in self.normalized)
                 or ("true" in self.normalized)):
             self.bool = True
         else:
             self.bool = False
         return True
     else:
         return False
示例#27
0
 def can_process(self, statement):
     self.normalized = normalize(str(statement).lower())
     if ('hangman' in self.normalized) and ('not' not in self.normalized):
         return True
     else:
         return self.chatbot.globals['hangman']['enabled']
示例#28
0
    def process(self, statement, additional_response_selection_parameters=None):
        # add emotion output
        adj = None
        verb = None
        confidence = 0.90
        last_response = self.chatbot.globals['history']['total'][-1]
        emotion = Emotion.neutral
        self.last_normalized = normalize(str(last_response))
        if last_response:
            self.tagged_last = pos_tag(self.last_normalized)
            self.tagged_now = pos_tag(self.normalized)
            sm = SequenceMatcher(None, self.tagged_last, self.tagged_now)
            for i in self.tagged_now:
                if i[1] == 'JJ':
                    adj = i[0]
                elif i[1] == 'VB' and (not i[0] == 'be'):
                    verb = i[0]
            if sm.ratio() > 0.5:
                if adj:
                    response = 'Well, Its not a good reason for me to be {}'.format(
                        adj)
                else:
                    response = 'Well, its not a good reason you have told me 😭'
            else:
                if verb:
                    if verb in ['think', 'breath', 'eat', 'hear', 'feel', 'taste']:
                        response = 'Robots are computer devices. I cannot {}'.format(
                            verb.replace('ing', ''))
                        emotion = Emotion.cry
                    else:
                        response = "I may not be able to {}. " \
                                   "This might not be my builtin quality".format(
                                       verb.replace('ing', ''))
                        emotion = Emotion.cry_overflow
                else:
                    if adj:
                        sia = SentimentIntensityAnalyzer()
                        sia_scores = sia.polarity_scores(str(statement))
                        if sia_scores['neu'] == 1:
                            response = 'Ok! Thanks for your feedback'
                            emotion = Emotion.positive
                        elif sia_scores['pos'] > sia_scores['neg']:
                            response = 'I will try to be more {} in future'.format(
                                adj)
                            emotion = Emotion.adorable
                        else:
                            response = 'I will never try to be {}.'.format(adj)
                            emotion = Emotion.angry
                    else:
                        response = 'Are you sure this is the reason? I would love to report to my creator.'
                        self.chatbot.report = True
                        emotion = Emotion.non_expressive_left

        else:
            response = 'Well, I cannot think of saying something. Your conversation began with reason. 🤯'
            emotion = Emotion.angry

        selected_statement = SugaroidStatement(response, chatbot=True)
        selected_statement.confidence = confidence
        selected_statement.emotion = emotion
        selected_statement.adapter = None
        return selected_statement
示例#29
0
    def process(self,
                statement,
                additional_response_selection_parameters=None):
        bool_yes = self.bool
        emotion = Emotion.neutral
        if self.chatbot.report:
            if bool_yes:
                response = "Sure, I would connect to the Developer to report this issue right away"
                self.chatbot.report = False
                # TODO: Add report function
                # report_here() FIXME
            else:
                response = "Ok, I will not report it."
                self.chatbot.report = False
            confidence = 1.0
        elif self.chatbot.globals["trivia_answer"]:
            if self.chatbot.globals["trivia_answer"] == self.bool:
                response = "Exactly! You are right"
                reset_reverse(self)
            else:
                response = "Nope, You got it wrong. The correct answer was {}".format(
                    self.chatbot.globals["trivia_answer"])
                reset_reverse(self)
            self.chatbot.globals["trivia_answer"] = None
            confidence = 1.1
        else:
            if self.chatbot.globals["history"]["total"][-1] == 0:
                if bool_yes:
                    response = "I shall annoy you. A big NO"
                else:
                    response = "I would rather have fun, YES ?"
            else:
                md = False
                vb = False
                nn = False
                self.last_normalized = normalize(
                    str(self.chatbot.globals["history"]["total"][-1]))
                self.tagged = nltk.pos_tag(self.last_normalized)
                iteration = 0
                for j in self.tagged:
                    if j[1].startswith("MD"):
                        md = True
                    elif (j[1].startswith("VB")) and (not j[0] == "be"):
                        vb = True
                        verb = j[0]
                    elif j[1].startswith("NN"):
                        if not nn:
                            nn_index = iteration
                        nn = True
                        noun = j[0]
                    iteration += 1

                if md:
                    if nn:
                        some_nouns = " ".join(self.last_normalized[nn_index:])
                    if bool_yes:
                        if nn:
                            response = "Ok, here comes your {} 😝😝".format(
                                some_nouns)
                        elif vb:
                            response = "You should {}".format(
                                verb.replace("ing", ""))
                        else:
                            response = "I will keep thinking 🚀"
                    else:
                        if nn:
                            response = "Ok, I will have the {}".format(
                                some_nouns)
                        elif vb:
                            response = "You shouldn't {} then".format(
                                verb.replace("ing", ""))
                        else:
                            response = "Okay!"
                else:
                    if bool_yes:
                        response = "Why is this 'yes' here? I couldn't find the question. Anyway, I agree with you"
                    else:
                        response = "No? for what?."
                        emotion = Emotion.angry

            confidence = 0.95
        selected_statement = SugaroidStatement(response, chatbot=True)
        selected_statement.confidence = confidence

        selected_statement.emotion = emotion

        return selected_statement
示例#30
0
 def can_process(self, statement):
     normalized = normalize(str(statement))
     if "ok" in normalized or "okay" in normalized:
         return True
     else:
         return False