davda54
commited on
Commit
·
ada9d7c
1
Parent(s):
ef9462a
initial test
Browse files
app.py
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
|
4 |
+
description = """
|
5 |
+
<div style="text-align: center;">
|
6 |
+
<h1>Norsk UD (Bokmål og Nynorsk)</h1>
|
7 |
+
<p align="center">
|
8 |
+
<img src="https://huggingface.co/ltg/norbert3-base/resolve/main/norbert.png" width=6.75%>
|
9 |
+
</p><p></p>
|
10 |
+
</div>
|
11 |
+
"""
|
12 |
+
|
13 |
+
text = """1 President President PROPN NNP Number=Sing 5 nsubj 5:nsubj _
|
14 |
+
2 Bush Bush PROPN NNP Number=Sing 1 flat 1:flat _
|
15 |
+
3 on on ADP IN _ 4 case 4:case _
|
16 |
+
4 Tuesday Tuesday PROPN NNP Number=Sing 5 obl 5:obl:on _
|
17 |
+
5 nominated nominate VERB VBD Mood=Ind|Number=Sing|Person=3|Tense=Past|VerbForm=Fin 0 root 0:root _
|
18 |
+
6 two two NUM CD NumType=Card 7 nummod 7:nummod _
|
19 |
+
7 individuals individual NOUN NNS Number=Plur 5 obj 5:obj _
|
20 |
+
8 to to PART TO _ 9 mark 9:mark _
|
21 |
+
9 replace replace VERB VB VerbForm=Inf 5 advcl 5:advcl:to _
|
22 |
+
10 retiring retire VERB VBG VerbForm=Ger 11 amod 11:amod _
|
23 |
+
11 jurists jurist NOUN NNS Number=Plur 9 obj 9:obj _
|
24 |
+
12 on on ADP IN _ 14 case 14:case _
|
25 |
+
13 federal federal ADJ JJ Degree=Pos 14 amod 14:amod _
|
26 |
+
14 courts court NOUN NNS Number=Plur 11 nmod 11:nmod:on _
|
27 |
+
15 in in ADP IN _ 18 case 18:case _
|
28 |
+
16 the the DET DT Definite=Def|PronType=Art 18 det 18:det _
|
29 |
+
17 Washington Washington PROPN NNP Number=Sing 18 compound 18:compound _
|
30 |
+
18 area area NOUN NN Number=Sing 14 nmod 14:nmod:in SpaceAfter=No
|
31 |
+
19 . . PUNCT . _ 5 punct 5:punct _"""
|
32 |
+
|
33 |
+
forms = [
|
34 |
+
line.split("\t")[1]
|
35 |
+
for line in text.split("\n")
|
36 |
+
if line and not line.startswith("#")
|
37 |
+
]
|
38 |
+
|
39 |
+
lemmas = [
|
40 |
+
line.split("\t")[2]
|
41 |
+
for line in text.split("\n")
|
42 |
+
if line and not line.startswith("#")
|
43 |
+
]
|
44 |
+
|
45 |
+
upos = [
|
46 |
+
line.split("\t")[3]
|
47 |
+
for line in text.split("\n")
|
48 |
+
if line and not line.startswith("#")
|
49 |
+
]
|
50 |
+
|
51 |
+
xpos = [
|
52 |
+
line.split("\t")[4]
|
53 |
+
for line in text.split("\n")
|
54 |
+
if line and not line.startswith("#")
|
55 |
+
]
|
56 |
+
|
57 |
+
feats = [
|
58 |
+
line.split("\t")[5]
|
59 |
+
for line in text.split("\n")
|
60 |
+
if line and not line.startswith("#")
|
61 |
+
]
|
62 |
+
|
63 |
+
metadata = [
|
64 |
+
line.split("\t")[9]
|
65 |
+
for line in text.split("\n")
|
66 |
+
if line and not line.startswith("#")
|
67 |
+
]
|
68 |
+
|
69 |
+
edges = [
|
70 |
+
int(line.split("\t")[6])
|
71 |
+
for line in text.split("\n")
|
72 |
+
if line and not line.startswith("#")
|
73 |
+
]
|
74 |
+
|
75 |
+
edge_labels = [
|
76 |
+
line.split("\t")[7]
|
77 |
+
for line in text.split("\n")
|
78 |
+
if line and not line.startswith("#")
|
79 |
+
]
|
80 |
+
|
81 |
+
|
82 |
+
|
83 |
+
with gr.Blocks(theme='sudeepshouche/minimalist') as demo:
|
84 |
+
gr.HTML(description)
|
85 |
+
|
86 |
+
gr.Dataframe([forms], interactive=False, type="array")
|
87 |
+
|
88 |
+
with gr.Accordion("Lemmas", open=True):
|
89 |
+
gr.Dataframe([lemmas], interactive=False, type="array")
|
90 |
+
|
91 |
+
with gr.Accordion("UPOS", open=True):
|
92 |
+
gr.Dataframe([upos], interactive=False, type="array")
|
93 |
+
|
94 |
+
with gr.Accordion("XPOS", open=True):
|
95 |
+
gr.Dataframe([xpos], interactive=False, type="array")
|
96 |
+
|
97 |
+
with gr.Accordion("UFeats", open=True):
|
98 |
+
feats = [feat.split("|") for feat in feats]
|
99 |
+
max_len = max([len(feat) for feat in feats])
|
100 |
+
feats = [feat + [""] * (max_len - len(feat)) for feat in feats]
|
101 |
+
feats = list(zip(*feats))
|
102 |
+
gr.Dataframe([feats], interactive=False, type="array")
|
103 |
+
|
104 |
+
demo.launch()
|