Skip to content

dot default SVG rendering broken #35

@lxkain

Description

@lxkain

As of today, using the latest pynini and openFST sources, pip installs, and a base ubuntu 20.04, the default SVG rendering of graphviz's dot is broken. This is of course not pynini's fault, but it affects its output in jupyter notebooks. After much searching, I came upon a workaround that others might find useful:

import graphviz
from IPython.display import SVG, display
def draw(fst):
    fst.draw('tmp.dot', portrait=True, isymbols=fst.input_symbols(), osymbols=fst.output_symbols())
    graphviz.render('dot', 'svg', 'tmp.dot', renderer='cairo')
    return display(SVG(url='file:tmp.dot.cairo.svg'))

The key here is to use svg:cairo rendering. You can then use draw(fst). I wrote some code that tried to overwrite a fst object's repr_svg function, but it's read-only, so for now I am using the functional version.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions