mirror of https://github.com/explosion/spaCy.git
Use uppercase for entity types
This commit is contained in:
parent
3d37564a09
commit
c33bdeb564
|
@ -156,12 +156,12 @@ class EntityRenderer(object):
|
||||||
|
|
||||||
options (dict): Visualiser-specific options (colors, ents)
|
options (dict): Visualiser-specific options (colors, ents)
|
||||||
"""
|
"""
|
||||||
colors = {'org': '#7aecec', 'product': '#bfeeb7', 'gpe': '#feca74',
|
colors = {'ORG': '#7aecec', 'PRODUCT': '#bfeeb7', 'GPE': '#feca74',
|
||||||
'loc': '#ff9561', 'person': '#9886fc', 'norp': '#c887fb',
|
'LOC': '#ff9561', 'PERSON': '#aa9cfc', 'NORP': '#c887fb',
|
||||||
'facility': '#9cc9cc', 'event': '#ffeb80', 'language': '#ff8197',
|
'FACILITY': '#9cc9cc', 'EVENT': '#ffeb80', 'LANGUAGE': '#ff8197',
|
||||||
'work_of_art': '#f0d0ff', 'date': '#bfe1d9', 'time': '#bfe1d9',
|
'WORK_OF_ART': '#f0d0ff', 'DATE': '#bfe1d9', 'TIME': '#bfe1d9',
|
||||||
'money': '#e4e7d2', 'quantity': '#e4e7d2', 'ordinal': '#e4e7d2',
|
'MONEY': '#e4e7d2', 'QUANTITY': '#e4e7d2', 'ORDINAL': '#e4e7d2',
|
||||||
'cardinal': '#e4e7d2', 'percent': '#e4e7d2'}
|
'CARDINAL': '#e4e7d2', 'PERCENT': '#e4e7d2'}
|
||||||
colors.update(options.get('colors', {}))
|
colors.update(options.get('colors', {}))
|
||||||
self.default_color = '#ddd'
|
self.default_color = '#ddd'
|
||||||
self.colors = colors
|
self.colors = colors
|
||||||
|
@ -204,8 +204,8 @@ class EntityRenderer(object):
|
||||||
markup += fragment
|
markup += fragment
|
||||||
if len(fragments) > 1 and i != len(fragments)-1:
|
if len(fragments) > 1 and i != len(fragments)-1:
|
||||||
markup += '</br>'
|
markup += '</br>'
|
||||||
if self.ents is None or label.lower() in self.ents:
|
if self.ents is None or label.upper() in self.ents:
|
||||||
color = self.colors.get(label.lower(), self.default_color)
|
color = self.colors.get(label.upper(), self.default_color)
|
||||||
markup += TPL_ENT.format(label=label, text=entity, bg=color)
|
markup += TPL_ENT.format(label=label, text=entity, bg=color)
|
||||||
else:
|
else:
|
||||||
markup += entity
|
markup += entity
|
||||||
|
|
|
@ -194,8 +194,8 @@ p
|
||||||
+h(3, "options-ent") Named Entity Visualizer options
|
+h(3, "options-ent") Named Entity Visualizer options
|
||||||
|
|
||||||
+aside-code("Example").
|
+aside-code("Example").
|
||||||
options = {'ents': ['person', 'org', 'product'],
|
options = {'ents': ['PERSON', 'ORG', 'PRODUCT'],
|
||||||
'colors': {'org': 'yellow'}}
|
'colors': {'ORG': 'yellow'}}
|
||||||
displacy.serve(doc, style='ent', options=options)
|
displacy.serve(doc, style='ent', options=options)
|
||||||
|
|
||||||
+table(["Name", "Type", "Description", "Default"])
|
+table(["Name", "Type", "Description", "Default"])
|
||||||
|
|
Loading…
Reference in New Issue