sub
new {
my
$class
=
shift
;
my
%args
=
@_
;
my
$self
=
bless
Wiktionary::Parser::Section->new(
%args
),
$class
;
$self
->set_part_of_speech(
$self
->get_header());
$self
->set_language_code(
$self
->get_language());
return
$self
;
}
sub
add_content {
my
$self
=
shift
;
my
$line
=
shift
;
if
(
$line
=~ m/^\{\{([^\}]+)\}\}/) {
my
$header_meta
= $1;
my
@meta_parts
=
split
(/\|/,
$header_meta
);
if
(
$meta_parts
[0] eq
'head'
) {
$self
->set_language_code(
$meta_parts
[1]);
$self
->set_part_of_speech(
$meta_parts
[2])
}
elsif
(
$meta_parts
[0] =~ m/^(\w+)\-(\w+)-(\w+)\|?/) {
$self
->set_language_code($1);
$self
->set_part_of_speech($3);
$self
->set_inflection([
@meta_parts
[1..-1]]);
}
elsif
(
$meta_parts
[0] =~ m/^(\w+)\-(\w+)/) {
$self
->set_language_code($1);
$self
->set_part_of_speech($2);
$self
->set_inflection([
@meta_parts
[1..-1]]);
}
}
push
@{
$self
->{content}},
$line
;
}
sub
set_part_of_speech {
my
$self
=
shift
;
$self
->{part_of_speech} =
shift
;
}
sub
get_part_of_speech {
my
$self
=
shift
;
return
$self
->{part_of_speech};
}
sub
set_language_code {
my
$self
=
shift
;
$self
->{language_code} =
shift
;
}
sub
get_language_code {
my
$self
=
shift
;
return
$self
->{language_code};
}
sub
set_inflection {
my
$self
=
shift
;
$self
->{inflection} =
shift
;
}
sub
get_inflection {
my
$self
=
shift
;
return
$self
->{inflection};
}
1;