blob: fbdb721dcc669264005168d7dcc65dd9c4459e23 [file] [log] [blame]
Akrona3f74f52024-07-17 17:18:17 +02001#!/usr/bin/env perl
2use strict;
3use warnings;
4use Test::More;
5use KorAP::DefList;
6use Mojo::JSON 'decode_json';
7
8my $rf = \&KorAP::DefList::from_regex;
9
10sub _collection {
11 return decode_json($rf->(@_)->to_string)->{collection}
12}
13
14my $doc = _collection("x",'Name','Beschreibung');
15is($doc->{key},'corpusSigle');
16is($doc->{value},'x');
17is($doc->{type},'type:string');
18is($doc->{comment},'name:"Name",desc:"Beschreibung"');
19
20$doc = _collection("x/");
21is($doc->{key},'corpusSigle');
22is($doc->{value},'x');
23is($doc->{type},'type:string');
24
25$doc = _collection("x[0-3]",'Na"me','Besch"re\'ibung');
26is($doc->{key},'corpusSigle');
27is($doc->{value},'x[0-3]');
28is($doc->{type},'type:regex');
29is($doc->{comment},'name:"Na\"me",desc:"Besch\"re\'ibung"');
30
31$doc = _collection('x[0-3]/');
32is($doc->{key},'corpusSigle');
33is($doc->{value},'x[0-3]');
34is($doc->{type},'type:regex');
35
36$doc = _collection('BIO/(BKA|LTI|TK1|TK2|TK3|TK4|TK5|TK6)');
37is($doc->{key},'docSigle');
38is($doc->{value},'BIO/(BKA|LTI|TK1|TK2|TK3|TK4|TK5|TK6)');
39is($doc->{type},'type:regex');
40
41$doc = _collection('(GOE/(AGD|AGM|AGN|AGV|AGW))|(MK1/(LBC|LBT|LFH|LGB|LJA|LMB|LSO|MHE|TJM|TPM))|(MK2/TRI)');
42is($doc->{key},'docSigle');
43is($doc->{value},'(GOE/(AGD|AGM|AGN|AGV|AGW))|(MK1/(LBC|LBT|LFH|LGB|LJA|LMB|LSO|MHE|TJM|TPM))|(MK2/TRI)');
44is($doc->{type},'type:regex');
45
46$doc = _collection('FSP/~FSP/(ANG|ANR|EIN|GEB|KAR|REI|SCH|TYP|VER|VID)','fsp-pub','Fachsprachenkorpus');
47
48is($doc->{'@type'},'koral:docGroup');
49is($doc->{'operation'},'operation:and');
50is($doc->{operands}->[0]->{type},'type:string');
51is($doc->{operands}->[0]->{match},'match:eq');
52is($doc->{operands}->[0]->{key},'corpusSigle');
53is($doc->{operands}->[0]->{value},'FSP');
54is($doc->{operands}->[1]->{type},'type:regex');
55is($doc->{operands}->[1]->{match},'match:ne');
56is($doc->{operands}->[1]->{key},'docSigle');
57is($doc->{operands}->[1]->{value},'FSP/(ANG|ANR|EIN|GEB|KAR|REI|SCH|TYP|VER|VID)');
58
59done_testing;