Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -86,32 +86,15 @@ label_column_name = "ner_tags"
|
|
| 86 |
|
| 87 |
# In the event the labels are not a `Sequence[ClassLabel]`, we will need to go through the dataset to get the
|
| 88 |
# unique labels.
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
label_list = features[label_column_name].feature.names
|
| 99 |
-
# No need to convert the labels since they are already ints.
|
| 100 |
-
id2label = {k: v for k,v in enumerate(label_list)}
|
| 101 |
-
label2id = {v: k for k,v in enumerate(label_list)}
|
| 102 |
-
else:
|
| 103 |
-
label_list = get_label_list(dataset["test"][label_column_name])
|
| 104 |
-
id2label = {k: v for k,v in enumerate(label_list)}
|
| 105 |
-
label2id = {v: k for k,v in enumerate(label_list)}
|
| 106 |
-
num_labels = len(label_list)
|
| 107 |
-
|
| 108 |
-
def get_label_list(labels):
|
| 109 |
-
unique_labels = set()
|
| 110 |
-
for label in labels:
|
| 111 |
-
unique_labels = unique_labels | set(label)
|
| 112 |
-
label_list = list(unique_labels)
|
| 113 |
-
label_list.sort()
|
| 114 |
-
return label_list
|
| 115 |
|
| 116 |
#label2color = {'question':'blue', 'answer':'green', 'header':'orange', 'other':'violet'}
|
| 117 |
|
|
|
|
| 86 |
|
| 87 |
# In the event the labels are not a `Sequence[ClassLabel]`, we will need to go through the dataset to get the
|
| 88 |
# unique labels.
|
| 89 |
+
labels = dataset.features["ner_tags"].feature.names
|
| 90 |
+
id2label = {v: k for v, k in enumerate(labels)}
|
| 91 |
+
|
| 92 |
+
label2color = {
|
| 93 |
+
"question": "blue",
|
| 94 |
+
"answer": "green",
|
| 95 |
+
"header": "orange",
|
| 96 |
+
"other": "violet",
|
| 97 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
#label2color = {'question':'blue', 'answer':'green', 'header':'orange', 'other':'violet'}
|
| 100 |
|