-
Notifications
You must be signed in to change notification settings - Fork 0
/
pages.py
95 lines (71 loc) · 2.95 KB
/
pages.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import sys
import gradio as gr
import spacy
import yaml
from spacy_functions import (named_entity_recognition, parts_of_speech,
tokenizer)
with open("config.yaml", "r") as cfg:
CONFIG = yaml.load(cfg, yaml.SafeLoader)
with gr.Blocks() as Tokenizer:
with gr.Row():
with gr.Column():
gr.Markdown("__Enter your Text__:")
with gr.Row():
text_input = gr.Textbox()
with gr.Row():
with gr.Column():
submit = gr.Button("Tokenize")
with gr.Column():
gr.ClearButton([text_input])
with gr.Column():
gr.Markdown("__Tokens Found__:")
tokens_list = gr.JSON()
submit.click(tokenizer, [text_input], tokens_list)
with gr.Blocks() as PartsOfSpeech:
with gr.Row():
with gr.Column():
gr.Markdown("__Enter your Text__:")
with gr.Row():
text_input = gr.Textbox()
gr.Markdown("__Choose Language Model__:")
with gr.Row():
model = gr.Radio(CONFIG['allowed_models'], value=CONFIG['allowed_models'][0])
with gr.Row():
with gr.Column():
submit = gr.Button("Tag Parts of Speech")
with gr.Column():
gr.ClearButton([text_input])
with gr.Column():
gr.Markdown("__Tokens Found__")
tokens_list = gr.DataFrame()
submit.click(parts_of_speech, [text_input, model], tokens_list)
with gr.Blocks() as NamedEntityRecognition:
with gr.Row():
with gr.Column():
gr.Markdown("__Enter your Text__:")
with gr.Row():
text_input = gr.Textbox()
gr.Markdown("__Choose Language Model__:")
with gr.Row():
model = gr.Radio(CONFIG['allowed_models'], value=CONFIG['allowed_models'][0])
gr.Markdown("__Choose Entities to Hide__:")
with gr.Row():
filters = gr.CheckboxGroup(CONFIG['entities'])
with gr.Row():
with gr.Column():
submit = gr.Button("Recognize Entities")
with gr.Column():
gr.ClearButton([text_input, filters])
with gr.Column():
gr.Markdown("__Entities Found__:")
entity_list = gr.DataFrame()
submit.click(named_entity_recognition, [text_input, model, filters], entity_list)
with gr.Blocks() as About:
gr.Markdown("## About")
gr.Markdown("* Author: [arnabdhar](https://hf.co/arnabdhar)")
gr.Markdown("* Author's GitHub: [arnabd64](https://github.com/arnabd64)")
gr.Markdown("## Package versions")
gr.Markdown(f"* Python: {sys.version}")
gr.Markdown(f"* Spacy: {spacy.__version__}")
gr.Markdown(f"* Gradio: {gr.__version__}")
interfaces = [Tokenizer, PartsOfSpeech, NamedEntityRecognition, About]