tannu038 commited on
Commit
4cc8fe3
·
verified ·
1 Parent(s): 31d46f7

Create app.py

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