Guiyom commited on
Commit
9a5dc5f
·
1 Parent(s): af8fac4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -22
app.py CHANGED
@@ -89,31 +89,22 @@ with gr.Blocks() as demo:
89
  clear = gr.Button("Clear", visible = False)
90
 
91
  def uploaddetailsfromreport(report):
92
- # Extract title of the focus group
93
- title = re.search(r'title is:\n(.+)', report).group(1)
94
 
95
- # Extract questions
96
- questions = re.findall(r'Question (\d+): (.+)', report)
97
 
98
- # Extract focus group profiles and participant answers
99
- profiles = re.findall(r'// Profile (\d+) //\n(.*?)Participants answers:', report, re.DOTALL)
100
- participants = []
101
- for profile in profiles:
102
- profile_id = profile[0]
103
- participant_answers = re.findall(r'Profile {} answer to question (\d+)\n(.+)'.format(profile_id), profile[1])
104
- participants.append(participant_answers)
105
 
106
- # Format the extracted values
107
- output = []
108
- output.append(title)
109
- for question in questions:
110
- output.append("Question {}: {}".format(question[0], question[1]))
111
- for i, participant in enumerate(participants, 1):
112
- output.append("// Profile {} //".format(i))
113
- for answer in participant:
114
- output.append("Profile {} answer to question {}: {}".format(i, answer[0], answer[1].strip()))
115
-
116
- return output[0], output[1], output[2], output[3], output[4], output[5], output[6], output[7], output[8], output[9], output[10], output[11], output[12], output[13], output[14], output[15], output[16], output[17], output[18], output[19], output[20], output[21], output[22], output[23]
117
 
118
  def checkapiinput(apikey):
119
  if apikey != "" and apikey is not None and len(apikey) >=25 and len(apikey) <= 130:
 
89
  clear = gr.Button("Clear", visible = False)
90
 
91
  def uploaddetailsfromreport(report):
92
+ # Extract title
93
+ title = re.search(r'which title is:\n(.+)\n', report).group(1)
94
 
95
+ # Extract questions from summary report
96
+ questions = re.findall(r'Question \d: (.+)', report)[:3]
97
 
98
+ # Extract participant profiles and answers
99
+ participant_profiles = re.findall(r'// Profile (\d+) //\n(.+?)={10}', report, re.DOTALL)
100
+ participant_answers = re.findall(r'Participant answers:\n(.+?)\-{100}', report, re.DOTALL)
 
 
 
 
101
 
102
+ # Combine all the extracted values
103
+ output = [title] + questions
104
+ for profile, answer in zip(participant_profiles, participant_answers):
105
+ output.extend(profile)
106
+ output.extend(answer)
107
+ return output[0], output[1], output[2], output[3], output[5], output[8], output[11], output[14], output[17], output[20], output[23], output[26], output[29], output[32], output[6], output[9], output[12], output[15], output[18], output[21], output[24], output[27], output[30], output[33]
 
 
 
 
 
108
 
109
  def checkapiinput(apikey):
110
  if apikey != "" and apikey is not None and len(apikey) >=25 and len(apikey) <= 130: