Spaces:
Runtime error
Runtime error
mwitiderrick
commited on
Commit
·
68931bd
1
Parent(s):
0363976
Update app.py
Browse files
app.py
CHANGED
@@ -30,7 +30,30 @@ def run_pipeline(text):
|
|
30 |
|
31 |
dense_output = dense_qa_pipeline(text)
|
32 |
for item in dict(dense_output)['predictions'][0]:
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
dense_output = {"text": text, "entities": dense_entities}
|
35 |
|
36 |
dense_end = time.perf_counter()
|
@@ -40,7 +63,29 @@ def run_pipeline(text):
|
|
40 |
|
41 |
sparse_output = sparse_qa_pipeline(text)
|
42 |
for item in dict(sparse_output)['predictions'][0]:
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
sparse_output = {"text": text, "entities": sparse_entities}
|
46 |
|
|
|
30 |
|
31 |
dense_output = dense_qa_pipeline(text)
|
32 |
for item in dict(dense_output)['predictions'][0]:
|
33 |
+
dictionary = dict(item)
|
34 |
+
entity = dictionary['entity']
|
35 |
+
|
36 |
+
if entity == "LABEL_0":
|
37 |
+
value = "O"
|
38 |
+
elif entity == "LABEL_1":
|
39 |
+
value = "B-PER"
|
40 |
+
elif entity == "LABEL_2":
|
41 |
+
value = "I-PER"
|
42 |
+
elif entity == "LABEL_3":
|
43 |
+
value = "-ORG"
|
44 |
+
elif entity == "LABEL_4":
|
45 |
+
value = "I-ORG"
|
46 |
+
elif entity == "LABEL_5":
|
47 |
+
value = "B-LOC"
|
48 |
+
elif entity == "LABEL_6":
|
49 |
+
value = "I-LOC"
|
50 |
+
elif entity == "LABEL_7":
|
51 |
+
value = "B-MISC"
|
52 |
+
else:
|
53 |
+
value = "I-MISC"
|
54 |
+
dictionary['entity'] = value
|
55 |
+
dense_entities.append(dictionary)
|
56 |
+
|
57 |
dense_output = {"text": text, "entities": dense_entities}
|
58 |
|
59 |
dense_end = time.perf_counter()
|
|
|
63 |
|
64 |
sparse_output = sparse_qa_pipeline(text)
|
65 |
for item in dict(sparse_output)['predictions'][0]:
|
66 |
+
sparse_dictionary = dict(item)
|
67 |
+
entity = dictionary['entity']
|
68 |
+
|
69 |
+
if entity == "LABEL_0":
|
70 |
+
value = "O"
|
71 |
+
elif entity == "LABEL_1":
|
72 |
+
value = "B-PER"
|
73 |
+
elif entity == "LABEL_2":
|
74 |
+
value = "I-PER"
|
75 |
+
elif entity == "LABEL_3":
|
76 |
+
value = "-ORG"
|
77 |
+
elif entity == "LABEL_4":
|
78 |
+
value = "I-ORG"
|
79 |
+
elif entity == "LABEL_5":
|
80 |
+
value = "B-LOC"
|
81 |
+
elif entity == "LABEL_6":
|
82 |
+
value = "I-LOC"
|
83 |
+
elif entity == "LABEL_7":
|
84 |
+
value = "B-MISC"
|
85 |
+
else:
|
86 |
+
value = "I-MISC"
|
87 |
+
dictionary['entity'] = value
|
88 |
+
sparse_entities.append(sparse_dictionary)
|
89 |
|
90 |
sparse_output = {"text": text, "entities": sparse_entities}
|
91 |
|