khaerens commited on
Commit
4c871d1
1 Parent(s): 9a83e00
Files changed (1) hide show
  1. rebel.py +6 -2
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
- color = DEFAULT_LABEL_COLORS[NER_type]
 
 
 
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(), title=triplet["type"], label=triplet["type"])
 
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(