NAME
Wikibase::Datatype::Form - Wikibase form datatype.
SYNOPSIS
use Wikibase::Datatype::Form;
my $obj = Wikibase::Datatype::Form->new(%params);
my $grammatical_features_ar = $obj->grammatical_features;
my $id = $obj->id;
my $representations_ar = $obj->representations;
my $statements_ar = $obj->statements;
METHODS
new
my $obj = Wikibase::Datatype::Form->new(%params);
Constructor.
Retruns instance of object.
grammatical_features
Grammatical features. Items of array are Q items. Parameter is optional.
id
Identifier of form. Parameter is optional.
representations
Representations. Items of array are Wikibase::Datatype::Value::Monolingual items. Parameter is optional.
statements
Statements. Items of array are Wikibase:Datatype::Statement items. Parameter is optional.
grammatical_features
my $grammatical_features_ar = $obj->grammatical_features;
Get grammatical features.
Returns reference to array of Q items.
id
my $id = $obj->id;
Get form identifier.
Returns string.
representations
my $representations_ar = $obj->representations;
Get representations.
Returns reference to array with Wikibase::Datatype::Value::Monolingual items.
statements
my $statements_ar = $obj->statements;
Get statements.
Returns reference to array of Wikibase::Datatype::Statemnet items.
ERRORS
new():
From Mo::utils::check_array_object():
Grammatical feature isn't 'Wikibase::Datatype::Value::Item' object.
Parameter 'grammatical_features' must be a array.
Parameter 'representations' must be a array.
Parameter 'statements' must be a array.
Representation isn't 'Wikibase::Datatype::Value::Monolingual' object.
Statement isn't 'Wikibase::Datatype::Statement' object.
EXAMPLE
use strict;
use warnings;
use Wikibase::Datatype::Form;
use Wikibase::Datatype::Snak;
use Wikibase::Datatype::Statement;
use Wikibase::Datatype::Value::Item;
use Wikibase::Datatype::Value::Monolingual;
# Object.
my $obj = Wikibase::Datatype::Form->new(
'grammatical_features' => [
Wikibase::Datatype::Value::Item->new(
'value' => 'Q123',
),
Wikibase::Datatype::Value::Item->new(
'value' => 'Q321',
),
],
'id' => 'identifier',
'representations' => [
Wikibase::Datatype::Value::Monolingual->new(
'language' => 'cs',
'value' => 'Text',
),
Wikibase::Datatype::Value::Monolingual->new(
'language' => 'en',
'value' => 'Text',
),
],
'statements' => [
Wikibase::Datatype::Statement->new(
'snak' => Wikibase::Datatype::Snak->new(
'datatype' => 'wikibase-item',
'datavalue' => Wikibase::Datatype::Value::Item->new(
'value' => 'Q1',
),
'property' => 'P1',
),
),
],
);
# Get id.
my $id = $obj->id;
# Get counts.
my $gr_count = @{$obj->grammatical_features};
my $re_count = @{$obj->representations};
my $st_count = @{$obj->statements};
# Print out.
print "Id: $id\n";
print "Number of grammatical features: $gr_count\n";
print "Number of representations: $re_count\n";
print "Number of statements: $st_count\n";
# Output:
# Id: identifier
# Number of grammatical features: 2
# Number of representations: 2
# Number of statements: 1
DEPENDENCIES
SEE ALSO
- Wikibase::Datatype
-
Wikibase datatypes.
REPOSITORY
https://github.com/michal-josef-spacek/Wikibase-Datatype
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© Michal Josef Špaček 2020
BSD 2-Clause License
VERSION
0.01