Support LOAD() directives in scripts
Change-Id: Ib22192a942daa47c40d4fe5712a63de9c71b68af
diff --git a/lib/KorAP/ScriptLoad.pm b/lib/KorAP/ScriptLoad.pm
new file mode 100644
index 0000000..66aa8ee
--- /dev/null
+++ b/lib/KorAP/ScriptLoad.pm
@@ -0,0 +1,120 @@
+package KorAP::ScriptLoad;
+use KorAP::VirtualCorpus::Group;
+use KorAP::VirtualCorpus::Or;
+use KorAP::VirtualCorpus::GroupRef;
+use File::Spec::Functions qw!catfile!;
+use Mojo::Util qw'encode';
+use strict;
+use warnings;
+
+
+# Constructor
+sub new {
+ my $class = shift;
+ my %self = @_;
+
+ $self{output} //= '.';
+
+ my $file = $self{file};
+
+ if (ref $file && ref $file eq 'GLOB') {
+ $self{file} = '';
+ $self{fh} = $file;
+ return bless \%self, $class;
+ };
+
+ # Open def file
+ if (!open($self{fh}, '<' . $file)) {
+ warn $file . " can't be opened";
+ exit(0);
+ };
+
+ return bless \%self, $class;
+};
+
+
+# Parse script file
+sub parse {
+ my $self = shift;
+
+ while (!eof($self->{fh})) {
+ my $line = readline($self->{fh});
+
+ next if $line =~ /^\#/;
+
+ if ($line =~ /LOAD/) {
+ my ($name, $desc, @vcs) = _parse_load($line);
+ unless ($name) {
+ warn
+ };
+ $self->load_to_vc($name, $desc, @vcs);
+ };
+ };
+
+ close($self->{fh});
+};
+
+sub load_to_vc {
+ my $self = shift;
+ my ($name, $desc, @list) = @_;
+
+ print "Convert '", $name, "' from LOAD()\n";
+
+ my $vc = from_load($name, $desc, @list);
+
+ # Output
+ my $out = catfile($self->{output}, $name . '.jsonld');
+ if (open(my $koral, '>' . $out)) {
+ binmode($koral);
+ print $koral encode('utf-8', $vc->to_string);
+ close($koral);
+ return;
+ };
+
+ warn 'Unable to write file ' . $out;
+};
+
+sub _parse_load {
+ my $line = shift;
+ chomp($line);
+ $line =~ s/^\s*echo\s+-e\s+//;
+ $line =~ s/\s+>>\s*\$.+$//;
+ $line =~ s/^\s*"(.+?)"\s*$/$1/;
+ $line =~ s/\\t/ /g;
+
+ $line =~ /^(.+?) - (.+?)[\s\t]+(?:(?:_[^_]+_)+[\s\t]+)?LOAD\(([^\)]+?)\).*$/;
+ my ($name, $desc, $list) = ($1, $2, $3);
+ $list =~ s/^"(.+?)"$/$1/;
+ $list =~ s/^'(.+?)'$/$1/;
+ return $name, $desc, split(/\s+/,$list);
+};
+
+
+sub from_load {
+ my ($name, $desc, @vcs) = @_;
+
+ my @vc_objs = ();
+ foreach (@vcs) {
+
+ if (index($_,'-') == 0) {
+ my $minus = substr($_,1);
+
+ my $neg_vc = KorAP::VirtualCorpus::GroupRef->new($minus);
+ $neg_vc->match('ne');
+
+ my $base_vc = KorAP::VirtualCorpus::Or->new(@vc_objs);
+ (@vc_objs) = KorAP::VirtualCorpus::And->new($base_vc, $neg_vc);
+ }
+
+ else {
+ push @vc_objs, KorAP::VirtualCorpus::GroupRef->new($_);
+ };
+ };
+
+ if (@vc_objs > 1) {
+ return KorAP::VirtualCorpus::Or->new(@vc_objs);
+ };
+ return $vc_objs[0];
+};
+
+1;
diff --git a/lib/KorAP/VirtualCorpus/GroupRef.pm b/lib/KorAP/VirtualCorpus/GroupRef.pm
new file mode 100644
index 0000000..f2b96b6
--- /dev/null
+++ b/lib/KorAP/VirtualCorpus/GroupRef.pm
@@ -0,0 +1,71 @@
+package KorAP::VirtualCorpus::GroupRef;
+use strict;
+use warnings;
+use base 'KorAP::VirtualCorpus';
+
+# TODO:
+# Maybe replaceble with DocVec
+
+# Constructor
+sub new {
+ my $class = shift;
+ bless {
+ reference => shift,
+ match => 'eq',
+ }, $class;
+};
+
+
+# Clone document VC
+sub clone {
+ my $self = shift;
+ bless {
+ reference => $self->{reference},
+ match => $self->{match},
+ }, __PACKAGE__;
+};
+
+
+# Return object type
+sub koral_type {
+ return 'DocGroupRef';
+};
+
+
+# Get or set match
+sub match {
+ my $self = shift;
+ if (@_) {
+ $self->{match} = shift;
+ return $self;
+ };
+ return $self->{match};
+};
+
+
+# Get or set reference
+sub reference {
+ my $self = shift;
+ if (@_) {
+ $self->{reference} = shift;
+ return $self;
+ };
+ return $self->{reference};
+};
+
+
+# Stringify fragment
+sub _to_fragment {
+ my $self = shift;
+ my $json = '{';
+ $json .= '"@type":"koral:docGroupRef",';
+ $json .= '"ref":"' . $self->reference . '"';
+ $json .= ',"match":"match:' . $self->match . '"' if $self->match ne 'eq';
+
+ # Set at the end, when all comments are done
+ $json .= $self->_commentparam_to_string;
+ return $json . '}';
+};
+
+
+1;
diff --git a/script/cosmasvc2koralquery b/script/cosmasvc2koralquery
index e674964..e73166e 100755
--- a/script/cosmasvc2koralquery
+++ b/script/cosmasvc2koralquery
@@ -33,9 +33,9 @@
)
or die("Error in command line arguments\n");
-if (!$cmd || ($cmd ne 'def' && $cmd ne 'list')) {
+if (!$cmd || ($cmd ne 'def' && $cmd ne 'list' && $cmd ne 'script')) {
print <<'HELP';
-Convert a list of C2 VC definitions or a single definition into
+Convert a list of C2 VC definitions, a single definition or a script file into
KoralQuery VCs.
$ perl cosmasvc2koralquery def my_vc.txt | gzip -vc > my_vc.jsonld.gz
@@ -54,6 +54,12 @@
--output: The output directory
--copy-src: The directory for def files to copy
+Command: script
+
+ Convert a script file with LOAD() instructions to KoralQuery VCs.
+
+ --output: The output directory
+
HELP
exit 1;
};
@@ -69,6 +75,16 @@
exit(0);
};
+# Process a list
+if ($cmd eq 'script') {
+ KorAP::ScriptLoad->new(
+ file => ($input || $ARGV[0]),
+ output => ($output || '.')
+ )->parse;
+ exit(0);
+};
+
+
# Parse a single def
my $def_parser;
if ($ARGV[0] eq '-') {
diff --git a/t/data/doVirtBms.w.all.2024-I b/t/data/doVirtBms.w.all.2024-I
new file mode 100644
index 0000000..9318d25
--- /dev/null
+++ b/t/data/doVirtBms.w.all.2024-I
@@ -0,0 +1,487 @@
+#!/usr/bin/bash
+# Script for building the virtual Corpus Bitmaps of C2-Database W2
+# $1 : Database Name as registered in Server.
+# $2 : Path of C2-Server
+# $3 : Corpus Definition file (output)
+# 21.01.02/FB
+# 20.09.02/FB iko90 iko91
+# 15.10.02/FB froh1/froh2 entfernt
+# 09.04.03/FB parameter $3
+# 14.04.03/FB W-ALL-BIG
+# 25.03.04/FB W2
+# 14.11.05/FB W3
+# 08.06.06/FB dereko als eigenstaendiges Korpus und Defintione entfernt.
+# Umlaute öÖäÄüÜß
+#
+# DeReKo 2024-I - 22.02.23/FB
+# IMPORTANT:
+# Whhen editing this file, always check for the last 2 years: 2022 and 2023 while in 2024.
+
+### Anm. zu den .def-Dateien:
+### diese Methode nicht mehr verwenden (bzw. nicht mehr auf .def-Dateien verzichten), weil
+### Eric fuer die Generierung der CII-HTML-Seiten Informationen aus den .def Dateien holt
+
+if [ "$1" = "" ]
+then
+ echo "Error: missing registered Database Name!"
+ return 1
+fi
+
+if [ "$2" = "" ]
+then
+ echo "Error: missing C2-Server Path!"
+ return 1
+fi
+
+if [ "$3" = "" ]
+then
+ echo "Error: missing Corpus Definition file!"
+ return 1
+fi
+
+if [ "$5" = "" ]
+then
+ echo "Error: Variable DBHOME must be specified!"
+ return 1
+fi
+
+DBN="-n:$1"
+SV=-ps:$2
+CDFile=$3
+SL=-s1
+BIN=$4
+DBHOME=$5
+
+_THIS_YEAR=2023
+
+echo "$0: Ausführung beginnt..."
+
+# TODO: . graph. Uebersicht, welche virt. Korpora wo inkludiert sind (kann ich so etwas evtl.
+# per Skript als HTML-Seite generieren?): z.B. loz enthaelt div u. lit entaelt wiederum
+# loz: lit <- loz <- div (mit Eric sprechen: ich habe links stehende Verschachtelung
+# in LIST/list.w implementiert, sonst verliere ich die Uebersicht. Ob das seine Webseiten-
+# Generierung stoert, weiss ich allerdings nicht
+
+#
+# include functions like build_big_def()
+#
+. /home/c2admin/c2/ix/cfg/bms/SCRIPT/functions
+
+echo "$0: functions loaded."
+
+### Die Gesamt-Korpora (_Blue_):
+# 2024-I: W-gesamt: keine neuen Korpus-Dateien - 16.02.23/FB
+
+echo -e "W-gesamt - alle Korpora des Archivs W (mit Neuakquisitionen) _B__Blue_\tLOAD('bih bio bio-pub l bvz brz bzk b ct cz dck div div-pub dkg dpa p erk flt faz foc frr fsp fsp-pub goe gr1 gri haz hbk hes hmp iko ix kic kjl klz ksp les lim lmd ltb mk1 mk2 mld m neu new ng nku nkz non nun nuz nzf nzs nzz oon pp prf rei rhp rhz sbl sbn a sid soz s spk sol ste stg u tas t thm ttz van vdi wam wkb wkd wkv wxx11 wwo zca zcw z zge e zwi')" >>$CDFile
+
+echo -e "N-gesamt - alle Neuakquisitionen von DeReKo-2024-I _B__Blue_\tLOAD('bih bio bio-pub l bvz brz bzk b ct cz dck div div-pub dkg dpa p erk flt faz foc frr fsp fsp-pub goe gr1 gri haz hbk hes hmp iko ix kic kjl klz ksp les lim lmd ltb mk1 mk2 mld m neu new ng nku nkz non nun nuz nzf nzs nzz oon pp prf rei rhp rhz sbl sbn a sid soz s spk sol ste stg u tas t thm ttz van vdi wam wkb wkd wkv wxx11 wwo zca zcw z zge e zwi -corp-w-gesamt.2023-i.16.03.23')" >>$CDFile
+
+echo -e "W-ohneWikipedia-gesamt - alle Korpora des Archivs W (mit Neuakquisitionen, ohne Wikipedia) _Blue_\tLOAD('bih bio bio-pub l bvz brz bzk b ct cz dck div div-pub dkg dpa p erk flt faz foc frr fsp fsp-pub goe gr1 gri haz hbk hes hmp iko ix kic kjl klz ksp les lim lmd ltb mk1 mk2 mld m neu new ng nku nkz non nun nuz nzf nzs nzz oon pp prf rei rhp rhz sbl sbn a sid soz s spk sol ste stg u tas t thm ttz van vdi wam wkb wkd wkv wwo zca zcw z zge e zwi')" >>$CDFile
+
+# Neuakquisitionen 2024-I:
+#
+# - *.def + Bitmaps erzeugt mit /C2/IX2/RES/BMS/NEUAKQUI/doNeuakqui.
+# - Dateien automatisch aus dem Vergleich von w-all und w-neu erzeugt.
+# - Dateien autom. in /bm/ kopiert und Eintrag cdef.neuakqui.txt erzeugt, der
+# hier reinkopiert wurde.
+# P.S. letztendlich in die bestehenden Skripte integriert.
+# 26.03.21/FB
+
+#echo "$0: calling $BIN/c2test $SL $DBN $SV -ad2b:o:Name_eines_VC"
+
+### Diese Korpora sind eingefroren
+### siehe x4600m2:/export/home1/C2_home2/C2/res/c2/bm/README.uwv !!!
+# da der Aufbau der Korpus-Bitmap lange dauert, wird c2test im Hintergrund gestartet.
+# last DeReKo-release is accessible to everybody.
+
+echo -e "W-gesamt-2023-I - W-gesamt von Release DeReKo-2023-I _Blue_\tLOAD('corp-w-gesamt.2023-i.16.03.23')" >> $CDFile
+
+echo -e "W-gesamt-2022-I - W-gesamt von Release DeReKo-2022-I _Blue_\tLOAD('corp-w-gesamt.2022-i.21.06.22')" >> $CDFile
+
+echo -e "W-gesamt-2021-I - W-gesamt von Release DeReKo-2021-I _Blue_\tLOAD('corp-w-gesamt.2021-i.11.08.21')" >> $CDFile
+
+echo -e "W-gesamt-2020-I - W-gesamt von Release DeReKo-2020-I _Blue_\tLOAD('corp-w-gesamt.2020-i.15.05.20')\tG_UWV" >> $CDFile
+
+echo -e "W-gesamt-2018-II - W-gesamt von Release DeReKo-2018-II _Blue_\tLOAD('corp-w-gesamt.2018-ii.05.12.18')\tG_UWV" >> $CDFile
+
+echo -e "W-gesamt-2017-I - W-gesamt von Release DeReKo-2017-I _Blue_\tLOAD('corp-w-gesamt.2017-i.17.10.17')\tG_UWV" >> $CDFile
+
+for c in corp-w-gesamt.2023-i.16.03.23 corp-w-gesamt.2022-i.21.06.22 \
+ corp-w-gesamt.2021-i.11.08.21 corp-w-gesamt.2020-i.15.05.20 \
+ corp-w-gesamt.2018-ii.05.12.18 corp-w-gesamt.2017-i.17.10.17
+do
+ build_big_def $c &
+done
+
+### Gebündelte,allgemeine Korpora (_Maroon_):
+
+# gri + kjl added to lit - 06.05.22/FB
+echo -e ""
+echo -e "lit - Belletristik/Trivialliteratur _Maroon_ \tLOAD('bih bio bio-pub div div-pub gr1 gri hes kjl les wam thm-lit misc-lit')" >>$CDFile
+$BIN/c2test $SL "$DBN" "$SV" -ad2b:o:thm-lit
+$BIN/c2test $SL "$DBN" "$SV" -ad2b:o:misc-lit
+
+#echo -e "ozk - Österreichisches Zeitungskorpus, 1991 - $_THIS_YEAR _Maroon_\tLOAD('bvz p prf flt klz new nkz non oon sbn ttz van')" >>$CDFile
+
+echo -e "ndR - Korpora mit überwiegend neuer Rechtschreibung _Maroon_\tLOAD('ndr-all')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:ndr-all
+
+# länderspezifische Korpora
+
+echo -e "A-Korpora - Korpora aus Österreich _Maroon_\tLOAD('corp-a')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:corp-a
+
+echo -e "CH-Korpora - deutschsprachige Korpora aus der Schweiz _Maroon_\tLOAD('corp-ch')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:corp-ch
+
+echo -e "D-Korpora - Korpora aus Deutschland _Maroon_\tLOAD('corp-d')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:corp-d
+
+echo -e "L-Korpora - deutschsprachige Korpora aus Luxemburg _Maroon_\tLOAD('corp-l')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:corp-l
+
+### Projektkorpora (_Green_):
+
+### TODO: siehe Mail vom 23.02.16 (Mail/converted_from_THB/COSMASII.sbd/Indexierung.sbd/Newsletter)
+# Ansprechspartner fuer die Zusammensetzung von dfwb: Herbert Schmidt, IDS
+
+echo -e ""
+echo -e "dfwb - virt. Korpus des Deutschen Fremdwörterbuches _Green_\tLOAD('dfwb33 dfwb-frag bio bio-pub dfwb-p faz fsp fsp-pub hmp dfwb-spiegel a spk vdi')" >> $CDFile
+
+for name in dfwb33 dfwb-frag dfwb-p dfwb-spiegel
+do
+ $BIN/c2test $SL "$DBN" $SV -ad2b:o:$name
+done
+
+# w-frei:
+# Virtuelles Korpus für die WebServices.
+# Hier aufbauen, aber nicht in die Listen cdef.all|pub.txt aufnehmen.
+# 16.04.21/FB
+
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:w-frei
+
+### TODO: siehe /home/c2admin/ix/ix/cfg/bms/create_ndr.pl
+### NOTE 1: "cat /export/home3/C2/db/off/w/auxdb/aux-dnames.dat|../create_ndr.pl > ndr.def"
+### zur Generierung von 'DEF/ndr.def' ausfuehren!
+### NOTE 2: generierte Datei von Hand pruefen (vi -d ndr.def DEF/ndr.def)
+# DeReKo-2021-I:
+# MOTE 3: ndr-all.def und ndr-pub.def sind jetzt vordefiniert, passen sich an
+# die letzte Aktualisierung automatisch an und ersetzen die Generierung
+# von ndr-pub.def und ndr-npub.def.
+# cdef.all.txt -> ndr-all.def / cdef.pub.txt -> ndr.pub.def.
+
+
+###
+echo -e "rsrat - Rechtschreibrat-Kernkorpus in W _Green_\tLOAD('corp-w-rsrat')\tG_Rechtschreibrat" >> $CDFile
+build_big_def corp-w-rsrat &
+###
+echo -e "vas-n91 - Projektkorpus VAS N91, Stand Juli 2013 (korr. 2017) _Green_\tLOAD('corp-w-vas-n91-kor17')\tG_VAS" >> $CDFile
+build_big_def corp-w-vas-n91-kor17 &
+###
+
+echo -e "bih - Herausgebertexte zum Korpus bio\tLOAD('bih')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:bih
+
+echo -e "bio - Biografische Literatur\tLOAD('bio bio-pub')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:bio
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:bio-pub
+
+echo -e "div - Belletristik des 20. und 21. Jahrhunderts: Diverse Schriftsteller\tLOAD('div div-pub')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:div
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:div-pub
+
+echo -e "bmp - Berliner Morgenpost, 1997 - $_THIS_YEAR\tLOAD('l')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:l
+
+echo -e "brz - Braunschweiger Zeitung, September 2005 - Juni 2013\tLOAD('brz')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:brz
+
+### 27.06.17: bvz was NOT updated since DeReKo-2015-II
+##echo -e "bvz - Burgenländische Volkszeitung, Januar 2007 - $_BVZ $_THIS_YEAR\tLOAD('bvz')" >>$CDFile
+#echo -e "bvz - Burgenländische Volkszeitung, 2007 - $_THIS_YEAR\tLOAD('bvz')" >>$CDFile
+echo -e "bvz - Burgenländische Volkszeitung, 2007 - 2015\tLOAD('bvz')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:bvz
+
+echo -e "bzk - Bonner Zeitungskorpus\tLOAD('bzk')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:bzk
+
+echo -e "bzt - Berliner Zeitung, 1997 - $_THIS_YEAR\tLOAD('b')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:b
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:b-pub
+
+echo -e "c't - Magazin für Computertechnik, 2017 - $_THIS_YEAR\tLOAD('ct')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:ct
+
+echo -e "cz - Computer Zeitung, Januar 1993 - Dezember 1998\tLOAD('cz')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:cz
+
+echo -e "dck - Dortmunder Chatkorpus 2.2\tLOAD('dck')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:dck
+
+echo -e "dkg - Fachsprachen-Korpus 2: Gentechnologie\tLOAD('dkg')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:dkg
+
+##echo -e "dpa - Meldungen der Deutschen Presse-Agentur, Januar 2006 - Dezember 2009, April 2010 - $_DPA $_THIS_YEAR\tLOAD('dpa')" >>$CDFile
+echo -e "dpa - Meldungen der Deutschen Presse-Agentur, 2006 - $_THIS_YEAR\tLOAD('dpa')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:dpa
+
+##echo -e "dpr - Die Presse, September 1991 - Dezember 2000\tLOAD('p')" >>$CDFile
+echo -e "dpr - Die Presse, 1991 - $_THIS_YEAR\tLOAD('p')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:p
+
+echo -e "erk - Am Erker\tLOAD('erk')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:erk
+
+echo -e "flt - Falter, 2000 - $_THIS_YEAR\tLOAD('flt')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:flt
+
+echo -e "faz - Frankfurter Allgemeine, 1993, 1995 und 1997 - 2005 (ungerade Jahrgänge und Monate)\tLOAD('faz')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:faz
+
+##echo -e "foc - FOCUS, Januar 2000 - $_FOC $_THIS_YEAR\tLOAD('foc')" >>$CDFile
+echo -e "foc - FOCUS, 2000 - $_THIS_YEAR\tLOAD('foc')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:foc
+
+echo -e "frr - Frankfurter Rundschau, Januar 1997 - Dezember 1999\tLOAD('frr')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:frr
+
+echo -e "fsp - Fachsprachen-Korpus 1\tLOAD('fsp fsp-pub')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:fsp
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:fsp-pub
+
+echo -e "goe - Goethes Werke\tLOAD('goe')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:goe
+
+echo -e "gr1 - Grammatik-Korpus\tLOAD('gr1')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:gr1
+
+echo -e "gri - Brüder Grimm: Sagen, Kinder- und Hausmärchen, Kinderlegenden\tLOAD('gri')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:gri
+
+##echo -e "haz - Hannoversche Allgemeine, August 2007 - $_HAZ $_THIS_YEAR\tLOAD('haz')" >>$CDFile
+echo -e "haz - Hannoversche Allgemeine, 2007 - $_THIS_YEAR\tLOAD('haz')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:haz
+
+echo -e "hbk - Handbuch-Korpora, 1985 - 1988\tLOAD('hbk')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:hbk
+
+echo -e "hes - Belletristik des 20. Jahrhunderts: Stefan Heym\tLOAD('hes')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:hes
+
+##echo -e "hmp - Hamburger Morgenpost, April 2005 - $_HMP $_THIS_YEAR\tLOAD('hmp')" >>$CDFile
+echo -e "hmp - Hamburger Morgenpost, 2005 - $_THIS_YEAR\tLOAD('hmp')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:hmp
+
+echo -e "iko - Interviewkorpus\tLOAD('iko')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:iko
+
+echo -e "ix - Magazin für professionelle Informationstechnik, 2017 - $_THIS_YEAR\tLOAD('ix')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:ix
+
+echo -e "kic - Fußball-Liveticker, kicker.de, 2006 - 2016\tLOAD('kic')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:kic
+
+echo -e "kjl - Kinder- und Jugendliteratur\tLOAD('kjl')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:kjl
+
+echo -e "klz - Kleine Zeitung, August 1996 - Dezember 2000\tLOAD('klz')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:klz
+
+echo -e "ksp - Fußball-Spielberichte, kicker.de, 2006 - 2016\tLOAD('ksp')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:ksp
+
+echo -e "les - Belletristik des 20. Jahrhunderts: Siegfried Lenz\tLOAD('les')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:les
+
+echo -e "lim - LIMAS-Korpus\tLOAD('lim')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:lim
+
+echo -e "lmd - Le Monde diplomatique, 2017 - $_THIS_YEAR\tLOAD('lmd')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:lmd
+
+echo -e "loz - Belletristik des 20. und 21. Jahrhunderts\tLOAD('div div-pub hes les wam')" >>$CDFile
+
+##echo -e "ltb - Luxemburger Tageblatt, Januar 2008 - $_LTB $_THIS_YEAR\tLOAD('ltb')" >>$CDFile
+echo -e "ltb - Luxemburger Tageblatt, 2008 - $_THIS_YEAR\tLOAD('ltb')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:ltb
+
+echo -e "mk - Mannheimer Korpora 1+2\tLOAD('mk1 mk2')" >>$CDFile
+
+echo -e "mk1 - Mannheimer Korpus 1\tLOAD('mk1')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:mk1
+
+echo -e "mk2 - Mannheimer Korpus 2\tLOAD('mk2')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:mk2
+
+echo -e "mld - Korpus Magazin Lufthansa Bordbuch/deutsch\tLOAD('mld')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:mld
+
+##echo -e "mm - Mannheimer Morgen, Januar 1995 - $_MM $_THIS_YEAR (die Jahrgänge 1995, 1997 und 2000 sind unvollständig)\tLOAD('m')" >>$CDFile
+echo -e "mm - Mannheimer Morgen, 1995 - $_THIS_YEAR (die Jahrgänge 1995, 1997 und 2000 sind unvollständig)\tLOAD('m')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:m
+
+echo -e "neu - Neuland: Das Wirtschaftsmagazin der Regionen, Okt. 2007; Mrz.,Jul.,Dez. 2008; Aug. 2009\tLOAD('neu')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:neu
+
+##echo -e "news - NEWS, Januar 2002 - $_NEWS $_THIS_YEAR\tLOAD('new')" >>$CDFile
+echo -e "news - NEWS, 2002 - $_THIS_YEAR\tLOAD('new')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:new
+
+### 01.07.2017:
+### use the below scripts for generating the approp. new ng-entries in 'DEF/new-npub.def':
+### unset LIST
+### while read; do if [ -z "$LIST" ];then LIST="$REPLY";else LIST="${LIST}\n${REPLY}";fi; done < <(for i in `ls -1 /pool3/DeReKo/DeReKo-2017-I/I5/ng*.i5.xml.bz2`;do bzcat $i|perl -ne 'chomp;if(s/^\s*<d.title>(.+)[0-9]{4}<\/d.title>$/$1/){print " $_\n";last};print if s/^\s*<korpusSigle>([^<]+)<\/korpusSigle>$/$1/';done)
+### export LIST
+### while read; do export REPLY; perl -e '$ENV{REPLY}=~/^([^\/]+).+?([0-9]+)$/;$ks=$1;$year=$2;$ENV{LIST}=~/$ks ([^\\\n]+)/;print "<doc>$ENV{REPLY} ${1}20$year</doc>\n"'; done < <(for i in `cat /pool3/home6/DIFF/diff_cs.DeReKo-2017-I_xs/DA/ng*.da`;do echo $i;done) >> DEF/new-pub.def
+### NOTE: the above while-loop only refers to _added_ documents (.../DA/...) and _not_ completely new ones (in this case like 'ngalt')
+###
+echo -e "ng - 'de.*'-Usenet-Newsgruppen, 2013 - 2016\tLOAD('ng')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:ng
+
+echo -e "nku - Nordkurier, 2000 - $_THIS_YEAR\tLOAD('nku')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:nku
+
+echo -e "nkz - Neue Kronen-Zeitung, Januar 1994 - Mai 2000\tLOAD('nkz')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:nkz
+
+echo -e "non - Niederösterreichische Nachrichten, 2007 - $_THIS_YEAR\tLOAD('non')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:non
+
+echo -e "nun - Nürnberger Nachrichten, 1990 - $_THIS_YEAR\tLOAD('nun')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:nun
+
+echo -e "nuz - Nürnberger Zeitung, 2002 - $_THIS_YEAR\tLOAD('nuz')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:nuz
+
+echo -e "nzf - NZZ Folio, 1994 - $_THIS_YEAR\tLOAD('nzf')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:nzf
+
+echo -e "nzs - NZZ am Sonntag, 2002 - $_THIS_YEAR\tLOAD('nzs')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:nzs
+
+echo -e "nzz - Neue Zürcher Zeitung, 2000 - $_THIS_YEAR\tLOAD('nzz')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:nzz
+
+echo -e "oon - Oberösterreichische Nachrichten, 1996 - 1997\tLOAD('oon')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:oon
+
+# Ansprechpartner: Harald Luengen
+echo -e "pp - Plenarprotokolle\tLOAD('pp')" >> $CDFile
+$BIN/c2test $SL "$DBN" "$SV" -ad2b:o:pp
+
+echo -e "prf - profil, 2000 - $_THIS_YEAR\tLOAD('prf')" >>$CDFile
+$BIN/c2test $SL "$DBN" "$SV" -ad2b:o:prf
+
+echo -e "rei - Reden und Interviews, Januar 2002 - Dezember 2006\tLOAD('rei')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:rei
+
+echo -e "rhp - Die Rheinpfalz, 2007 - $_THIS_YEAR\tLOAD('rhp')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:rhp
+
+echo -e "rhz - Rhein-Zeitung, 1996 - $_THIS_YEAR\tLOAD('rhz')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:rhz
+
+echo -e "sbl - Sonntagsblick, Feb. 2001; 2005 - $_THIS_YEAR\tLOAD('sbl')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:sbl
+
+echo -e "sbn - Salzburger Nachrichten, Juni 1991 - Dezember 2000\tLOAD('sbn')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:sbn
+
+echo -e "sgt - St. Galler Tagblatt, 1997 - 2001, 2007 - $_THIS_YEAR\tLOAD('a')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:a
+
+echo -e "sid - Fußball-Liveticker, Sport-Informations-Dienst, 2010 - 2016\tLOAD('sid')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:sid
+
+echo -e "soz - Die Südostschweiz, 2005 - 2018\tLOAD('soz')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:soz
+
+echo -e "spiegel - Der Spiegel, 1947 - $_THIS_YEAR\tLOAD('s')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:s
+
+echo -e "spon - Spiegel-Online, 1999 - $_THIS_YEAR\tLOAD('sol')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:sol
+
+echo -e "spk - spektrumdirekt, Januar 1997 - August 2012\tLOAD('spk')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:spk
+
+echo -e "ste - Stern, 1996 - $_THIS_YEAR\tLOAD('ste')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:ste
+
+echo -e "stg - Stern Gesund leben, 2018 - $_THIS_YEAR\tLOAD('stg')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:stg
+
+echo -e "sz - Süddeutsche Zeitung, 1992 - $_THIS_YEAR\tLOAD('u')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:u
+
+echo -e "tas - SonntagsZeitung (Tages-Anzeiger), 2000 - $_THIS_YEAR\tLOAD('tas')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:tas
+
+echo -e "taz - die tageszeitung, 1986 - $_THIS_YEAR\tLOAD('t')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:t
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:t-pub
+
+echo -e "thm - Thomas-Mann-Korpus\tLOAD('thm')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:thm
+
+echo -e "ttz - Tiroler Tageszeitung, Januar 1996 - Dezember 2000\tLOAD('ttz')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:ttz
+
+echo -e "van - Vorarlberger Nachrichten, Januar 1997 - Dezember 2000\tLOAD('van')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:van
+
+echo -e "vdi - VDI nachrichten, 2006 - $_THIS_YEAR\tLOAD('vdi')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:vdi
+
+echo -e "wam - Belletristik des 20. Jahrhunderts: Martin Walser\tLOAD('wam')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:wam
+
+echo -e "wkb - Wendekorpus/West\tLOAD('wkb')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:wkb
+
+echo -e "wkd - Wendekorpus/Ost\tLOAD('wkd')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:wkd
+
+echo -e "wk - Wendekorpora West+Ost\tLOAD('wkb wkd')" >>$CDFile
+
+echo -e "wkv - Wendekorpus/Vereinigung\tLOAD('wkv')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:wkv
+
+echo -e "wpd11 - Wikipedia Artikel (Stand: 29.10.2011)\tLOAD('wpd11')" >> $CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:wpd11
+
+echo -e "wdd11 - Wikipedia Diskussionen (Stand: 29.10.2011)\tLOAD('wdd11')" >> $CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:wdd11
+
+echo -e "wxx11 - Wikipedia Artikel und Diskussionen (Stand: 29.10.2011)\tLOAD('wxx11')" >> $CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:wxx11
+
+echo -e "wwo - Weltwoche, 2005 - $_THIS_YEAR\tLOAD('wwo')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:wwo
+
+echo -e "zca - Zeit Campus, 2009 - $_THIS_YEAR\tLOAD('zca')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:zca
+
+echo -e "zcw - ZEIT Christ und Welt, 2015 - $_THIS_YEAR\tLOAD('zcw')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:zcw
+
+echo -e "zeit - Die Zeit, 1953 - $_THIS_YEAR\tLOAD('z')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:z
+
+echo -e "zge - Zeit Geschichte, 2010 - $_THIS_YEAR\tLOAD('zge')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:zge
+
+echo -e "zta - Tages-Anzeiger, 1996 - $_THIS_YEAR\tLOAD('e')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:e
+
+echo -e "zwi - Zeit Wissen (unvollst.), 2009 - 2015, 2017 - $_THIS_YEAR\tLOAD('zwi')" >>$CDFile
+$BIN/c2test $SL "$DBN" $SV -ad2b:o:zwi
+
+#
+# important for the next scripts:
+# wait till all build_big_def() calls have returned:
+# 01.04.21/FB
+
+echo "$0: wait for all build_big_def()..."
+wait
+echo "$0: wait: done."
diff --git a/t/script2vc.t b/t/script2vc.t
new file mode 100644
index 0000000..8443528
--- /dev/null
+++ b/t/script2vc.t
@@ -0,0 +1,93 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+use KorAP::ScriptLoad;
+use Mojo::JSON qw'decode_json encode_json';
+use Mojo::File qw'path';
+use File::Temp qw/tempdir/;
+use File::Basename;
+use File::Spec::Functions;
+
+my $rf = \&KorAP::ScriptLoad::_parse_load;
+
+my ($name, $desc, @def) = $rf->(q!echo -e "W-gesamt-2022-I - W-gesamt von Release DeReKo-2022-I _Blue_\tLOAD('corp-w-gesamt.2022-i.21.06.22')" >> $CDFile !);
+
+is($name, 'W-gesamt-2022-I');
+is($desc, 'W-gesamt von Release DeReKo-2022-I');
+is($def[0], 'corp-w-gesamt.2022-i.21.06.22');
+
+($name, $desc, @def) = $rf->(q! echo -e "W-gesamt-2017-I - W-gesamt von Release DeReKo-2017-I _Blue_\tLOAD('corp-w-gesamt.2017-i.17.10.17')\tG_UWV" >> $CDFile !);
+
+is($name, 'W-gesamt-2017-I');
+is($desc, 'W-gesamt von Release DeReKo-2017-I');
+is($def[0], 'corp-w-gesamt.2017-i.17.10.17');
+
+($name, $desc, @def) = $rf->(q! echo -e "lit - Belletristik/Trivialliteratur _Maroon_ \tLOAD('bih bio bio-pub div div-pub gr1 gri hes kjl les wam thm-lit misc-lit')" >>$CDFile !);
+
+is($name, 'lit');
+is($desc, 'Belletristik/Trivialliteratur');
+is($def[0], 'bih');
+is($def[-1], 'misc-lit');
+
+($name, $desc, @def) = $rf->(q!echo -e "W2-öffentlich - alle öffentlichen Korpora des Archivs W2 (mit Neuakquisitionen) _B__BLUE_\tLOAD('aan aaz abo alz art azm baz bdz bee bez bku bla bli boz brg brm bru brw bun bup bwa bsz bze chk cou ctb dak daz dec dki dnn dol dpr dog edf eft elf elt ett eut euw fis fmt fnp fom fra frt gal gaz ge geo ges gingko gng gob gsp gta gtb hab hau hfz hhz hkr hrz hst htb hzs hzw hzz ix k kaz ksa kur ktz lah lan laz lmd lru msp ndo neo noz nwt osz paz ph pmm scw stb stg tvd vbw vzs w was weo div')" >>$CDFile !);
+
+is($name, 'W2-öffentlich');
+is($desc, 'alle öffentlichen Korpora des Archivs W2 (mit Neuakquisitionen)');
+is($def[0], 'aan');
+is($def[-1], 'div');
+
+($name, $desc, @def) = $rf->(q!div - Belletristik des 20. und 21. Jahrhunderts: Diverse Schriftsteller LOAD('div div-pub')!);
+
+is($name, 'div');
+is($desc, 'Belletristik des 20. und 21. Jahrhunderts: Diverse Schriftsteller');
+is($def[0], 'div');
+is($def[-1], 'div-pub');
+
+
+($name, $desc, @def) = $rf->(q!echo -e "N-gesamt - alle Neuakquisitionen von DeReKo-2024-I _B__Blue_\tLOAD('bih bio bio-pub l bvz brz bzk b ct cz dck div div-pub dkg dpa p erk flt faz foc frr fsp fsp-pub goe gr1 gri haz hbk hes hmp iko ix kic kjl klz ksp les lim lmd ltb mk1 mk2 mld m neu new ng nku nkz non nun nuz nzf nzs nzz oon pp prf rei rhp rhz sbl sbn a sid soz s spk sol ste stg u tas t thm ttz van vdi wam wkb wkd wkv wxx11 wwo zca zcw z zge e zwi -corp-w-gesamt.2023-i.16.03.23')" >>$CDFile!);
+
+is($name, 'N-gesamt');
+is($desc, 'alle Neuakquisitionen von DeReKo-2024-I');
+is($def[0], 'bih');
+is($def[-1], '-corp-w-gesamt.2023-i.16.03.23');
+
+
+# Load script file
+my $script_file = catfile(dirname(__FILE__), 'data', 'doVirtBms.w.all.2024-I');
+my $output = tempdir( CLEANUP => 1 );
+
+my $load = KorAP::ScriptLoad->new(
+ file => $script_file,
+ output => $output
+);
+
+$load->parse;
+
+ok(-e catfile($output, 'wkd.jsonld'));
+ok(-e catfile($output, 'taz.jsonld'));
+ok(-e catfile($output, 'stg.jsonld'));
+ok(-e catfile($output, 'zwi.jsonld'));
+
+my $f = Mojo::File->new(catfile($output, 'lit.jsonld'));
+
+my $coll = decode_json($f->slurp);
+
+is($coll->{collection}->{operation},'operation:or');
+is($coll->{collection}->{operands}->[0]->{'ref'},'bih');
+is($coll->{collection}->{operands}->[-1]->{'ref'},'misc-lit');
+
+
+$f = Mojo::File->new(catfile($output, 'N-gesamt.jsonld'));
+
+$coll = decode_json($f->slurp);
+
+is($coll->{collection}->{operation},'operation:and');
+is($coll->{collection}->{operands}->[0]->{operands}->[0]->{'ref'},'bih');
+is($coll->{collection}->{operands}->[-1]->{'ref'}, 'corp-w-gesamt.2023-i.16.03.23');
+is($coll->{collection}->{operands}->[-1]->{'match'}, 'match:ne');
+
+
+
+
+done_testing;