udapi.block.write.prettyconllu module

PrettyConllu writer with aligned columns for plain-text, HTML and TeX/PDF.

The writer prints the 10 CoNLL-U columns (or their configurable subset) in aligned columns. Column widths are configured by w_* parameters, but for each sentence the effective width is shrunk to the longest value needed in that sentence.

The main parameter is format which can be set to plain, html or tex. plain is the default and produces a plain text. html produces HTML output with tooltips. tex produces TeX/PDF output, one sentence per page (using documentclass{standalone}).

The color parameter controls colorization in the output. The default value is auto which means that for plain format, colors are enabled only when writing to a TTY, while for html and tex formats, colors are always enabled. Colors can be forced on or off with values 1 or 0.

Example CLI usage:

# Plain text (default), compact per-sentence widths, no column names.
udapy write.PrettyConllu < file.conllu

# Plain text with custom widths and visible column names.
udapy write.PrettyConllu print_column_names=1 w_form=20 w_feats=32 < file.conllu

# Force color even if not writing to a TTY
udapy write.PrettyConllu color=1 < file.conllu | less -R

# The same as above, using a udapy syntactic sugar
udapy -P < file.conllu | less -R

# HTML output with tooltips.
udapy write.PrettyConllu format=html < file.conllu > pretty.html

# TeX/PDF output, one sentence per page (using \documentclass{standalone}).
udapy write.PrettyConllu format=tex tex_style=standalone < file.conllu > pretty.tex
pdflatex pretty.tex
class udapi.block.write.prettyconllu.PrettyConllu(print_sent_id=True, print_text=True, print_empty_trees=True, format='plain', attributes='ord,form,lemma,upos,xpos,feats,head,deprel,deps,misc', w_ord=4, w_form=16, w_lemma=16, w_upos=8, w_xpos=10, w_feats=28, w_head=6, w_deprel=16, w_deps=20, w_misc=28, color='auto', print_column_names=False, tex_style='resize', tooltip=True, tooltip_feats_misc=True, mark='(ToDo|ToDoOrigText|Bug|Mark)', marked_only=False, **kwargs)[source]

Bases: Conllu

A writer of aligned CoNLL-U tables in plain, TeX and HTML formats.

after_process_document(document)[source]

Finalize output wrappers for html/tex formats.

before_process_document(document)[source]

Initialize output wrappers and format-specific state.

is_marked(node)[source]
process_tree(tree)[source]

Render one tree in the selected output format.

should_print_tree(tree, nodes)[source]

Should this tree be printed?