tannu038 commited on
Commit
be98154
·
verified ·
1 Parent(s): 1733f74

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py CHANGED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import re
3
+
4
+ def extract_study_timeline(text):
5
+ """Extracts Screening, Treatment, and Follow-up durations from study timeline text."""
6
+ screening = re.search(r'Screening\s*(\d+)\s*weeks?', text)
7
+ treatment = re.search(r'Treatment\s*(\d+)\s*weeks?', text)
8
+ follow_up = re.search(r'Follow[-\s]*up\s*(\d+)\s*weeks?', text)
9
+
10
+ timeline = {
11
+ "Screening": int(screening.group(1)) if screening else None,
12
+ "Treatment": int(treatment.group(1)) if treatment else None,
13
+ "Follow-Up": int(follow_up.group(1)) if follow_up else None
14
+ }
15
+
16
+ return timeline
17
+
18
+ # Create a Gradio Interface
19
+ demo = gr.Interface(
20
+ fn=extract_study_timeline,
21
+ inputs=gr.Textbox(lines=3, placeholder="Enter study timeline text..."),
22
+ outputs="json",
23
+ title="Study Timeline Extraction",
24
+ description="Enter a study timeline description, and the model will extract Screening, Treatment, and Follow-Up durations.",
25
+ )
26
+
27
+ # Launch the Gradio App
28
+ demo.launch()