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