Spaces:
Build error
Build error
change
Browse files
rebel.py
CHANGED
|
@@ -46,7 +46,10 @@ def generate_knowledge_graph(texts: List[str], filename: str):
|
|
| 46 |
if n in NERs:
|
| 47 |
NER_type = NER_types[NERs.index(n)]
|
| 48 |
if NER_type in NER_types:
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
| 50 |
net.add_node(n, title=NER_type, shape="circle", color=color)
|
| 51 |
else:
|
| 52 |
net.add_node(n, shape="circle")
|
|
@@ -57,7 +60,8 @@ def generate_knowledge_graph(texts: List[str], filename: str):
|
|
| 57 |
stringify_trip = lambda x : x["tail"] + x["head"] + x["type"].lower()
|
| 58 |
for triplet in triplets:
|
| 59 |
if stringify_trip(triplet) not in unique_triplets:
|
| 60 |
-
net.add_edge(triplet["head"].lower(), triplet["tail"].lower(),
|
|
|
|
| 61 |
unique_triplets.add(stringify_trip(triplet))
|
| 62 |
|
| 63 |
net.repulsion(
|
|
|
|
| 46 |
if n in NERs:
|
| 47 |
NER_type = NER_types[NERs.index(n)]
|
| 48 |
if NER_type in NER_types:
|
| 49 |
+
if NER_type in DEFAULT_LABEL_COLORS.keys():
|
| 50 |
+
color = DEFAULT_LABEL_COLORS[NER_type]
|
| 51 |
+
else:
|
| 52 |
+
color = "#666666"
|
| 53 |
net.add_node(n, title=NER_type, shape="circle", color=color)
|
| 54 |
else:
|
| 55 |
net.add_node(n, shape="circle")
|
|
|
|
| 60 |
stringify_trip = lambda x : x["tail"] + x["head"] + x["type"].lower()
|
| 61 |
for triplet in triplets:
|
| 62 |
if stringify_trip(triplet) not in unique_triplets:
|
| 63 |
+
net.add_edge(triplet["head"].lower(), triplet["tail"].lower(),
|
| 64 |
+
title=triplet["type"], label=triplet["type"])
|
| 65 |
unique_triplets.add(stringify_trip(triplet))
|
| 66 |
|
| 67 |
net.repulsion(
|