cwb-vrt
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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cwb_vrt-0.3.0.tar.gz.
File metadata
- Download URL: cwb_vrt-0.3.0.tar.gz
- Upload date:
- Size: 42.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
070f0f649adc0e049dbd88e3d6847540f6a1a4ceb7cd5778b1acc61ab3df3772
|
|
| MD5 |
6a52f81bee564945a5018a24d117626a
|
|
| BLAKE2b-256 |
e7d5a213976a8b5c33158abd05e3f6c74a7144e248dce831d92a94f2ede20ab6
|
Provenance
The following attestation bundles were made for cwb_vrt-0.3.0.tar.gz:
Publisher:
publish.yml on ausgerechnet/cwb-vrt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cwb_vrt-0.3.0.tar.gz -
Subject digest:
070f0f649adc0e049dbd88e3d6847540f6a1a4ceb7cd5778b1acc61ab3df3772 - Sigstore transparency entry: 2387486028
- Sigstore integration time:
-
Permalink:
ausgerechnet/cwb-vrt@724dcb3f7651291d7b9e647967328defa4e6b1a5 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/ausgerechnet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@724dcb3f7651291d7b9e647967328defa4e6b1a5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file cwb_vrt-0.3.0-py3-none-any.whl.
File metadata
- Download URL: cwb_vrt-0.3.0-py3-none-any.whl
- Upload date:
- Size: 44.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
365664005ad3e098fb5a1a3a33c26e3bbc1a248e482b4c182f060346a99fc99a
|
|
| MD5 |
40c11bd58bcd6e16d153e1fde60de9b0
|
|
| BLAKE2b-256 |
60af709c7bd1672c6e674c9ac21633a3bf05d444a4d6efc79a7fb216c2c749ef
|
Provenance
The following attestation bundles were made for cwb_vrt-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on ausgerechnet/cwb-vrt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cwb_vrt-0.3.0-py3-none-any.whl -
Subject digest:
365664005ad3e098fb5a1a3a33c26e3bbc1a248e482b4c182f060346a99fc99a - Sigstore transparency entry: 2387486031
- Sigstore integration time:
-
Permalink:
ausgerechnet/cwb-vrt@724dcb3f7651291d7b9e647967328defa4e6b1a5 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/ausgerechnet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@724dcb3f7651291d7b9e647967328defa4e6b1a5 -
Trigger Event:
release
-
Statement type: