Fix for Schreibgebrauch VC support
Change-Id: Ief7dd69a78e112e67d0daace8edd185a1b477766
diff --git a/lib/KorAP/XML/Krill.pm b/lib/KorAP/XML/Krill.pm
index 8c546d0..4453274 100644
--- a/lib/KorAP/XML/Krill.pm
+++ b/lib/KorAP/XML/Krill.pm
@@ -255,7 +255,7 @@
if ($_[0]) {
return $self->{topics} = [ @_ ];
};
- return ($self->{topics} // []);
+ return ($self->{topics} //= []);
};
sub text_class_string {
@@ -267,7 +267,7 @@
if ($_[0]) {
return $self->{keywords} = [ @_ ];
};
- return ($self->{keywords} // []);
+ return ($self->{keywords} //= []);
};
sub keywords_string {
@@ -312,17 +312,32 @@
# Author
try {
my $author = $stmt->at('author')->attr('ref');
+
$author = $self->{ref_author}->{$author};
+
if ($author) {
+
+ my $array = $self->keywords;
$self->author($author->{id});
- $self->store('sgbrAuthorAgeClass' => $author->{age}) if $author->{age};
- $self->store('sgbrAuthorSex' => $author->{sex}) if $author->{sex};
+
+ if ($author->{age}) {
+ $self->store('sgbrAuthorAgeClass' => $author->{age});
+ push @$array, 'sgbrAuthorAgeClass:' . $author->{age};
+ };
+ if ($author->{sex}) {
+ $self->store('sgbrAuthorSex' => $author->{sex});
+ push @$array, 'sgbrAuthorSex:' . $author->{sex};
+ };
};
};
try {
my $kodex = $dom->at('item[rend]')->attr('rend');
- $self->store('sgbrKodex' => $kodex);
+ if ($kodex) {
+ my $array = $self->keywords;
+ $self->store('sgbrKodex' => $kodex);
+ push @$array, 'sgbrKodex:' . $kodex;
+ };
};
}
@@ -330,6 +345,7 @@
try {
$dom->find('particDesc person')->each(
sub {
+
$self->{ref_author}->{'#' . $_->attr('xml:id')} = {
age => $_->attr('age'),
sex => $_->attr('sex'),
@@ -559,8 +575,9 @@
);
$self->text_class(@topic) if @topic > 0;
+ my $kws = $self->keywords;
my @keywords = $text_class->find("h\.keywords > keyTerm")->each;
- $self->keywords(@keywords) if @keywords > 0;
+ push(@$kws, @keywords) if @keywords > 0;
};
if (my $edition_statement = $dom->at('biblFull editionStmt')) {
diff --git a/t/sgbr/sgbr_meta.t b/t/sgbr/sgbr_meta.t
index ed64fa2..a1e2b8e 100644
--- a/t/sgbr/sgbr_meta.t
+++ b/t/sgbr/sgbr_meta.t
@@ -27,8 +27,11 @@
#is($doc->sub_title, 'Beispiel Text Untertitel', 'title');
#is($doc->pub_date, '20010402', 'Publication date');
#is($doc->pub_place, 'Mannheim', 'Publication place');
+
is($doc->author, 'TEST.BSP.Autoren.1', 'Author');
+
is($doc->store('sgbrAuthorAgeClass'), 'X', 'AgeClass');
+
is($doc->store('sgbrAuthorSex'), 'M', 'Sex');
is($doc->store('sgbrKodex'), 'M', 'Kodex');
@@ -63,6 +66,9 @@
is($hash->{title}, 'Sommerüberraschung', 'Corpus title');
is($hash->{store}->{sgbrAuthorSex}, 'M', 'store');
+# Sgbr specific keywords
+is($doc->keywords_string, 'sgbrAuthorAgeClass:X sgbrAuthorSex:M sgbrKodex:M');
+
done_testing;