-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
52 lines (31 loc) · 1.25 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from chatgpt import ChatGPT
from dataframe import CreateDataFrame
from tkinter import *
import re
chat_gpt = ChatGPT()
response_two, response_three = chat_gpt.assistant_response()
df = chat_gpt.df_instance.df
#### this should be a function ####
# regular expression pattern to match numbered sentences
pattern = re.compile(r'(\d+\..+?)(?=\n\d+\.|\n\n|$)', re.DOTALL)
# use re.findall() to find all occurrences of the pattern
numbered_sentences = re.findall(pattern, response_two)
response_two_list = []
# if you want to print each numbered sentence
for sentence in numbered_sentences:
response_two_list.append(sentence)
max_length = max(len(response_two_list), len(df))
response_two_list += [None] * (max_length - len(response_two_list))
df['Answer 1'] = response_two_list
#### this should be a function ####
pattern = re.compile(r'(\d+\..+?)(?=\n\d+\.|\n\n|$)', re.DOTALL)
numbered_sentences = re.findall(pattern, response_three)
response_three_list = []
for sentence in numbered_sentences:
response_three_list.append(sentence)
max_length = max(len(response_three_list), len(df))
response_three_list += [None] * (max_length - len(response_three_list))
df['Answer 2'] = response_three_list
####
to_excel = CreateDataFrame()
to_excel.convert_to_xlsx(df)