Skip to main content

cwb-vrt

Build PyPI version PyPI Downloads License

cwb-vrt is a Python 3 module and command line interface for processing VRT files.

Installation

Requires Python 3.10+.

via PyPI

pip install cwb-vrt

via git (latest, unreleased changes)

pip install git+https://github.com/ausgerechnet/cwb-vrt.git

VRT files

VRT files are XML-like files containing verticalised text and are used as an import (and export) format of the IMS Open Corpus Workbench (CWB). The CWB distinguishes positional attributes (p-atts) on a token-level, which are stored in tab-separated lines, and structural attributes (s-atts) stored in XML elements (i.e. matching pairs of start and end tags).

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
<!-- A Thrilling Experience -->
<story num="4" title="A Thrilling Experience">
<p>
<s>
Tick	NN	tick
.	SENT	.
</s>
<s>
A	DT	a
clock	NN	clock
.	SENT	.
</s>
<s>
Tick	VB	tick
,	,	,
tick	VB	tick
.	SENT	.
</s>
</p>
...
</story>
...

The VRT file above contains three p-atts: by default, the first or primary layer is called word — the other p-atts here could e.g. be named pos and lemma. Note that the names of p-atts are usually not explicitly encoded in VRT files.

There are also three s-atts encoded in XML-elements: story, p, and s. story has two attribute-value pairs:

<story num="4" title="A Thrilling Experience">

cwb-vrt refers to the name of the XML element (e.g. story) usually as "level" of the s-att and stores it alongside the other key-value pairs in a dictionary. Note that in the CWB, each attribute is stored separately (here: story_num and story_title) with annotation (story itself is not encoded as an s-att). p and s do not have any annotation.

Unlike well-formed XML, s-attribute regions in a VRT file don't have to nest properly — they may overlap (also called "crossing" or "interleaved" annotations). For example, a <s> spanning a <p> boundary is valid VRT but not valid XML: <p>...<s>...</p><p>...</s>...</p>.

VRT files for CQPweb

Not all VRT files accepted by the CWB can be used for CQPweb:

  • there has to be an XML-element called "text" with unique IDs <text id="...">
  • only a relatively small number of <text>s are possible (~ 10,000,000)
  • meta data stored in <text>-attributes can be used for subcorpus creation and restricted queries, but they have to be marked as categorical in CQPweb — and this only works if all values are valid MySQL-identifiers

Using the CLI

Installing cwb-vrt puts a single cwb-vrt command on your PATH, with one subcommand per tool. Run cwb-vrt --help for the full list, or cwb-vrt <subcommand> --help for a subcommand's options.

$ cwb-vrt --help
usage: cwb-vrt [-h] [-v]
               {bio-repair,convert,cqpweb,dedup,encode,group,merge,meta,remove}
               ...

cwb-vrt: tools for processing VRT files

positional arguments:
  {bio-repair,convert,cqpweb,dedup,encode,group,merge,meta,remove}
    bio-repair          repair (potentially invalid) BIOES token tagging into
                        valid BIO tagging
    convert             render VRT file(s) as HTML (or plain text)
    cqpweb              make VRT file compatible with CQPweb
    dedup               find duplicate regions, or remove them from the VRT
    encode              create CWB import script from VRT file
    group               conflate texts according to meta data into cohorts
    merge               merge several VRT files of cohorts into one VRT
    meta                create TSV table of meta data stored in s-atts
    remove              remove structural and/or positional attributes from
                        VRT file

options:
  -h, --help            show this help message and exit
  -v, --version         output version information and exit

cwb-vrt bio-repair: repair (potentially invalid) BIOES token tagging into valid BIO tagging, storing it as an s-attribute

cwb-vrt bio-repair ner-bioes.vrt.gz --col 2 --level ner

cwb-vrt convert: render VRT file(s) as HTML (or plain text), optionally highlighting spans annotated with a given s-attribute (e.g. <sub> for sensitive data)

cwb-vrt convert tagesschau-mini-cqpweb.vrt.gz --highlight sub

cwb-vrt cqpweb: make VRT file compatible with CQPweb

cwb-vrt cqpweb tagesschau-mini.vrt.gz --level article

cwb-vrt dedup: find regions enclosed by level that are duplicates (--mode report, default: writes a TSV table), or remove them directly (--mode deduplicate: writes a cleaned copy of the VRT)

cwb-vrt dedup tagesschau-mini.vrt.gz --level s
cwb-vrt dedup tagesschau-mini.vrt.gz --level s --mode deduplicate

cwb-vrt encode: create CWB import script from VRT file

cwb-vrt encode tagesschau-mini.vrt.gz

cwb-vrt group: conflate texts according to meta data into cohorts

cwb-vrt group -m tagesschau-mini.vrt.gz -c month rubrik --level-old article --level-new article

cwb-vrt merge: merge several VRT files of cohorts into one VRT

cwb-vrt merge 'tagesschau-mini-cohorts/*.vrt.gz' --name TAGESSCHAU

cwb-vrt meta: create TSV table of meta data stored in s-atts

cwb-vrt meta tagesschau-mini.vrt.gz --level article

cwb-vrt remove: remove structural and/or positional attributes from VRT file, or just selected keys from a structural attribute's annotation

cwb-vrt remove tagesschau-mini.vrt.gz --s_atts p --p_atts 1 --s_att_keys article:fname

Metadata

Release files for cwb-vrt 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cwb-vrt 0.3.0
File Size Uploaded Provenance Actions
cwb_vrt-0.3.0.tar.gz 42.5 kB With provenance Details for cwb_vrt-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cwb-vrt 0.3.0
File Interpreter ABI Platform Actions
cwb_vrt-0.3.0-py3-none-any.whl Python 3 none any Details for cwb_vrt-0.3.0-py3-none-any.whl

Total release size: 86.6 kB

Release files / cwb_vrt-0.3.0.tar.gz

Download URL cwb_vrt-0.3.0.tar.gz
Size 42.5 kB
Tags Source
SHA-256 checksum
How to use checksums
070f0f649adc0e049dbd88e3d6847540f6a1a4ceb7cd5778b1acc61ab3df3772
BLAKE2b-256 checksum
How to use checksums
e7d5a213976a8b5c33158abd05e3f6c74a7144e248dce831d92a94f2ede20ab6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.

Transparency log

Release files / cwb_vrt-0.3.0-py3-none-any.whl

Download URL cwb_vrt-0.3.0-py3-none-any.whl
Size 44.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
365664005ad3e098fb5a1a3a33c26e3bbc1a248e482b4c182f060346a99fc99a
BLAKE2b-256 checksum
How to use checksums
60af709c7bd1672c6e674c9ac21633a3bf05d444a4d6efc79a7fb216c2c749ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.

Transparency log

Security for cwb-vrt 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cwb_vrt-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page