line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wikibase::Datatype::Struct::Item; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
1053139
|
use base qw(Exporter); |
|
4
|
|
|
|
|
46
|
|
|
4
|
|
|
|
|
387
|
|
4
|
4
|
|
|
4
|
|
28
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
93
|
|
5
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
105
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
1397
|
use Error::Pure qw(err); |
|
4
|
|
|
|
|
23735
|
|
|
4
|
|
|
|
|
98
|
|
8
|
4
|
|
|
4
|
|
164
|
use Readonly; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
147
|
|
9
|
4
|
|
|
4
|
|
1647
|
use Wikibase::Datatype::Item; |
|
4
|
|
|
|
|
1682586
|
|
|
4
|
|
|
|
|
143
|
|
10
|
4
|
|
|
4
|
|
1839
|
use Wikibase::Datatype::Struct::Language; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
163
|
|
11
|
4
|
|
|
4
|
|
1695
|
use Wikibase::Datatype::Struct::Sitelink; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
171
|
|
12
|
4
|
|
|
4
|
|
1823
|
use Wikibase::Datatype::Struct::Statement; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
177
|
|
13
|
4
|
|
|
4
|
|
32
|
use Wikibase::Datatype::Struct::Value::Monolingual; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
3663
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw(obj2struct struct2obj); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = 0.11; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub obj2struct { |
20
|
7
|
|
|
7
|
1
|
48773
|
my ($obj, $base_uri) = @_; |
21
|
|
|
|
|
|
|
|
22
|
7
|
100
|
|
|
|
25
|
if (! defined $obj) { |
23
|
1
|
|
|
|
|
6
|
err "Object doesn't exist."; |
24
|
|
|
|
|
|
|
} |
25
|
6
|
100
|
|
|
|
35
|
if (! $obj->isa('Wikibase::Datatype::Item')) { |
26
|
1
|
|
|
|
|
5
|
err "Object isn't 'Wikibase::Datatype::Item'."; |
27
|
|
|
|
|
|
|
} |
28
|
5
|
100
|
|
|
|
11
|
if (! defined $base_uri) { |
29
|
1
|
|
|
|
|
5
|
err 'Base URI is required.'; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
4
|
|
|
|
|
15
|
my $struct_hr = { |
33
|
|
|
|
|
|
|
'type' => 'item', |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Aliases. |
37
|
4
|
|
|
|
|
10
|
foreach my $alias (@{$obj->aliases}) { |
|
4
|
|
|
|
|
14
|
|
38
|
4
|
100
|
|
|
|
17
|
if (! exists $struct_hr->{'aliases'}->{$alias->language}) { |
39
|
2
|
|
|
|
|
28
|
$struct_hr->{'aliases'}->{$alias->language} = []; |
40
|
|
|
|
|
|
|
} |
41
|
4
|
|
|
|
|
25
|
push @{$struct_hr->{'aliases'}->{$alias->language}}, |
|
4
|
|
|
|
|
8
|
|
42
|
|
|
|
|
|
|
Wikibase::Datatype::Struct::Language::obj2struct($alias); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Claims. |
46
|
4
|
|
|
|
|
37
|
foreach my $statement (@{$obj->statements}) { |
|
4
|
|
|
|
|
13
|
|
47
|
4
|
|
100
|
|
|
31
|
$struct_hr->{'claims'}->{$statement->snak->property} //= []; |
48
|
4
|
|
|
|
|
63
|
push @{$struct_hr->{'claims'}->{$statement->snak->property}}, |
|
4
|
|
|
|
|
13
|
|
49
|
|
|
|
|
|
|
Wikibase::Datatype::Struct::Statement::obj2struct($statement, $base_uri); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Descriptions. |
53
|
4
|
|
|
|
|
23
|
foreach my $desc (@{$obj->descriptions}) { |
|
4
|
|
|
|
|
9
|
|
54
|
2
|
|
|
|
|
18
|
$struct_hr->{'descriptions'}->{$desc->language} |
55
|
|
|
|
|
|
|
= Wikibase::Datatype::Struct::Language::obj2struct($desc); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Id. |
59
|
4
|
100
|
|
|
|
35
|
if (defined $obj->id) { |
60
|
1
|
|
|
|
|
7
|
$struct_hr->{'id'} = $obj->id; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Labels. |
64
|
4
|
|
|
|
|
27
|
foreach my $label (@{$obj->labels}) { |
|
4
|
|
|
|
|
11
|
|
65
|
2
|
|
|
|
|
16
|
$struct_hr->{'labels'}->{$label->language} |
66
|
|
|
|
|
|
|
= Wikibase::Datatype::Struct::Language::obj2struct($label); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# Last revision id. |
70
|
4
|
100
|
|
|
|
36
|
if (defined $obj->lastrevid) { |
71
|
1
|
|
|
|
|
8
|
$struct_hr->{'lastrevid'} = $obj->lastrevid; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Modified date. |
75
|
4
|
100
|
|
|
|
33
|
if (defined $obj->modified) { |
76
|
1
|
|
|
|
|
7
|
$struct_hr->{'modified'} = $obj->modified; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# Namespace. |
80
|
4
|
100
|
|
|
|
32
|
if (defined $obj->ns) { |
81
|
3
|
|
|
|
|
75
|
$struct_hr->{'ns'} = $obj->ns; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Page ID. |
85
|
4
|
100
|
|
|
|
43
|
if (defined $obj->page_id) { |
86
|
1
|
|
|
|
|
7
|
$struct_hr->{'pageid'} = $obj->page_id; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# Sitelinks. |
90
|
4
|
|
|
|
|
24
|
foreach my $sitelink (@{$obj->sitelinks}) { |
|
4
|
|
|
|
|
9
|
|
91
|
2
|
|
|
|
|
17
|
$struct_hr->{'sitelinks'}->{$sitelink->site} |
92
|
|
|
|
|
|
|
= Wikibase::Datatype::Struct::Sitelink::obj2struct($sitelink); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# Title. |
96
|
4
|
100
|
|
|
|
34
|
if (defined $obj->title) { |
97
|
1
|
|
|
|
|
8
|
$struct_hr->{'title'} = $obj->title; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
4
|
|
|
|
|
110
|
return $struct_hr; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub struct2obj { |
104
|
5
|
|
|
5
|
1
|
14348
|
my $struct_hr = shift; |
105
|
|
|
|
|
|
|
|
106
|
5
|
100
|
100
|
|
|
32
|
if (! exists $struct_hr->{'type'} || $struct_hr->{'type'} ne 'item') { |
107
|
2
|
|
|
|
|
10
|
err "Structure isn't for 'item' type."; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# Aliases. |
111
|
3
|
|
|
|
|
8
|
my $aliases_ar = []; |
112
|
3
|
|
|
|
|
7
|
foreach my $lang (keys %{$struct_hr->{'aliases'}}) { |
|
3
|
|
|
|
|
15
|
|
113
|
2
|
|
|
|
|
6
|
foreach my $alias_hr (@{$struct_hr->{'aliases'}->{$lang}}) { |
|
2
|
|
|
|
|
6
|
|
114
|
4
|
|
|
|
|
7
|
push @{$aliases_ar}, Wikibase::Datatype::Struct::Language::struct2obj( |
|
4
|
|
|
|
|
68
|
|
115
|
|
|
|
|
|
|
$alias_hr, |
116
|
|
|
|
|
|
|
); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# Descriptions. |
121
|
3
|
|
|
|
|
9
|
my $descriptions_ar = []; |
122
|
3
|
|
|
|
|
4
|
foreach my $lang (keys %{$struct_hr->{'descriptions'}}) { |
|
3
|
|
|
|
|
11
|
|
123
|
2
|
|
|
|
|
19
|
push @{$descriptions_ar}, Wikibase::Datatype::Struct::Language::struct2obj( |
124
|
2
|
|
|
|
|
5
|
$struct_hr->{'descriptions'}->{$lang}, |
125
|
|
|
|
|
|
|
); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# Labels. |
129
|
3
|
|
|
|
|
356
|
my $labels_ar = []; |
130
|
3
|
|
|
|
|
9
|
foreach my $lang (keys %{$struct_hr->{'labels'}}) { |
|
3
|
|
|
|
|
10
|
|
131
|
2
|
|
|
|
|
7
|
push @{$labels_ar}, Wikibase::Datatype::Struct::Language::struct2obj( |
132
|
2
|
|
|
|
|
6
|
$struct_hr->{'labels'}->{$lang}, |
133
|
|
|
|
|
|
|
); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# Sitelinks. |
137
|
3
|
|
|
|
|
7
|
my $sitelinks_ar = []; |
138
|
3
|
|
|
|
|
6
|
foreach my $site (keys %{$struct_hr->{'sitelinks'}}) { |
|
3
|
|
|
|
|
12
|
|
139
|
2
|
|
|
|
|
7
|
push @{$sitelinks_ar}, Wikibase::Datatype::Struct::Sitelink::struct2obj( |
140
|
2
|
|
|
|
|
4
|
$struct_hr->{'sitelinks'}->{$site}, |
141
|
|
|
|
|
|
|
); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
# Statements. |
145
|
3
|
|
|
|
|
7
|
my $statements_ar = []; |
146
|
3
|
|
|
|
|
5
|
foreach my $property (keys %{$struct_hr->{'claims'}}) { |
|
3
|
|
|
|
|
11
|
|
147
|
2
|
|
|
|
|
4
|
foreach my $claim_hr (@{$struct_hr->{'claims'}->{$property}}) { |
|
2
|
|
|
|
|
9
|
|
148
|
2
|
|
|
|
|
5
|
push @{$statements_ar}, Wikibase::Datatype::Struct::Statement::struct2obj( |
|
2
|
|
|
|
|
8
|
|
149
|
|
|
|
|
|
|
$claim_hr, |
150
|
|
|
|
|
|
|
); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::Item->new( |
155
|
|
|
|
|
|
|
'aliases' => $aliases_ar, |
156
|
|
|
|
|
|
|
'descriptions' => $descriptions_ar, |
157
|
|
|
|
|
|
|
defined $struct_hr->{'id'} ? ('id' => $struct_hr->{'id'}) : (), |
158
|
|
|
|
|
|
|
'labels' => $labels_ar, |
159
|
|
|
|
|
|
|
defined $struct_hr->{'lastrevid'} ? ('lastrevid' => $struct_hr->{'lastrevid'}) : (), |
160
|
|
|
|
|
|
|
defined $struct_hr->{'modified'} ? ('modified' => $struct_hr->{'modified'}) : (), |
161
|
|
|
|
|
|
|
defined $struct_hr->{'ns'} ? ('ns' => $struct_hr->{'ns'}) : (), |
162
|
|
|
|
|
|
|
defined $struct_hr->{'pageid'} ? ('page_id' => $struct_hr->{'pageid'}) : (), |
163
|
|
|
|
|
|
|
'sitelinks' => $sitelinks_ar, |
164
|
|
|
|
|
|
|
'statements' => $statements_ar, |
165
|
3
|
100
|
|
|
|
94
|
defined $struct_hr->{'title'} ? ('title' => $struct_hr->{'title'}) : (), |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
166
|
|
|
|
|
|
|
); |
167
|
|
|
|
|
|
|
|
168
|
3
|
|
|
|
|
827
|
return $obj; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
1; |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
__END__ |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=pod |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=encoding utf8 |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 NAME |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Wikibase::Datatype::Struct::Item - Wikibase item structure serialization. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 SYNOPSIS |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
use Wikibase::Datatype::Struct::Item qw(obj2struct struct2obj); |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
my $struct_hr = obj2struct($obj, $base_uri); |
188
|
|
|
|
|
|
|
my $obj = struct2obj($struct_hr); |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head1 DESCRIPTION |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
This conversion is between objects defined in Wikibase::Datatype and structures |
193
|
|
|
|
|
|
|
serialized via JSON to MediaWiki. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 SUBROUTINES |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head2 C<obj2struct> |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
my $struct_hr = obj2struct($obj, $base_uri); |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
Convert Wikibase::Datatype::Item instance to structure. |
202
|
|
|
|
|
|
|
C<$base_uri> is base URI of Wikibase system (e.g. http://test.wikidata.org/entity/). |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Returns reference to hash with structure. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head2 C<struct2obj> |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
my $obj = struct2obj($struct_hr); |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Convert structure of item to object. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
Returns Wikibase::Datatype::Item instance. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head1 ERRORS |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
obj2struct(): |
217
|
|
|
|
|
|
|
Base URI is required. |
218
|
|
|
|
|
|
|
Object doesn't exist. |
219
|
|
|
|
|
|
|
Object isn't 'Wikibase::Datatype::Item'. |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
struct2obj(): |
222
|
|
|
|
|
|
|
Structure isn't for 'item' type. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 EXAMPLE1 |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=for comment filename=obj2struct_item.pl |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
use strict; |
229
|
|
|
|
|
|
|
use warnings; |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
use Data::Printer; |
232
|
|
|
|
|
|
|
use Wikibase::Datatype::Item; |
233
|
|
|
|
|
|
|
use Wikibase::Datatype::Reference; |
234
|
|
|
|
|
|
|
use Wikibase::Datatype::Sitelink; |
235
|
|
|
|
|
|
|
use Wikibase::Datatype::Snak; |
236
|
|
|
|
|
|
|
use Wikibase::Datatype::Statement; |
237
|
|
|
|
|
|
|
use Wikibase::Datatype::Struct::Item qw(obj2struct); |
238
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::Item; |
239
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::Monolingual; |
240
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::String; |
241
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::Time; |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
# Object. |
244
|
|
|
|
|
|
|
my $statement1 = Wikibase::Datatype::Statement->new( |
245
|
|
|
|
|
|
|
# instance of (P31) human (Q5) |
246
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
247
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
248
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
249
|
|
|
|
|
|
|
'value' => 'Q5', |
250
|
|
|
|
|
|
|
), |
251
|
|
|
|
|
|
|
'property' => 'P31', |
252
|
|
|
|
|
|
|
), |
253
|
|
|
|
|
|
|
'property_snaks' => [ |
254
|
|
|
|
|
|
|
# of (P642) alien (Q474741) |
255
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
256
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
257
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
258
|
|
|
|
|
|
|
'value' => 'Q474741', |
259
|
|
|
|
|
|
|
), |
260
|
|
|
|
|
|
|
'property' => 'P642', |
261
|
|
|
|
|
|
|
), |
262
|
|
|
|
|
|
|
], |
263
|
|
|
|
|
|
|
'references' => [ |
264
|
|
|
|
|
|
|
Wikibase::Datatype::Reference->new( |
265
|
|
|
|
|
|
|
'snaks' => [ |
266
|
|
|
|
|
|
|
# stated in (P248) Virtual International Authority File (Q53919) |
267
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
268
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
269
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
270
|
|
|
|
|
|
|
'value' => 'Q53919', |
271
|
|
|
|
|
|
|
), |
272
|
|
|
|
|
|
|
'property' => 'P248', |
273
|
|
|
|
|
|
|
), |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
# VIAF ID (P214) 113230702 |
276
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
277
|
|
|
|
|
|
|
'datatype' => 'external-id', |
278
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::String->new( |
279
|
|
|
|
|
|
|
'value' => '113230702', |
280
|
|
|
|
|
|
|
), |
281
|
|
|
|
|
|
|
'property' => 'P214', |
282
|
|
|
|
|
|
|
), |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
# retrieved (P813) 7 December 2013 |
285
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
286
|
|
|
|
|
|
|
'datatype' => 'time', |
287
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Time->new( |
288
|
|
|
|
|
|
|
'value' => '+2013-12-07T00:00:00Z', |
289
|
|
|
|
|
|
|
), |
290
|
|
|
|
|
|
|
'property' => 'P813', |
291
|
|
|
|
|
|
|
), |
292
|
|
|
|
|
|
|
], |
293
|
|
|
|
|
|
|
), |
294
|
|
|
|
|
|
|
], |
295
|
|
|
|
|
|
|
); |
296
|
|
|
|
|
|
|
my $statement2 = Wikibase::Datatype::Statement->new( |
297
|
|
|
|
|
|
|
# sex or gender (P21) male (Q6581097) |
298
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
299
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
300
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
301
|
|
|
|
|
|
|
'value' => 'Q6581097', |
302
|
|
|
|
|
|
|
), |
303
|
|
|
|
|
|
|
'property' => 'P21', |
304
|
|
|
|
|
|
|
), |
305
|
|
|
|
|
|
|
'references' => [ |
306
|
|
|
|
|
|
|
Wikibase::Datatype::Reference->new( |
307
|
|
|
|
|
|
|
'snaks' => [ |
308
|
|
|
|
|
|
|
# stated in (P248) Virtual International Authority File (Q53919) |
309
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
310
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
311
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
312
|
|
|
|
|
|
|
'value' => 'Q53919', |
313
|
|
|
|
|
|
|
), |
314
|
|
|
|
|
|
|
'property' => 'P248', |
315
|
|
|
|
|
|
|
), |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
# VIAF ID (P214) 113230702 |
318
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
319
|
|
|
|
|
|
|
'datatype' => 'external-id', |
320
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::String->new( |
321
|
|
|
|
|
|
|
'value' => '113230702', |
322
|
|
|
|
|
|
|
), |
323
|
|
|
|
|
|
|
'property' => 'P214', |
324
|
|
|
|
|
|
|
), |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
# retrieved (P813) 7 December 2013 |
327
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
328
|
|
|
|
|
|
|
'datatype' => 'time', |
329
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Time->new( |
330
|
|
|
|
|
|
|
'value' => '+2013-12-07T00:00:00Z', |
331
|
|
|
|
|
|
|
), |
332
|
|
|
|
|
|
|
'property' => 'P813', |
333
|
|
|
|
|
|
|
), |
334
|
|
|
|
|
|
|
], |
335
|
|
|
|
|
|
|
), |
336
|
|
|
|
|
|
|
], |
337
|
|
|
|
|
|
|
); |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
# Main item. |
340
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::Item->new( |
341
|
|
|
|
|
|
|
'aliases' => [ |
342
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
343
|
|
|
|
|
|
|
'language' => 'cs', |
344
|
|
|
|
|
|
|
'value' => 'Douglas Noël Adams', |
345
|
|
|
|
|
|
|
), |
346
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
347
|
|
|
|
|
|
|
'language' => 'cs', |
348
|
|
|
|
|
|
|
'value' => 'Douglas Noel Adams', |
349
|
|
|
|
|
|
|
), |
350
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
351
|
|
|
|
|
|
|
'language' => 'cs', |
352
|
|
|
|
|
|
|
'value' => 'Douglas N. Adams', |
353
|
|
|
|
|
|
|
), |
354
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
355
|
|
|
|
|
|
|
'language' => 'en', |
356
|
|
|
|
|
|
|
'value' => 'Douglas Noel Adams', |
357
|
|
|
|
|
|
|
), |
358
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
359
|
|
|
|
|
|
|
'language' => 'en', |
360
|
|
|
|
|
|
|
'value' => 'Douglas Noël Adams', |
361
|
|
|
|
|
|
|
), |
362
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
363
|
|
|
|
|
|
|
'language' => 'en', |
364
|
|
|
|
|
|
|
'value' => 'Douglas N. Adams', |
365
|
|
|
|
|
|
|
), |
366
|
|
|
|
|
|
|
], |
367
|
|
|
|
|
|
|
'descriptions' => [ |
368
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
369
|
|
|
|
|
|
|
'language' => 'cs', |
370
|
|
|
|
|
|
|
'value' => 'anglický spisovatel, humorista a dramatik', |
371
|
|
|
|
|
|
|
), |
372
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
373
|
|
|
|
|
|
|
'language' => 'en', |
374
|
|
|
|
|
|
|
'value' => 'English writer and humorist', |
375
|
|
|
|
|
|
|
), |
376
|
|
|
|
|
|
|
], |
377
|
|
|
|
|
|
|
'id' => 'Q42', |
378
|
|
|
|
|
|
|
'labels' => [ |
379
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
380
|
|
|
|
|
|
|
'language' => 'cs', |
381
|
|
|
|
|
|
|
'value' => 'Douglas Adams', |
382
|
|
|
|
|
|
|
), |
383
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
384
|
|
|
|
|
|
|
'language' => 'en', |
385
|
|
|
|
|
|
|
'value' => 'Douglas Adams', |
386
|
|
|
|
|
|
|
), |
387
|
|
|
|
|
|
|
], |
388
|
|
|
|
|
|
|
'page_id' => 123, |
389
|
|
|
|
|
|
|
'sitelinks' => [ |
390
|
|
|
|
|
|
|
Wikibase::Datatype::Sitelink->new( |
391
|
|
|
|
|
|
|
'site' => 'cswiki', |
392
|
|
|
|
|
|
|
'title' => 'Douglas Adams', |
393
|
|
|
|
|
|
|
), |
394
|
|
|
|
|
|
|
Wikibase::Datatype::Sitelink->new( |
395
|
|
|
|
|
|
|
'site' => 'enwiki', |
396
|
|
|
|
|
|
|
'title' => 'Douglas Adams', |
397
|
|
|
|
|
|
|
), |
398
|
|
|
|
|
|
|
], |
399
|
|
|
|
|
|
|
'statements' => [ |
400
|
|
|
|
|
|
|
$statement1, |
401
|
|
|
|
|
|
|
$statement2, |
402
|
|
|
|
|
|
|
], |
403
|
|
|
|
|
|
|
'title' => 'Q42', |
404
|
|
|
|
|
|
|
); |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
# Get structure. |
407
|
|
|
|
|
|
|
my $struct_hr = obj2struct($obj, 'http://test.wikidata.org/entity/'); |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
# Dump to output. |
410
|
|
|
|
|
|
|
p $struct_hr; |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
# Output: |
413
|
|
|
|
|
|
|
# \ { |
414
|
|
|
|
|
|
|
# aliases { |
415
|
|
|
|
|
|
|
# cs [ |
416
|
|
|
|
|
|
|
# [0] { |
417
|
|
|
|
|
|
|
# language "cs", |
418
|
|
|
|
|
|
|
# value "Douglas Noël Adams" |
419
|
|
|
|
|
|
|
# }, |
420
|
|
|
|
|
|
|
# [1] { |
421
|
|
|
|
|
|
|
# language "cs", |
422
|
|
|
|
|
|
|
# value "Douglas Noel Adams" |
423
|
|
|
|
|
|
|
# }, |
424
|
|
|
|
|
|
|
# [2] { |
425
|
|
|
|
|
|
|
# language "cs", |
426
|
|
|
|
|
|
|
# value "Douglas N. Adams" |
427
|
|
|
|
|
|
|
# } |
428
|
|
|
|
|
|
|
# ], |
429
|
|
|
|
|
|
|
# en [ |
430
|
|
|
|
|
|
|
# [0] { |
431
|
|
|
|
|
|
|
# language "en", |
432
|
|
|
|
|
|
|
# value "Douglas Noel Adams" |
433
|
|
|
|
|
|
|
# }, |
434
|
|
|
|
|
|
|
# [1] { |
435
|
|
|
|
|
|
|
# language "en", |
436
|
|
|
|
|
|
|
# value "Douglas Noël Adams" |
437
|
|
|
|
|
|
|
# }, |
438
|
|
|
|
|
|
|
# [2] { |
439
|
|
|
|
|
|
|
# language "en", |
440
|
|
|
|
|
|
|
# value "Douglas N. Adams" |
441
|
|
|
|
|
|
|
# } |
442
|
|
|
|
|
|
|
# ] |
443
|
|
|
|
|
|
|
# }, |
444
|
|
|
|
|
|
|
# descriptions { |
445
|
|
|
|
|
|
|
# cs { |
446
|
|
|
|
|
|
|
# language "cs", |
447
|
|
|
|
|
|
|
# value "anglický spisovatel, humorista a dramatik" |
448
|
|
|
|
|
|
|
# }, |
449
|
|
|
|
|
|
|
# en { |
450
|
|
|
|
|
|
|
# language "en", |
451
|
|
|
|
|
|
|
# value "English writer and humorist" |
452
|
|
|
|
|
|
|
# } |
453
|
|
|
|
|
|
|
# }, |
454
|
|
|
|
|
|
|
# id "Q42", |
455
|
|
|
|
|
|
|
# labels { |
456
|
|
|
|
|
|
|
# cs { |
457
|
|
|
|
|
|
|
# language "cs", |
458
|
|
|
|
|
|
|
# value "Douglas Adams" |
459
|
|
|
|
|
|
|
# }, |
460
|
|
|
|
|
|
|
# en { |
461
|
|
|
|
|
|
|
# language "en", |
462
|
|
|
|
|
|
|
# value "Douglas Adams" |
463
|
|
|
|
|
|
|
# } |
464
|
|
|
|
|
|
|
# }, |
465
|
|
|
|
|
|
|
# ns 0, |
466
|
|
|
|
|
|
|
# pageid 123, |
467
|
|
|
|
|
|
|
# sitelinks { |
468
|
|
|
|
|
|
|
# cswiki { |
469
|
|
|
|
|
|
|
# badges [], |
470
|
|
|
|
|
|
|
# site "cswiki", |
471
|
|
|
|
|
|
|
# title "Douglas Adams" |
472
|
|
|
|
|
|
|
# }, |
473
|
|
|
|
|
|
|
# enwiki { |
474
|
|
|
|
|
|
|
# badges [], |
475
|
|
|
|
|
|
|
# site "enwiki", |
476
|
|
|
|
|
|
|
# title "Douglas Adams" |
477
|
|
|
|
|
|
|
# } |
478
|
|
|
|
|
|
|
# }, |
479
|
|
|
|
|
|
|
# claims { |
480
|
|
|
|
|
|
|
# P21 [ |
481
|
|
|
|
|
|
|
# [0] { |
482
|
|
|
|
|
|
|
# mainsnak { |
483
|
|
|
|
|
|
|
# datatype "wikibase-item", |
484
|
|
|
|
|
|
|
# datavalue { |
485
|
|
|
|
|
|
|
# type "wikibase-entityid", |
486
|
|
|
|
|
|
|
# value { |
487
|
|
|
|
|
|
|
# entity-type "item", |
488
|
|
|
|
|
|
|
# id "Q6581097", |
489
|
|
|
|
|
|
|
# numeric-id 6581097 |
490
|
|
|
|
|
|
|
# } |
491
|
|
|
|
|
|
|
# }, |
492
|
|
|
|
|
|
|
# property "P21", |
493
|
|
|
|
|
|
|
# snaktype "value" |
494
|
|
|
|
|
|
|
# }, |
495
|
|
|
|
|
|
|
# rank "normal", |
496
|
|
|
|
|
|
|
# references [ |
497
|
|
|
|
|
|
|
# [0] { |
498
|
|
|
|
|
|
|
# snaks { |
499
|
|
|
|
|
|
|
# P214 [ |
500
|
|
|
|
|
|
|
# [0] { |
501
|
|
|
|
|
|
|
# datatype "external-id", |
502
|
|
|
|
|
|
|
# datavalue { |
503
|
|
|
|
|
|
|
# type "string", |
504
|
|
|
|
|
|
|
# value 113230702 |
505
|
|
|
|
|
|
|
# }, |
506
|
|
|
|
|
|
|
# property "P214", |
507
|
|
|
|
|
|
|
# snaktype "value" |
508
|
|
|
|
|
|
|
# } |
509
|
|
|
|
|
|
|
# ], |
510
|
|
|
|
|
|
|
# P248 [ |
511
|
|
|
|
|
|
|
# [0] { |
512
|
|
|
|
|
|
|
# datatype "wikibase-item", |
513
|
|
|
|
|
|
|
# datavalue { |
514
|
|
|
|
|
|
|
# type "wikibase-entityid", |
515
|
|
|
|
|
|
|
# value { |
516
|
|
|
|
|
|
|
# entity-type "item", |
517
|
|
|
|
|
|
|
# id "Q53919", |
518
|
|
|
|
|
|
|
# numeric-id 53919 |
519
|
|
|
|
|
|
|
# } |
520
|
|
|
|
|
|
|
# }, |
521
|
|
|
|
|
|
|
# property "P248", |
522
|
|
|
|
|
|
|
# snaktype "value" |
523
|
|
|
|
|
|
|
# } |
524
|
|
|
|
|
|
|
# ], |
525
|
|
|
|
|
|
|
# P813 [ |
526
|
|
|
|
|
|
|
# [0] { |
527
|
|
|
|
|
|
|
# datatype "time", |
528
|
|
|
|
|
|
|
# datavalue { |
529
|
|
|
|
|
|
|
# type "time", |
530
|
|
|
|
|
|
|
# value { |
531
|
|
|
|
|
|
|
# after 0, |
532
|
|
|
|
|
|
|
# before 0, |
533
|
|
|
|
|
|
|
# calendarmodel "http://test.wikidata.org/entity/Q1985727", |
534
|
|
|
|
|
|
|
# precision 11, |
535
|
|
|
|
|
|
|
# time "+2013-12-07T00:00:00Z", |
536
|
|
|
|
|
|
|
# timezone 0 |
537
|
|
|
|
|
|
|
# } |
538
|
|
|
|
|
|
|
# }, |
539
|
|
|
|
|
|
|
# property "P813", |
540
|
|
|
|
|
|
|
# snaktype "value" |
541
|
|
|
|
|
|
|
# } |
542
|
|
|
|
|
|
|
# ] |
543
|
|
|
|
|
|
|
# }, |
544
|
|
|
|
|
|
|
# snaks-order [ |
545
|
|
|
|
|
|
|
# [0] "P248", |
546
|
|
|
|
|
|
|
# [1] "P214", |
547
|
|
|
|
|
|
|
# [2] "P813" |
548
|
|
|
|
|
|
|
# ] |
549
|
|
|
|
|
|
|
# } |
550
|
|
|
|
|
|
|
# ], |
551
|
|
|
|
|
|
|
# type "statement" |
552
|
|
|
|
|
|
|
# } |
553
|
|
|
|
|
|
|
# ], |
554
|
|
|
|
|
|
|
# P31 [ |
555
|
|
|
|
|
|
|
# [0] { |
556
|
|
|
|
|
|
|
# mainsnak { |
557
|
|
|
|
|
|
|
# datatype "wikibase-item", |
558
|
|
|
|
|
|
|
# datavalue { |
559
|
|
|
|
|
|
|
# type "wikibase-entityid", |
560
|
|
|
|
|
|
|
# value { |
561
|
|
|
|
|
|
|
# entity-type "item", |
562
|
|
|
|
|
|
|
# id "Q5", |
563
|
|
|
|
|
|
|
# numeric-id 5 |
564
|
|
|
|
|
|
|
# } |
565
|
|
|
|
|
|
|
# }, |
566
|
|
|
|
|
|
|
# property "P31", |
567
|
|
|
|
|
|
|
# snaktype "value" |
568
|
|
|
|
|
|
|
# }, |
569
|
|
|
|
|
|
|
# qualifiers { |
570
|
|
|
|
|
|
|
# P642 [ |
571
|
|
|
|
|
|
|
# [0] { |
572
|
|
|
|
|
|
|
# datatype "wikibase-item", |
573
|
|
|
|
|
|
|
# datavalue { |
574
|
|
|
|
|
|
|
# type "wikibase-entityid", |
575
|
|
|
|
|
|
|
# value { |
576
|
|
|
|
|
|
|
# entity-type "item", |
577
|
|
|
|
|
|
|
# id "Q474741", |
578
|
|
|
|
|
|
|
# numeric-id 474741 |
579
|
|
|
|
|
|
|
# } |
580
|
|
|
|
|
|
|
# }, |
581
|
|
|
|
|
|
|
# property "P642", |
582
|
|
|
|
|
|
|
# snaktype "value" |
583
|
|
|
|
|
|
|
# } |
584
|
|
|
|
|
|
|
# ] |
585
|
|
|
|
|
|
|
# }, |
586
|
|
|
|
|
|
|
# qualifiers-order [ |
587
|
|
|
|
|
|
|
# [0] "P642" |
588
|
|
|
|
|
|
|
# ], |
589
|
|
|
|
|
|
|
# rank "normal", |
590
|
|
|
|
|
|
|
# references [ |
591
|
|
|
|
|
|
|
# [0] { |
592
|
|
|
|
|
|
|
# snaks { |
593
|
|
|
|
|
|
|
# P214 [ |
594
|
|
|
|
|
|
|
# [0] { |
595
|
|
|
|
|
|
|
# datatype "external-id", |
596
|
|
|
|
|
|
|
# datavalue { |
597
|
|
|
|
|
|
|
# type "string", |
598
|
|
|
|
|
|
|
# value 113230702 |
599
|
|
|
|
|
|
|
# }, |
600
|
|
|
|
|
|
|
# property "P214", |
601
|
|
|
|
|
|
|
# snaktype "value" |
602
|
|
|
|
|
|
|
# } |
603
|
|
|
|
|
|
|
# ], |
604
|
|
|
|
|
|
|
# P248 [ |
605
|
|
|
|
|
|
|
# [0] { |
606
|
|
|
|
|
|
|
# datatype "wikibase-item", |
607
|
|
|
|
|
|
|
# datavalue { |
608
|
|
|
|
|
|
|
# type "wikibase-entityid", |
609
|
|
|
|
|
|
|
# value { |
610
|
|
|
|
|
|
|
# entity-type "item", |
611
|
|
|
|
|
|
|
# id "Q53919", |
612
|
|
|
|
|
|
|
# numeric-id 53919 |
613
|
|
|
|
|
|
|
# } |
614
|
|
|
|
|
|
|
# }, |
615
|
|
|
|
|
|
|
# property "P248", |
616
|
|
|
|
|
|
|
# snaktype "value" |
617
|
|
|
|
|
|
|
# } |
618
|
|
|
|
|
|
|
# ], |
619
|
|
|
|
|
|
|
# P813 [ |
620
|
|
|
|
|
|
|
# [0] { |
621
|
|
|
|
|
|
|
# datatype "time", |
622
|
|
|
|
|
|
|
# datavalue { |
623
|
|
|
|
|
|
|
# type "time", |
624
|
|
|
|
|
|
|
# value { |
625
|
|
|
|
|
|
|
# after 0, |
626
|
|
|
|
|
|
|
# before 0, |
627
|
|
|
|
|
|
|
# calendarmodel "http://test.wikidata.org/entity/Q1985727", |
628
|
|
|
|
|
|
|
# precision 11, |
629
|
|
|
|
|
|
|
# time "+2013-12-07T00:00:00Z", |
630
|
|
|
|
|
|
|
# timezone 0 |
631
|
|
|
|
|
|
|
# } |
632
|
|
|
|
|
|
|
# }, |
633
|
|
|
|
|
|
|
# property "P813", |
634
|
|
|
|
|
|
|
# snaktype "value" |
635
|
|
|
|
|
|
|
# } |
636
|
|
|
|
|
|
|
# ] |
637
|
|
|
|
|
|
|
# }, |
638
|
|
|
|
|
|
|
# snaks-order [ |
639
|
|
|
|
|
|
|
# [0] "P248", |
640
|
|
|
|
|
|
|
# [1] "P214", |
641
|
|
|
|
|
|
|
# [2] "P813" |
642
|
|
|
|
|
|
|
# ] |
643
|
|
|
|
|
|
|
# } |
644
|
|
|
|
|
|
|
# ], |
645
|
|
|
|
|
|
|
# type "statement" |
646
|
|
|
|
|
|
|
# } |
647
|
|
|
|
|
|
|
# ] |
648
|
|
|
|
|
|
|
# }, |
649
|
|
|
|
|
|
|
# title "Q42", |
650
|
|
|
|
|
|
|
# type "item" |
651
|
|
|
|
|
|
|
# } |
652
|
|
|
|
|
|
|
|
653
|
|
|
|
|
|
|
=head1 EXAMPLE2 |
654
|
|
|
|
|
|
|
|
655
|
|
|
|
|
|
|
=for comment filename=struct2obj_item.pl |
656
|
|
|
|
|
|
|
|
657
|
|
|
|
|
|
|
use strict; |
658
|
|
|
|
|
|
|
use warnings; |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
use Data::Printer; |
661
|
|
|
|
|
|
|
use Wikibase::Datatype::Struct::Item qw(struct2obj); |
662
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
# Item structure. |
664
|
|
|
|
|
|
|
my $struct_hr = { |
665
|
|
|
|
|
|
|
'aliases' => { |
666
|
|
|
|
|
|
|
'en' => [{ |
667
|
|
|
|
|
|
|
'language' => 'en', |
668
|
|
|
|
|
|
|
'value' => 'Douglas Noel Adams', |
669
|
|
|
|
|
|
|
}, { |
670
|
|
|
|
|
|
|
'language' => 'en', |
671
|
|
|
|
|
|
|
'value' => 'Douglas Noël Adams', |
672
|
|
|
|
|
|
|
}], |
673
|
|
|
|
|
|
|
'cs' => [{ |
674
|
|
|
|
|
|
|
'language' => 'cs', |
675
|
|
|
|
|
|
|
'value' => 'Douglas Noel Adams', |
676
|
|
|
|
|
|
|
}, { |
677
|
|
|
|
|
|
|
'language' => 'cs', |
678
|
|
|
|
|
|
|
'value' => 'Douglas Noël Adams', |
679
|
|
|
|
|
|
|
}], |
680
|
|
|
|
|
|
|
}, |
681
|
|
|
|
|
|
|
'claims' => { |
682
|
|
|
|
|
|
|
'P394' => [{ |
683
|
|
|
|
|
|
|
'rank' => 'normal', |
684
|
|
|
|
|
|
|
'id' => 'Q42$c763016e-49e0-89b9-f717-2b18af5148f9', |
685
|
|
|
|
|
|
|
'references' => [{ |
686
|
|
|
|
|
|
|
'hash' => 'ed9d0472fca124cea519c0a37eba5f33f10baa22', |
687
|
|
|
|
|
|
|
'snaks' => { |
688
|
|
|
|
|
|
|
'P1943' => [{ |
689
|
|
|
|
|
|
|
'datavalue' => { |
690
|
|
|
|
|
|
|
'type' => 'string', |
691
|
|
|
|
|
|
|
'value' => 'http://wikipedia.org/', |
692
|
|
|
|
|
|
|
}, |
693
|
|
|
|
|
|
|
'datatype' => 'url', |
694
|
|
|
|
|
|
|
'snaktype' => 'value', |
695
|
|
|
|
|
|
|
'hash' => 'b808d4d54bed4daf07d9ac73353c0d1173cfa3c0', |
696
|
|
|
|
|
|
|
'property' => 'P1943', |
697
|
|
|
|
|
|
|
}], |
698
|
|
|
|
|
|
|
}, |
699
|
|
|
|
|
|
|
'snaks-order' => [ |
700
|
|
|
|
|
|
|
'P1943', |
701
|
|
|
|
|
|
|
], |
702
|
|
|
|
|
|
|
}], |
703
|
|
|
|
|
|
|
'type' => 'statement', |
704
|
|
|
|
|
|
|
'mainsnak' => { |
705
|
|
|
|
|
|
|
'datatype' => 'quantity', |
706
|
|
|
|
|
|
|
'datavalue' => { |
707
|
|
|
|
|
|
|
'type' => 'quantity', |
708
|
|
|
|
|
|
|
'value' => { |
709
|
|
|
|
|
|
|
'amount' => '+0.00000000000000000000000000000091093821500', |
710
|
|
|
|
|
|
|
'upperBound' => '+0.00000000000000000000000000000091093821545', |
711
|
|
|
|
|
|
|
'lowerBound' => '+0.00000000000000000000000000000091093821455', |
712
|
|
|
|
|
|
|
'unit' => 'http://test.wikidata.org/entity/Q213', |
713
|
|
|
|
|
|
|
}, |
714
|
|
|
|
|
|
|
}, |
715
|
|
|
|
|
|
|
'snaktype' => 'value', |
716
|
|
|
|
|
|
|
'hash' => 'fac57bc5b94714fb2390cce90f58b6a6cf9b9717', |
717
|
|
|
|
|
|
|
'property' => 'P394', |
718
|
|
|
|
|
|
|
}, |
719
|
|
|
|
|
|
|
}], |
720
|
|
|
|
|
|
|
}, |
721
|
|
|
|
|
|
|
'descriptions' => { |
722
|
|
|
|
|
|
|
'en' => { |
723
|
|
|
|
|
|
|
'language' => 'en', |
724
|
|
|
|
|
|
|
'value' => 'human', |
725
|
|
|
|
|
|
|
}, |
726
|
|
|
|
|
|
|
'cs' => { |
727
|
|
|
|
|
|
|
'language' => 'cs', |
728
|
|
|
|
|
|
|
'value' => 'člověk', |
729
|
|
|
|
|
|
|
}, |
730
|
|
|
|
|
|
|
}, |
731
|
|
|
|
|
|
|
'id' => 'Q42', |
732
|
|
|
|
|
|
|
'labels' => { |
733
|
|
|
|
|
|
|
'en' => { |
734
|
|
|
|
|
|
|
'language' => 'en', |
735
|
|
|
|
|
|
|
'value' => 'Douglas Adams', |
736
|
|
|
|
|
|
|
}, |
737
|
|
|
|
|
|
|
'cs' => { |
738
|
|
|
|
|
|
|
'language' => 'cs', |
739
|
|
|
|
|
|
|
'value' => 'Douglas Adams', |
740
|
|
|
|
|
|
|
}, |
741
|
|
|
|
|
|
|
}, |
742
|
|
|
|
|
|
|
'lastrevid' => 534820, |
743
|
|
|
|
|
|
|
'modified' => '2020-12-02T13:39:18Z', |
744
|
|
|
|
|
|
|
'ns' => 0, |
745
|
|
|
|
|
|
|
'pageid' => '703', |
746
|
|
|
|
|
|
|
'sitelinks' => { |
747
|
|
|
|
|
|
|
'cswiki' => { |
748
|
|
|
|
|
|
|
'title' => 'Douglas Adams', |
749
|
|
|
|
|
|
|
'badges' => [], |
750
|
|
|
|
|
|
|
'site' => 'cswiki', |
751
|
|
|
|
|
|
|
}, |
752
|
|
|
|
|
|
|
}, |
753
|
|
|
|
|
|
|
'type' => 'item', |
754
|
|
|
|
|
|
|
'title' => 'Q42', |
755
|
|
|
|
|
|
|
}; |
756
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
# Get object. |
758
|
|
|
|
|
|
|
my $obj = struct2obj($struct_hr); |
759
|
|
|
|
|
|
|
|
760
|
|
|
|
|
|
|
# Print out. |
761
|
|
|
|
|
|
|
p $obj; |
762
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
# Output: |
764
|
|
|
|
|
|
|
# Wikibase::Datatype::Item { |
765
|
|
|
|
|
|
|
# Parents Mo::Object |
766
|
|
|
|
|
|
|
# public methods (9) : BUILD, can (UNIVERSAL), DOES (UNIVERSAL), err (Error::Pure), check_array_object (Mo::utils), check_number (Mo::utils), check_number_of_items (Mo::utils), isa (UNIVERSAL), VERSION (UNIVERSAL) |
767
|
|
|
|
|
|
|
# private methods (1) : __ANON__ (Mo::build) |
768
|
|
|
|
|
|
|
# internals: { |
769
|
|
|
|
|
|
|
# aliases [ |
770
|
|
|
|
|
|
|
# [0] Wikibase::Datatype::Value::Monolingual, |
771
|
|
|
|
|
|
|
# [1] Wikibase::Datatype::Value::Monolingual, |
772
|
|
|
|
|
|
|
# [2] Wikibase::Datatype::Value::Monolingual, |
773
|
|
|
|
|
|
|
# [3] Wikibase::Datatype::Value::Monolingual |
774
|
|
|
|
|
|
|
# ], |
775
|
|
|
|
|
|
|
# descriptions [ |
776
|
|
|
|
|
|
|
# [0] Wikibase::Datatype::Value::Monolingual, |
777
|
|
|
|
|
|
|
# [1] Wikibase::Datatype::Value::Monolingual |
778
|
|
|
|
|
|
|
# ], |
779
|
|
|
|
|
|
|
# id "Q42", |
780
|
|
|
|
|
|
|
# labels [ |
781
|
|
|
|
|
|
|
# [0] Wikibase::Datatype::Value::Monolingual, |
782
|
|
|
|
|
|
|
# [1] Wikibase::Datatype::Value::Monolingual |
783
|
|
|
|
|
|
|
# ], |
784
|
|
|
|
|
|
|
# lastrevid 534820, |
785
|
|
|
|
|
|
|
# modified "2020-12-02T13:39:18Z", |
786
|
|
|
|
|
|
|
# ns 0, |
787
|
|
|
|
|
|
|
# page_id 703, |
788
|
|
|
|
|
|
|
# sitelinks [ |
789
|
|
|
|
|
|
|
# [0] Wikibase::Datatype::Sitelink |
790
|
|
|
|
|
|
|
# ], |
791
|
|
|
|
|
|
|
# statements [ |
792
|
|
|
|
|
|
|
# [0] Wikibase::Datatype::Statement |
793
|
|
|
|
|
|
|
# ], |
794
|
|
|
|
|
|
|
# title "Q42" |
795
|
|
|
|
|
|
|
# } |
796
|
|
|
|
|
|
|
# } |
797
|
|
|
|
|
|
|
|
798
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
799
|
|
|
|
|
|
|
|
800
|
|
|
|
|
|
|
L<Error::Pure>, |
801
|
|
|
|
|
|
|
L<Exporter>, |
802
|
|
|
|
|
|
|
L<Readonly>, |
803
|
|
|
|
|
|
|
L<Wikibase::Datatype::Reference>, |
804
|
|
|
|
|
|
|
L<Wikibase::Datatype::Struct::Utils>. |
805
|
|
|
|
|
|
|
|
806
|
|
|
|
|
|
|
=head1 SEE ALSO |
807
|
|
|
|
|
|
|
|
808
|
|
|
|
|
|
|
=over |
809
|
|
|
|
|
|
|
|
810
|
|
|
|
|
|
|
=item L<Wikibase::Datatype::Struct> |
811
|
|
|
|
|
|
|
|
812
|
|
|
|
|
|
|
Wikibase structure serialization. |
813
|
|
|
|
|
|
|
|
814
|
|
|
|
|
|
|
=item L<Wikibase::Datatype::Item> |
815
|
|
|
|
|
|
|
|
816
|
|
|
|
|
|
|
Wikibase item datatype. |
817
|
|
|
|
|
|
|
|
818
|
|
|
|
|
|
|
=back |
819
|
|
|
|
|
|
|
|
820
|
|
|
|
|
|
|
=head1 REPOSITORY |
821
|
|
|
|
|
|
|
|
822
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Wikibase-Datatype-Struct> |
823
|
|
|
|
|
|
|
|
824
|
|
|
|
|
|
|
=head1 AUTHOR |
825
|
|
|
|
|
|
|
|
826
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
827
|
|
|
|
|
|
|
|
828
|
|
|
|
|
|
|
L<http://skim.cz> |
829
|
|
|
|
|
|
|
|
830
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
831
|
|
|
|
|
|
|
|
832
|
|
|
|
|
|
|
© 2020-2023 Michal Josef Špaček |
833
|
|
|
|
|
|
|
|
834
|
|
|
|
|
|
|
BSD 2-Clause License |
835
|
|
|
|
|
|
|
|
836
|
|
|
|
|
|
|
=head1 VERSION |
837
|
|
|
|
|
|
|
|
838
|
|
|
|
|
|
|
0.11 |
839
|
|
|
|
|
|
|
|
840
|
|
|
|
|
|
|
=cut |