The cas_visualizerlibrary can be used to transform a Common Analysis System (CAS) data structure into an annotated HTML string.
The library visualizes annotations with an underlined (default) or highlighted style.
(see self-contained example)
We require a CAS file or cassis.Cas object that contains a text, e.g.
Die Fernuniversität in Hagen (Eigenschreibweise: FernUniversität) ist die erste und einzige staatliche Fernuniversität in Deutschland. Ihr Sitz befindet sich in Hagen in Nordrhein-Westfalen.
Nach Angaben des Statistischen Bundesamtes war sie, ohne Berücksichtigung von Akademie- und Weiterbildungsstudierenden, mit über 76.000 Studierenden im Wintersemester 2016/2017[3] die größte deutsche Universität.[4]
The CAS is based on a type system file or cassis.TypeSystem object and specifies annotation types, e.g.
de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity
To transform the text into an HTML string with underlined annotations of type NamedEntity, we run:
from cas_visualizer.visualizer import SpanVisualizer
cas = '../data/hagen.txt.xmi'
ts = '../data/TypeSystem.xml'
span_vis = SpanVisualizer(ts)
span_vis.add_type(name='NamedEntity')
html = span_vis.visualize(cas)
Finally, in a browser we can then render the HTML string:
Before visualizing the CAS, you can switch to the highlighted style by calling:
span_vis.selected_span_type = "HIGHLIGHT"
- Increase the version number in
pyproject.toml - Run
poetry build - [Optional] If no token is configured:
- Create an API-Token by visiting: https://pypi.org/manage/account/#api-tokens
- Replace
TOKENwith the string of the API-Token and runpoetry config pypi-token.pypi TOKEN
- Run
poetry publish

