Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import re
|
3 |
+
title="Information Extraction"
|
4 |
+
|
5 |
+
def match(pattern,text):
|
6 |
+
match_text=re.findall(pattern,text)
|
7 |
+
if match_text:
|
8 |
+
return match_text[0]
|
9 |
+
|
10 |
+
def extractInformation(text):
|
11 |
+
age=match("age (\d)",text)
|
12 |
+
name=match('Born(.*)\n',text)
|
13 |
+
|
14 |
+
return{
|
15 |
+
'Age':int(age),
|
16 |
+
'Full Name':name.strip()
|
17 |
+
}
|
18 |
+
|
19 |
+
def infoExtract(input):
|
20 |
+
out=extractInformation(input)
|
21 |
+
return out
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
|
26 |
+
interface=gr.Interface(fn=infoExtract,inputs='text',outputs='text',title=title)
|
27 |
+
interface.launch(inline=False)
|