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