blob: 49fefb83af80d6f4bc686ee1adb1923da4444a4f [file] [log] [blame]
Akron7dacd012020-05-27 12:18:57 +02001package KorAP::VirtualCorpus::DocVec;
2use strict;
3use warnings;
4use base 'KorAP::VirtualCorpus::Doc';
5
6# Constructor
7sub new {
8 my $class = shift;
9 bless {
10 key => shift,
11 match => 'eq',
12 type => 'string',
13 value => []
14 }, $class;
15};
16
17# Return object type
18sub koral_type {
19 return 'DocVec';
20};
21
22# Get or set value
23sub value {
24 my $self = shift;
25 if (@_) {
26 $self->{value} = [@_];
27 return $self;
28 };
29 return $self->{value};
30};
31
32# Stringify fragment
33sub _to_fragment {
34 my $self = shift;
35 my $json = '{';
36 $json .= '"@type":"koral:doc",';
37 $json .= '"type":"type:' . $self->type . '",';
38 $json .= '"match":"match:' . $self->match . '",';
39 $json .= '"key":"' . $self->key . '",';
40 $json .= '"value":[' . join(',', map { $self->quote($_) } @{$self->value}) . ']';
41
42 # Set at the end, when all comments are done
43 $json .= $self->_commentparam_to_string;
44 return $json . '}';
45};
46
47
481;