line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wikibase::Datatype::Property; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
1588089
|
use strict; |
|
17
|
|
|
|
|
191
|
|
|
17
|
|
|
|
|
489
|
|
4
|
17
|
|
|
17
|
|
128
|
use warnings; |
|
17
|
|
|
|
|
32
|
|
|
17
|
|
|
|
|
477
|
|
5
|
|
|
|
|
|
|
|
6
|
17
|
|
|
17
|
|
7707
|
use Error::Pure qw(err); |
|
17
|
|
|
|
|
187725
|
|
|
17
|
|
|
|
|
331
|
|
7
|
17
|
|
|
17
|
|
1035
|
use List::Util qw(none); |
|
17
|
|
|
|
|
39
|
|
|
17
|
|
|
|
|
1139
|
|
8
|
17
|
|
|
17
|
|
8259
|
use Mo qw(build default is); |
|
17
|
|
|
|
|
9192
|
|
|
17
|
|
|
|
|
116
|
|
9
|
17
|
|
|
17
|
|
46686
|
use Mo::utils qw(check_array_object check_number check_number_of_items check_required); |
|
17
|
|
|
|
|
24530
|
|
|
17
|
|
|
|
|
352
|
|
10
|
17
|
|
|
17
|
|
1608
|
use Readonly; |
|
17
|
|
|
|
|
35
|
|
|
17
|
|
|
|
|
7075
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Pairs data type and datatype. |
13
|
|
|
|
|
|
|
Readonly::Hash our %DATA_TYPES => ( |
14
|
|
|
|
|
|
|
'commonsMedia' => 'Wikibase::Datatype::Value::String', |
15
|
|
|
|
|
|
|
'external-id' => 'Wikibase::Datatype::Value::String', |
16
|
|
|
|
|
|
|
'geo-shape' => 'Wikibase::Datatype::Value::String', |
17
|
|
|
|
|
|
|
'globe-coordinate' => 'Wikibase::Datatype::Value::Globecoordinate', |
18
|
|
|
|
|
|
|
'math' => 'Wikibase::Datatype::Value::String', |
19
|
|
|
|
|
|
|
'monolingualtext' => 'Wikibase::Datatype::Value::Monolingual', |
20
|
|
|
|
|
|
|
'musical-notation' => 'Wikibase::Datatype::Value::String', |
21
|
|
|
|
|
|
|
'quantity' => 'Wikibase::Datatype::Value::Quantity', |
22
|
|
|
|
|
|
|
'string' => 'Wikibase::Datatype::Value::String', |
23
|
|
|
|
|
|
|
'tabular-data' => 'Wikibase::Datatype::Value::String', |
24
|
|
|
|
|
|
|
'time' => 'Wikibase::Datatype::Value::Time', |
25
|
|
|
|
|
|
|
'url' => 'Wikibase::Datatype::Value::String', |
26
|
|
|
|
|
|
|
'wikibase-item' => 'Wikibase::Datatype::Value::Item', |
27
|
|
|
|
|
|
|
'wikibase-property' => 'Wikibase::Datatype::Value::Property', |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $VERSION = 0.30; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has aliases => ( |
33
|
|
|
|
|
|
|
default => [], |
34
|
|
|
|
|
|
|
is => 'ro', |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has datatype => ( |
38
|
|
|
|
|
|
|
is => 'ro', |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has descriptions => ( |
42
|
|
|
|
|
|
|
default => [], |
43
|
|
|
|
|
|
|
is => 'ro', |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
has id => ( |
47
|
|
|
|
|
|
|
is => 'ro', |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
has labels => ( |
51
|
|
|
|
|
|
|
default => [], |
52
|
|
|
|
|
|
|
is => 'ro', |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
has lastrevid => ( |
56
|
|
|
|
|
|
|
is => 'ro', |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
has modified => ( |
60
|
|
|
|
|
|
|
is => 'ro', |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
has ns => ( |
64
|
|
|
|
|
|
|
default => 120, |
65
|
|
|
|
|
|
|
is => 'ro', |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
has page_id => ( |
69
|
|
|
|
|
|
|
is => 'ro', |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
has statements => ( |
73
|
|
|
|
|
|
|
default => [], |
74
|
|
|
|
|
|
|
is => 'ro', |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
has title => ( |
78
|
|
|
|
|
|
|
is => 'ro', |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub BUILD { |
82
|
26
|
|
|
26
|
0
|
13006
|
my $self = shift; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Check aliases. |
85
|
26
|
|
|
|
|
129
|
check_array_object($self, 'aliases', 'Wikibase::Datatype::Value::Monolingual', |
86
|
|
|
|
|
|
|
'Alias'); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# Check data type. |
89
|
25
|
|
|
|
|
690
|
check_required($self, 'datatype'); |
90
|
24
|
100
|
|
222
|
|
333
|
if (none { $self->{'datatype'} eq $_ } keys %DATA_TYPES) { |
|
222
|
|
|
|
|
1682
|
|
91
|
1
|
|
|
|
|
10
|
err "Parameter 'datatype' = '$self->{'datatype'}' isn't supported."; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# Check descriptions. |
95
|
23
|
|
|
|
|
191
|
check_array_object($self, 'descriptions', 'Wikibase::Datatype::Value::Monolingual', |
96
|
|
|
|
|
|
|
'Description'); |
97
|
22
|
|
|
|
|
367
|
check_number_of_items($self, 'descriptions', 'language', 'Description', 'language'); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# Check labels. |
100
|
21
|
|
|
|
|
697
|
check_array_object($self, 'labels', 'Wikibase::Datatype::Value::Monolingual', |
101
|
|
|
|
|
|
|
'Label'); |
102
|
20
|
|
|
|
|
303
|
check_number_of_items($self, 'labels', 'language', 'Label', 'language'); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# Check page id. |
105
|
19
|
|
|
|
|
483
|
check_number($self, 'page_id'); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# Check statements. |
108
|
18
|
|
|
|
|
294
|
check_array_object($self, 'statements', 'Wikibase::Datatype::Statement', |
109
|
|
|
|
|
|
|
'Statement'); |
110
|
|
|
|
|
|
|
|
111
|
17
|
|
|
|
|
212
|
return; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
__END__ |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=pod |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=encoding utf8 |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 NAME |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Wikibase::Datatype::Property - Wikibase property datatype. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 SYNOPSIS |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
use Wikibase::Datatype::Property; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::Property->new(%params); |
131
|
|
|
|
|
|
|
my $aliases_ar = $obj->aliases; |
132
|
|
|
|
|
|
|
my $datatype = $obj->datatype; |
133
|
|
|
|
|
|
|
my $descriptions_ar = $obj->descriptions; |
134
|
|
|
|
|
|
|
my $id = $obj->id; |
135
|
|
|
|
|
|
|
my $labels_ar = $obj->labels; |
136
|
|
|
|
|
|
|
my $lastrevid = $obj->lastrevid; |
137
|
|
|
|
|
|
|
my $modified = $obj->modified; |
138
|
|
|
|
|
|
|
my $ns = $obj->ns; |
139
|
|
|
|
|
|
|
my $page_id = $obj->page_id; |
140
|
|
|
|
|
|
|
my $statements_ar = $obj->statements; |
141
|
|
|
|
|
|
|
my $title = $obj->title; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 DESCRIPTION |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This datatype is property class for representing property. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 METHODS |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 C<new> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::Property->new(%params); |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Constructor. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Returns instance of object. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=over 8 |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item * C<aliases> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Item aliases. Multiple per language. |
162
|
|
|
|
|
|
|
Reference to array with Wikibase::Datatype::Value::Monolingual instances. |
163
|
|
|
|
|
|
|
Parameter is optional. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item * C<datatype> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Type of data. |
168
|
|
|
|
|
|
|
Parameter is required. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Possible datatypes are (datavalue instance in parenthesis): |
171
|
|
|
|
|
|
|
- commonsMedia (Wikibase::Datatype::Value::String) |
172
|
|
|
|
|
|
|
- external-id (Wikibase::Datatype::Value::String) |
173
|
|
|
|
|
|
|
- geo-shape (Wikibase::Datatype::Value::String) |
174
|
|
|
|
|
|
|
- globe-coordinate (Wikibase::Datatype::Value::Globecoordinate) |
175
|
|
|
|
|
|
|
- math (Wikibase::Datatype::Value::String) |
176
|
|
|
|
|
|
|
- monolingualtext (Wikibase::Datatype::Value::Monolingual) |
177
|
|
|
|
|
|
|
- musical-notation (Wikibase::Datatype::Value::String) |
178
|
|
|
|
|
|
|
- quantity (Wikibase::Datatype::Value::Quantity) |
179
|
|
|
|
|
|
|
- string (Wikibase::Datatype::Value::String) |
180
|
|
|
|
|
|
|
- tabular-data (Wikibase::Datatype::Value::String) |
181
|
|
|
|
|
|
|
- time (Wikibase::Datatype::Value::Time) |
182
|
|
|
|
|
|
|
- url (Wikibase::Datatype::Value::String) |
183
|
|
|
|
|
|
|
- wikibase-item (Wikibase::Datatype::Value::Item) |
184
|
|
|
|
|
|
|
- wikibase-property (Wikibase::Datatype::Value::Property) |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item * C<descriptions> |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Item descriptions. One per language. |
189
|
|
|
|
|
|
|
Reference to array with Wikibase::Datatype::Value::Monolingual instances. |
190
|
|
|
|
|
|
|
Parameter is optional. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=item * C<id> |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Id. |
195
|
|
|
|
|
|
|
Parameter is optional. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=item * C<labels> |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Item descriptions. One per language. |
200
|
|
|
|
|
|
|
Reference to array with Wikibase::Datatype::Value::Monolingual instances. |
201
|
|
|
|
|
|
|
Parameter is optional. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=item * C<lastrevid> |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Last revision ID. |
206
|
|
|
|
|
|
|
Parameter is optional. |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=item * C<modified> |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Date of modification. |
211
|
|
|
|
|
|
|
Parameter is optional. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=item * C<ns> |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Namespace. |
216
|
|
|
|
|
|
|
Default value is 120. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=item * C<page_id> |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
Page id. Numeric value. |
221
|
|
|
|
|
|
|
Parameter is optional. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=item * C<statements> |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Item statements. |
226
|
|
|
|
|
|
|
Reference to array with Wikibase::Datatype::Statement instances. |
227
|
|
|
|
|
|
|
Parameter is optional. |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=item * C<title> |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
Item title. |
232
|
|
|
|
|
|
|
Parameter is optional. |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=back |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head2 C<aliases> |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
my $aliases_ar = $obj->aliases; |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Get aliases. |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
Returns reference to array with Wikibase::Datatype::Value::Monolingual instances. |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head2 C<datatype> |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
my $datatype = $obj->datatype; |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
Get data type. |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
Returns string. |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head2 C<descriptions> |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
my $descriptions_ar = $obj->descriptions; |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
Get descriptions. |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
Returns reference to array with Wikibase::Datatype::Value::Monolingual instances. |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=head2 C<id> |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
my $id = $obj->id; |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
Get id. |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
Returns string. |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head2 C<labels> |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
my $labels_ar = $obj->labels; |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
Get labels. |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
Returns reference to array with Wikibase::Datatype::Value::Monolingual instances. |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=head2 C<lastrevid> |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
my $lastrevid = $obj->lastrevid; |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
Get last revision ID. |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
Returns string. |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=head2 C<modified> |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
my $modified = $obj->modified; |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
Get date of modification. |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
Returns string. |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
=head2 C<ns> |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
my $ns = $obj->ns; |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
Get namespace. |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
Returns number. |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=head2 C<page_id> |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
my $page_id = $obj->page_id; |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
Get page id. |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
Returns number. |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
=head2 C<statements> |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
my $statements_ar = $obj->statements; |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
Get statements. |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
Returns reference to array with Wikibase::Datatype::Statement instances. |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
=head2 C<title> |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
my $title = $obj->title; |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
Get title. |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
Returns string. |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
=head1 ERRORS |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
new(): |
327
|
|
|
|
|
|
|
From Mo::utils::check_array_object(): |
328
|
|
|
|
|
|
|
Alias isn't 'Wikibase::Datatype::Value::Monolingual' object. |
329
|
|
|
|
|
|
|
Description isn't 'Wikibase::Datatype::Value::Monolingual' object. |
330
|
|
|
|
|
|
|
Label isn't 'Wikibase::Datatype::Value::Monolingual' object. |
331
|
|
|
|
|
|
|
Parameter 'aliases' must be a array. |
332
|
|
|
|
|
|
|
Parameter 'descriptions' must be a array. |
333
|
|
|
|
|
|
|
Parameter 'labels' must be a array. |
334
|
|
|
|
|
|
|
Parameter 'statements' must be a array. |
335
|
|
|
|
|
|
|
Statement isn't 'Wikibase::Datatype::Statement' object. |
336
|
|
|
|
|
|
|
From Mo::utils::check_page_id(): |
337
|
|
|
|
|
|
|
Parameter 'page_id' must a number. |
338
|
|
|
|
|
|
|
From Mo::utils::check_number_of_items(): |
339
|
|
|
|
|
|
|
Description for language '%s' has multiple values. |
340
|
|
|
|
|
|
|
Label for language '%s' has multiple values. |
341
|
|
|
|
|
|
|
From Mo::utils::check_required(): |
342
|
|
|
|
|
|
|
Parameter 'datatype' is required. |
343
|
|
|
|
|
|
|
Parameter 'datatype' = '%s' isn't supported. |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
=head1 EXAMPLE |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
=for comment filename=create_and_print_property.pl |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
use strict; |
350
|
|
|
|
|
|
|
use warnings; |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
use Unicode::UTF8 qw(decode_utf8 encode_utf8); |
353
|
|
|
|
|
|
|
use Wikibase::Datatype::Property; |
354
|
|
|
|
|
|
|
use Wikibase::Datatype::Reference; |
355
|
|
|
|
|
|
|
use Wikibase::Datatype::Sitelink; |
356
|
|
|
|
|
|
|
use Wikibase::Datatype::Snak; |
357
|
|
|
|
|
|
|
use Wikibase::Datatype::Statement; |
358
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::Item; |
359
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::Monolingual; |
360
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::String; |
361
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::Time; |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
# Object. |
364
|
|
|
|
|
|
|
my $statement1 = Wikibase::Datatype::Statement->new( |
365
|
|
|
|
|
|
|
# instance of (P31) Wikidata property (Q18616576) |
366
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
367
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
368
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
369
|
|
|
|
|
|
|
'value' => 'Q18616576', |
370
|
|
|
|
|
|
|
), |
371
|
|
|
|
|
|
|
'property' => 'P31', |
372
|
|
|
|
|
|
|
), |
373
|
|
|
|
|
|
|
); |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
# Main item. |
376
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::Property->new( |
377
|
|
|
|
|
|
|
'aliases' => [ |
378
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
379
|
|
|
|
|
|
|
'language' => 'cs', |
380
|
|
|
|
|
|
|
'value' => 'je', |
381
|
|
|
|
|
|
|
), |
382
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
383
|
|
|
|
|
|
|
'language' => 'en', |
384
|
|
|
|
|
|
|
'value' => 'is a', |
385
|
|
|
|
|
|
|
), |
386
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
387
|
|
|
|
|
|
|
'language' => 'en', |
388
|
|
|
|
|
|
|
'value' => 'is an', |
389
|
|
|
|
|
|
|
), |
390
|
|
|
|
|
|
|
], |
391
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
392
|
|
|
|
|
|
|
'descriptions' => [ |
393
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
394
|
|
|
|
|
|
|
'language' => 'cs', |
395
|
|
|
|
|
|
|
'value' => decode_utf8('tato položka je jedna konkrétní věc (exemplář, '. |
396
|
|
|
|
|
|
|
'příklad) patřící do této třídy, kategorie nebo skupiny předmětů'), |
397
|
|
|
|
|
|
|
), |
398
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
399
|
|
|
|
|
|
|
'language' => 'en', |
400
|
|
|
|
|
|
|
'value' => 'that class of which this subject is a particular example and member', |
401
|
|
|
|
|
|
|
), |
402
|
|
|
|
|
|
|
], |
403
|
|
|
|
|
|
|
'id' => 'P31', |
404
|
|
|
|
|
|
|
'labels' => [ |
405
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
406
|
|
|
|
|
|
|
'language' => 'cs', |
407
|
|
|
|
|
|
|
'value' => decode_utf8('instance (čeho)'), |
408
|
|
|
|
|
|
|
), |
409
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
410
|
|
|
|
|
|
|
'language' => 'en', |
411
|
|
|
|
|
|
|
'value' => 'instance of', |
412
|
|
|
|
|
|
|
), |
413
|
|
|
|
|
|
|
], |
414
|
|
|
|
|
|
|
'page_id' => 3918489, |
415
|
|
|
|
|
|
|
'statements' => [ |
416
|
|
|
|
|
|
|
$statement1, |
417
|
|
|
|
|
|
|
], |
418
|
|
|
|
|
|
|
'title' => 'Property:P31', |
419
|
|
|
|
|
|
|
); |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
# Print out. |
422
|
|
|
|
|
|
|
print "Title: ".$obj->title."\n"; |
423
|
|
|
|
|
|
|
print 'Id: '.$obj->id."\n"; |
424
|
|
|
|
|
|
|
print 'Data type: '.$obj->datatype."\n"; |
425
|
|
|
|
|
|
|
print 'Page id: '.$obj->page_id."\n"; |
426
|
|
|
|
|
|
|
print "Labels:\n"; |
427
|
|
|
|
|
|
|
foreach my $label (sort { $a->language cmp $b->language } @{$obj->labels}) { |
428
|
|
|
|
|
|
|
print "\t".encode_utf8($label->value).' ('.$label->language.")\n"; |
429
|
|
|
|
|
|
|
} |
430
|
|
|
|
|
|
|
print "Descriptions:\n"; |
431
|
|
|
|
|
|
|
foreach my $desc (sort { $a->language cmp $b->language } @{$obj->descriptions}) { |
432
|
|
|
|
|
|
|
print "\t".encode_utf8($desc->value).' ('.$desc->language.")\n"; |
433
|
|
|
|
|
|
|
} |
434
|
|
|
|
|
|
|
print "Aliases:\n"; |
435
|
|
|
|
|
|
|
foreach my $alias (sort { $a->language cmp $b->language } @{$obj->aliases}) { |
436
|
|
|
|
|
|
|
print "\t".encode_utf8($alias->value).' ('.$alias->language.")\n"; |
437
|
|
|
|
|
|
|
} |
438
|
|
|
|
|
|
|
print "Statements:\n"; |
439
|
|
|
|
|
|
|
foreach my $statement (@{$obj->statements}) { |
440
|
|
|
|
|
|
|
print "\tStatement:\n"; |
441
|
|
|
|
|
|
|
print "\t\t".$statement->snak->property.' -> '.$statement->snak->datavalue->value."\n"; |
442
|
|
|
|
|
|
|
} |
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
# Output: |
445
|
|
|
|
|
|
|
# Title: Property:P31 |
446
|
|
|
|
|
|
|
# Id: P31 |
447
|
|
|
|
|
|
|
# Data type: wikibase-item |
448
|
|
|
|
|
|
|
# Page id: 3918489 |
449
|
|
|
|
|
|
|
# Labels: |
450
|
|
|
|
|
|
|
# instance (čeho) (cs) |
451
|
|
|
|
|
|
|
# instance of (en) |
452
|
|
|
|
|
|
|
# Descriptions: |
453
|
|
|
|
|
|
|
# tato položka je jedna konkrétní věc (exemplář, příklad) patřící do této třídy, kategorie nebo skupiny předmětů (cs) |
454
|
|
|
|
|
|
|
# that class of which this subject is a particular example and member (en) |
455
|
|
|
|
|
|
|
# Aliases: |
456
|
|
|
|
|
|
|
# je (cs) |
457
|
|
|
|
|
|
|
# is a (en) |
458
|
|
|
|
|
|
|
# is an (en) |
459
|
|
|
|
|
|
|
# Statements: |
460
|
|
|
|
|
|
|
# Statement: |
461
|
|
|
|
|
|
|
# P31 -> Q18616576 |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
L<Error::Pure>, |
466
|
|
|
|
|
|
|
L<List::Util>, |
467
|
|
|
|
|
|
|
L<Mo>, |
468
|
|
|
|
|
|
|
L<Mo:utils>, |
469
|
|
|
|
|
|
|
L<Readonly>. |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
=head1 SEE ALSO |
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
=over |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
=item L<Wikibase::Datatype> |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
Wikibase datatypes. |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
=back |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
=head1 REPOSITORY |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Wikibase-Datatype> |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
=head1 AUTHOR |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
L<http://skim.cz> |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
© 2020-2023 Michal Josef Špaček |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
BSD 2-Clause License |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
=head1 VERSION |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
0.30 |
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
=cut |