blob: 2e205683a6ead65c5cf4bba17484f5fa2b929678 [file] [log] [blame]
#!/usr/bin/env perl
use strict;
use warnings;
use KorAP::Def;
use KorAP::DefList;
use lib 'lib';
use Getopt::Long;
# 2020-05-20
# Preliminary support for C2 def-files.
# 2020-05-29
# Introduce optimizable object system.
# 2024-07-17
# Add KorAP::Def.
our $VERSION = 0.2;
our @ARGV;
my $cmd = shift @ARGV;
my ($input, $output, $copysrc);
GetOptions (
"input|i=s" => \$input,
"output|o=s" => \$output,
"copy-src|c=s" => \$copysrc,
)
or die("Error in command line arguments\n");
if ($cmd ne 'def' && $cmd ne 'list') {
print <<'HELP';
Convert a list of C2 VC definitions or a single definition into
KoralQuery VCs.
$ perl cosmasvc2koralquery def my_vc.txt | gzip -vc > my_vc.jsonld.gz
$ cat my_vc.txt | perl cosmasvc2koralquery def - | gzip -vc > my_vc.jsonld.gz
Command: def
Convert a def file or a list of sigles to a KoralQuery VC.
Takes the list or def from STDIN and exports to STDOUT.
Command: list
Convert a list with copy or regex instructions to KoralQuery VCs.
--output: The output directory
--copy-src: The directory for def files to copy
HELP
exit 1;
};
# Process a list
if ($cmd eq 'list') {
KorAP::DefList->new(
file => ($input || $ARGV[0]),
copy => ($copysrc || '.'),
output => ($output || '.')
)->parse;
exit(0);
};
# Parse a single def
my $def_parser;
if ($ARGV[0] eq '-') {
$def_parser = KorAP::Def->new(\*STDIN);
}
elsif ($input) {
$def_parser = KorAP::Def->new($input);
}
else {
$def_parser = KorAP::Def->new($ARGV[0]);
};
$def_parser->parse;
# Stringify current (extended?) virtual corpus
print $def_parser->to_string;