Exemplo n.º 1
0
    def __exists_word_after_want_to(df):
        try:
            idx_of_i = Nlp_util.get_idx_list_of_idiom("want to", df.word)[0]
            length_after_want_to = len(df.loc[idx_of_i + 2, :]) if len(df) >= idx_of_i + 3 else 0

            return length_after_want_to > 2
        except:
            logging.exception('')
            return False
Exemplo n.º 2
0
    def __alter_repeat_for_want_to(cls, repeat_df):
        i_idx = Nlp_util.get_idx_list_of_idiom("want to", repeat_df.word)[0]

        words_after_wanna = WordFormatter.Df2Str(repeat_df[i_idx + 2:])[1:]

        response_options = [
            [words_after_wanna, "That's what you wanna do"],
            ["So you'd be happy if you can " + words_after_wanna + "🤔"],
            [
                "So there is something makes you can't " + words_after_wanna +
                "😢"
            ], ["So now it's hard for you to " + words_after_wanna + "😓"]
        ]

        random_idx = randint(0, len(response_options) - 1)
        return response_options[random_idx]
Exemplo n.º 3
0
 def __has_dont_think_SV_sent(df):
     df_ex_adverb = df[~df.pos.isin(Nlp_util.pos_ADVERBs)].reset_index(
         drop=True)
     exists_i_dont_think = Df_util.anything_isin(["i do not think"],
                                                 df_ex_adverb["base_form"])
     if exists_i_dont_think:
         idx_of_dont_think = Nlp_util.get_idx_list_of_idiom(
             "i do not think", df_ex_adverb["base_form"])[0]
         if len(
                 RepeatResponseGenerator.get_sidx_of_not_basic_svo_sent(
                     df_ex_adverb.loc[idx_of_dont_think + 4:, :])) == 0:
             return True
         else:
             return False
     else:
         return False
Exemplo n.º 4
0
    def __alter_repeat_for_because_sent(df, repeat_text):
        if df["base_form"].iloc[0] in ["because", "since"]:
            repeat_text = "its " + repeat_text
            return [repeat_text]
        elif Df_util.anything_isin(
            ["because of"],
                df.loc[2:, "base_form"]) and not Df_util.anything_isin(
                    ["it is", "that is"], df.loc[:3, "base_form"]):
            because_of_idx = Nlp_util.get_idx_list_of_idiom(
                "because of", df["base_form"])[0]
            first_part = WordFormatter.Df2Str(df.loc[:because_of_idx - 1, :])
            last_part = "and its" + WordFormatter.Df2Str(
                df.loc[because_of_idx:, :])
            return [first_part, last_part]

        else:
            raise UnknownError
Exemplo n.º 5
0
    def __exists_want_to(cls, df):
        df_without_adverb = df[~df.pos.isin(Nlp_util.pos_ADVERBs)]

        noun_list = Nlp_util.make_noun_list(df)
        verb_list = Nlp_util.make_verb_list(df, type="basic")

        idx_of_i_wanna = Nlp_util.get_idx_list_of_idiom(
            "i want to", df_without_adverb.base_form)

        if len(idx_of_i_wanna) != 0 and len(
                df.loc[idx_of_i_wanna[0] + 2:, :]) > 1:
            if cls.__exists_word_after_want_to(
                    df) and Nlp_util.is_first_subject_in({"i"}, noun_list,
                                                         verb_list):
                return True
            else:
                return False
        else:
            return False
Exemplo n.º 6
0
    def __exists_word_after_want_to(df):
        idx_of_i = Nlp_util.get_idx_list_of_idiom("want to", df.word)[0]
        length_after_want_to = len(
            df.loc[idx_of_i + 2, :]) if len(df) >= idx_of_i + 3 else 0

        return length_after_want_to > 2