Spaces:
Sleeping
Sleeping
AlzbetaStrompova
commited on
Commit
•
cbb6c91
1
Parent(s):
92a6f43
change css
Browse files- app.py +4 -14
- style.css +22 -0
- website_script.py +0 -2
app.py
CHANGED
@@ -16,27 +16,17 @@ def ner(text, file_names):
|
|
16 |
result = run(tokenizer, model, gazetteers_for_matching, text, file_names)
|
17 |
return {"text": text, "entities": result}
|
18 |
|
19 |
-
with gr.Blocks(css="
|
20 |
-
# with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
21 |
-
|
22 |
gr.Interface(ner,
|
23 |
gr.Textbox(lines=10, placeholder="Enter sentence here..."),
|
24 |
-
gr.HighlightedText(show_legend=True, color_map={"PER": "red", "ORG": "green", "LOC": "blue"}),
|
|
|
25 |
examples=examples,
|
26 |
title="NerROB-czech",
|
27 |
description="This is an implementation of a Named Entity Recognition model for the Czech language using gazetteers.",
|
28 |
allow_flagging="never",
|
29 |
-
additional_inputs=gr.File(label="Upload a JSON file", file_count="multiple", file_types=[".json"]),
|
30 |
-
additional_inputs_accordion=gr.Accordion(label="Additional Gazetters", open=False)
|
31 |
)
|
32 |
|
33 |
-
# gr.Interface(load_gazetters,
|
34 |
-
# gr.File(label="Upload a JSON file", file_count="multiple", file_types=[".json"]),
|
35 |
-
# None,
|
36 |
-
# allow_flagging="never",
|
37 |
-
# description="Here you can upload your own gazetteers.", )
|
38 |
-
# btn = gr.Button(value="Change Language")
|
39 |
-
# btn.click(reload)
|
40 |
-
|
41 |
if __name__ == "__main__":
|
42 |
demo.launch()
|
|
|
16 |
result = run(tokenizer, model, gazetteers_for_matching, text, file_names)
|
17 |
return {"text": text, "entities": result}
|
18 |
|
19 |
+
with gr.Blocks(css="./style.css", theme=gr.themes.Default(primary_hue="blue", secondary_hue="sky")) as demo:
|
|
|
|
|
20 |
gr.Interface(ner,
|
21 |
gr.Textbox(lines=10, placeholder="Enter sentence here..."),
|
22 |
+
# gr.HighlightedText(show_legend=True, color_map={"PER": "red", "ORG": "green", "LOC": "blue"}),
|
23 |
+
gr.HighlightedText(show_legend=True, color_map={"PER": "#660606", "ORG": "#066618", "LOC": "#061966"}, elem_id="highlighted_text"),
|
24 |
examples=examples,
|
25 |
title="NerROB-czech",
|
26 |
description="This is an implementation of a Named Entity Recognition model for the Czech language using gazetteers.",
|
27 |
allow_flagging="never",
|
28 |
+
additional_inputs=gr.File(label="Upload a JSON file containing gazetteers", file_count="multiple", file_types=[".json"]),
|
|
|
29 |
)
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
if __name__ == "__main__":
|
32 |
demo.launch()
|
style.css
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
footer {
|
2 |
+
display: none !important;
|
3 |
+
}
|
4 |
+
|
5 |
+
.container .svelte-ju12zg {
|
6 |
+
color: white;
|
7 |
+
}
|
8 |
+
|
9 |
+
.text.svelte-ju12zg {
|
10 |
+
padding: 0;
|
11 |
+
margin: 0;
|
12 |
+
}
|
13 |
+
|
14 |
+
.textspan.svelte-ju12zg.hl {
|
15 |
+
margin: 0;
|
16 |
+
padding: 0;
|
17 |
+
}
|
18 |
+
|
19 |
+
.textspan.svelte-ju12zg.no-cat {
|
20 |
+
margin: 0;
|
21 |
+
padding: 0;
|
22 |
+
}
|
website_script.py
CHANGED
@@ -51,8 +51,6 @@ def run(tokenizer, model, gazetteers, text, file_names=None):
|
|
51 |
tokenized_inputs = tokenizer(
|
52 |
text, truncation=True, is_split_into_words=False, return_offsets_mapping=True
|
53 |
)
|
54 |
-
for i in gazetteers_for_matching:
|
55 |
-
print(len(i))
|
56 |
matches = gazetteer_matching(text, gazetteers_for_matching)
|
57 |
new_g = []
|
58 |
word_ids = tokenized_inputs.word_ids()
|
|
|
51 |
tokenized_inputs = tokenizer(
|
52 |
text, truncation=True, is_split_into_words=False, return_offsets_mapping=True
|
53 |
)
|
|
|
|
|
54 |
matches = gazetteer_matching(text, gazetteers_for_matching)
|
55 |
new_g = []
|
56 |
word_ids = tokenized_inputs.word_ids()
|