line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wikibase::Datatype::Sense; |
2
|
|
|
|
|
|
|
|
3
|
25
|
|
|
25
|
|
565796
|
use strict; |
|
25
|
|
|
|
|
110
|
|
|
25
|
|
|
|
|
685
|
|
4
|
25
|
|
|
25
|
|
139
|
use warnings; |
|
25
|
|
|
|
|
53
|
|
|
25
|
|
|
|
|
712
|
|
5
|
|
|
|
|
|
|
|
6
|
25
|
|
|
25
|
|
3510
|
use Mo qw(build default is); |
|
25
|
|
|
|
|
4073
|
|
|
25
|
|
|
|
|
143
|
|
7
|
25
|
|
|
25
|
|
27786
|
use Mo::utils qw(check_array_object check_number_of_items); |
|
25
|
|
|
|
|
96409
|
|
|
25
|
|
|
|
|
3177
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 0.29; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has glosses => ( |
12
|
|
|
|
|
|
|
default => [], |
13
|
|
|
|
|
|
|
is => 'ro', |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has id => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has statements => ( |
21
|
|
|
|
|
|
|
default => [], |
22
|
|
|
|
|
|
|
is => 'ro', |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub BUILD { |
26
|
27
|
|
|
27
|
0
|
10171
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Check glosses. |
29
|
27
|
|
|
|
|
178
|
check_array_object($self, 'glosses', 'Wikibase::Datatype::Value::Monolingual', |
30
|
|
|
|
|
|
|
'Glosse'); |
31
|
25
|
|
|
|
|
656
|
check_number_of_items($self, 'glosses', 'language', 'Glosse', 'language'); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Check statements. |
34
|
24
|
|
|
|
|
1191
|
check_array_object($self, 'statements', 'Wikibase::Datatype::Statement', |
35
|
|
|
|
|
|
|
'Statement'); |
36
|
|
|
|
|
|
|
|
37
|
22
|
|
|
|
|
477
|
return; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=pod |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=encoding utf8 |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NAME |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Wikibase::Datatype::Sense - Wikibase sense datatype. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 SYNOPSIS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
use Wikibase::Datatype::Sense; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::Sense->new(%params); |
57
|
|
|
|
|
|
|
my $glosses_ar = $obj->glosses; |
58
|
|
|
|
|
|
|
my $id = $obj->id; |
59
|
|
|
|
|
|
|
my $statements_ar = $obj->statements; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 DESCRIPTION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
This datatype is snak class for representing relation between property and value. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 METHODS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 C<new> |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::Snak->new(%params); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Constructor. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Retruns instance of object. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=over 8 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item * C<glosses> |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Item glosses. One per language. |
80
|
|
|
|
|
|
|
Reference to array with Wikibase::Datatype::Value::Monolingual instances. |
81
|
|
|
|
|
|
|
Parameter is optional. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item * C<id> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Id. |
86
|
|
|
|
|
|
|
Parameter is optional. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * C<statements> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Item statements. |
91
|
|
|
|
|
|
|
Reference to array with Wikibase::Datatype::Statement instances. |
92
|
|
|
|
|
|
|
Parameter is optional. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=back |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 C<glosses> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
my $glosses_ar = $obj->glosses; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Get glosses. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Returns reference to array with Wikibase::Datatype::Value::Monolingual instances. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 C<id> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my $id = $obj->id; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Get id. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Returns string. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 C<statements> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
my $statements_ar = $obj->statements; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Get statements. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Returns reference to array with Wikibase::Datatype::Statement instances. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 ERRORS |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
new(): |
123
|
|
|
|
|
|
|
From Mo::utils::check_array_object(): |
124
|
|
|
|
|
|
|
Glosse isn't 'Wikibase::Datatype::Value::Monolingual' object. |
125
|
|
|
|
|
|
|
Parameter 'glosses' must be a array. |
126
|
|
|
|
|
|
|
Parameter 'statements' must be a array. |
127
|
|
|
|
|
|
|
Statement isn't 'Wikibase::Datatype::Statement' object. |
128
|
|
|
|
|
|
|
From Mo::utils::check_number_of_items(): |
129
|
|
|
|
|
|
|
Glosse for language '%s' has multiple values. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 EXAMPLE |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=for comment filename=create_and_print_sense.pl |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
use strict; |
136
|
|
|
|
|
|
|
use warnings; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
use Unicode::UTF8 qw(decode_utf8); |
139
|
|
|
|
|
|
|
use Wikibase::Datatype::Sense; |
140
|
|
|
|
|
|
|
use Wikibase::Datatype::Snak; |
141
|
|
|
|
|
|
|
use Wikibase::Datatype::Statement; |
142
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::Item; |
143
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::Monolingual; |
144
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::String; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# One sense for Czech noun 'pes'. |
147
|
|
|
|
|
|
|
# https://www.wikidata.org/wiki/Lexeme:L469 |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
# Statements. |
150
|
|
|
|
|
|
|
my $statement_item = Wikibase::Datatype::Statement->new( |
151
|
|
|
|
|
|
|
# item for this sense (P5137) dog (Q144) |
152
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
153
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
154
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
155
|
|
|
|
|
|
|
'value' => 'Q144', |
156
|
|
|
|
|
|
|
), |
157
|
|
|
|
|
|
|
'property' => 'P5137', |
158
|
|
|
|
|
|
|
), |
159
|
|
|
|
|
|
|
); |
160
|
|
|
|
|
|
|
my $statement_image = Wikibase::Datatype::Statement->new( |
161
|
|
|
|
|
|
|
# image (P5137) 'Canadian Inuit Dog.jpg' |
162
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
163
|
|
|
|
|
|
|
'datatype' => 'commonsMedia', |
164
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::String->new( |
165
|
|
|
|
|
|
|
'value' => 'Canadian Inuit Dog.jpg', |
166
|
|
|
|
|
|
|
), |
167
|
|
|
|
|
|
|
'property' => 'P18', |
168
|
|
|
|
|
|
|
), |
169
|
|
|
|
|
|
|
); |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
# Object. |
172
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::Sense->new( |
173
|
|
|
|
|
|
|
'glosses' => [ |
174
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
175
|
|
|
|
|
|
|
'language' => 'en', |
176
|
|
|
|
|
|
|
'value' => 'domesticated mammal related to the wolf', |
177
|
|
|
|
|
|
|
), |
178
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
179
|
|
|
|
|
|
|
'language' => 'cs', |
180
|
|
|
|
|
|
|
'value' => decode_utf8('psovitá šelma chovaná jako domácí zvíře'), |
181
|
|
|
|
|
|
|
), |
182
|
|
|
|
|
|
|
], |
183
|
|
|
|
|
|
|
'id' => 'ID', |
184
|
|
|
|
|
|
|
'statements' => [ |
185
|
|
|
|
|
|
|
$statement_item, |
186
|
|
|
|
|
|
|
$statement_image, |
187
|
|
|
|
|
|
|
], |
188
|
|
|
|
|
|
|
); |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# Get id. |
191
|
|
|
|
|
|
|
my $id = $obj->id; |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
# Get glosses. |
194
|
|
|
|
|
|
|
my @glosses = map { $_->value.' ('.$_->language.')' } @{$obj->glosses}; |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
# Get statements. |
197
|
|
|
|
|
|
|
my $statements_count = @{$obj->statements}; |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
# Print out. |
200
|
|
|
|
|
|
|
print "Id: $id\n"; |
201
|
|
|
|
|
|
|
print "Glosses:\n"; |
202
|
|
|
|
|
|
|
map { print "\t$_\n"; } @glosses; |
203
|
|
|
|
|
|
|
print "Number of statements: $statements_count\n"; |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
# Output: |
206
|
|
|
|
|
|
|
# Id: ID |
207
|
|
|
|
|
|
|
# Glosses: |
208
|
|
|
|
|
|
|
# domesticated mammal related to the wolf (en) |
209
|
|
|
|
|
|
|
# psovitá šelma chovaná jako domácí zvíře (cs) |
210
|
|
|
|
|
|
|
# Number of statements: 2 |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
L<Mo>, |
215
|
|
|
|
|
|
|
L<Mo::utils>. |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head1 SEE ALSO |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=over |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=item L<Wikibase::Datatype> |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Wikibase datatypes. |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=back |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 REPOSITORY |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Wikibase-Datatype> |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head1 AUTHOR |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
L<http://skim.cz> |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
© 2020-2023 Michal Josef Špaček |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
BSD 2-Clause License |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head1 VERSION |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
0.29 |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=cut |