| def theme_analyzer(review): | |
| response = openai.completions.create( | |
| model="text-davinci-003", # You can choose the model version | |
| prompt=f"""Analyze the following review: \"{review}\". | |
| Is it a complain, a experience-based review or a question. | |
| Answer with a single word: | |
| - Complain | |
| - Experience | |
| - Question""", | |
| max_tokens=60 | |
| ) | |
| df_short["Theme"] = df_short.apply(lambda x:theme_analyzer(x["Text"]), axis=1) | |
| df_short |