blob: a95605f320893c8e00432c464eb88d65050234c9 [file] [log] [blame]
Akron3f875be2020-05-11 14:57:19 +02001#!/usr/bin/env perl
Akron3587f362020-05-20 17:50:38 +02002use strict;
3use warnings;
Akron71cf2f52024-07-17 08:54:15 +02004use KorAP::Def;
Akrona3f74f52024-07-17 17:18:17 +02005use KorAP::DefList;
Akron34a4f582020-05-27 12:18:57 +02006use lib 'lib';
Akrona3f74f52024-07-17 17:18:17 +02007use Getopt::Long;
Akron3f875be2020-05-11 14:57:19 +02008
Akron340a9cb2020-05-20 12:55:22 +02009# 2020-05-20
10# Preliminary support for C2 def-files.
Akron34a4f582020-05-27 12:18:57 +020011# 2020-05-29
12# Introduce optimizable object system.
Akron71cf2f52024-07-17 08:54:15 +020013# 2024-07-17
14# Add KorAP::Def.
Akron340a9cb2020-05-20 12:55:22 +020015
Akron71cf2f52024-07-17 08:54:15 +020016our $VERSION = 0.2;
Akron26b59702020-05-19 12:14:41 +020017our @ARGV;
18
Akrona3f74f52024-07-17 17:18:17 +020019my $cmd = shift @ARGV;
Akron3f875be2020-05-11 14:57:19 +020020
Akrona3f74f52024-07-17 17:18:17 +020021
22my $input;
23
24GetOptions (
25 "input|i=s" => \$input
26)
27or die("Error in command line arguments\n");
28
29if ($cmd ne 'def' && $cmd ne 'list') {
30 print <<'HELP';
31Convert a list of C2 VC definitions or a single definition into
32KoralQuery VCs.
33
34 $ perl cosmasvc2koralquery def my_vc.txt | gzip -vc > my_vc.jsonld.gz
35 $ cat my_vc.txt | perl cosmasvc2koralquery def - | gzip -vc > my_vc.jsonld.gz
36
37Commands: def, list
Akron3f875be2020-05-11 14:57:19 +020038
39HELP
Akrona3f74f52024-07-17 17:18:17 +020040exit 1;
Akron3f875be2020-05-11 14:57:19 +020041};
42
Akrona3f74f52024-07-17 17:18:17 +020043
44# Process a list
45if ($cmd eq 'list') {
46 KorAP::DefList->new($input || $ARGV[0])->parse;
47 exit(0);
48};
49
50# Parse a single def
Akron71cf2f52024-07-17 08:54:15 +020051my $def_parser;
Akron26b59702020-05-19 12:14:41 +020052if ($ARGV[0] eq '-') {
Akron71cf2f52024-07-17 08:54:15 +020053 $def_parser = KorAP::Def->new(\*STDIN);
54}
Akrona3f74f52024-07-17 17:18:17 +020055elsif ($input) {
56 $def_parser = KorAP::Def->new($input);
57}
Akron71cf2f52024-07-17 08:54:15 +020058else {
59 $def_parser = KorAP::Def->new($ARGV[0]);
Akron3f875be2020-05-11 14:57:19 +020060};
61
Akron71cf2f52024-07-17 08:54:15 +020062$def_parser->parse;
Akron26b59702020-05-19 12:14:41 +020063
Akron1c070452020-05-25 11:28:30 +020064# Stringify current (extended?) virtual corpus
Akron71cf2f52024-07-17 08:54:15 +020065print $def_parser->to_string;