Skip to content

Commit

Permalink
Support idno
Browse files Browse the repository at this point in the history
Change-Id: I05ae12e6076a911d8f9c69b032afeb6fdb792d85
  • Loading branch information
Akron committed Jul 26, 2024
1 parent 9d01c1e commit 1f95122
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
0.57 2024-07-25
- Support award notes in i5.
- Add support for idno (with @rend) in i5.
- Add support for ISBN in i5.

0.56 2024-06-05
- Add support für corpusexplorer.
Expand Down
44 changes: 36 additions & 8 deletions lib/KorAP/XML/Meta/I5.pm
Original file line number Diff line number Diff line change
Expand Up @@ -454,15 +454,41 @@ sub parse {
$self->{A_file_edition_statement} = $temp2 if $temp2;
};

if (my $availability = $temp->at('publicationStmt > availability')) {
$temp2 = _squish $availability->all_text;
$self->{S_availability} = $temp2 if $temp2;
};
if (my $pubstatement = $temp->at('publicationStmt')) {

if (my $distributor = $temp->at('publicationStmt > distributor')) {
$temp2 = _squish $distributor->all_text;
$self->{A_distributor} = $temp2 if $temp2;
}
if (my $availability = $pubstatement->at('> availability')) {
$temp2 = _squish $availability->all_text;
$self->{S_availability} = $temp2 if $temp2;
};

if (my $distributor = $pubstatement->at('> distributor')) {
$temp2 = _squish $distributor->all_text;
$self->{A_distributor} = $temp2 if $temp2;
};

$pubstatement->find('> idno')->each(
sub {
return unless $_->attr('type');
if ($_->attr('type') eq 'ISBN') {
$temp2 = _squish $_->all_text or return;
$self->{S_ISBN} = $temp2 if $temp2;
}

# When an idno has a rend, render value as a link
elsif (my $rend = $_->attr('rend')) {
$temp2 = _squish $_->all_text or return;
my ($key, $title) = split(';', $_->attr('rend'), 2);

if ($_->attr('type') eq 'URL' || $_->attr('type') eq 'URI') {
$self->{'A_' . $key} = $self->korap_data_uri($temp2, title => $title // $temp2);
}
else {
$self->{'A_' . $key} = $temp2;
}
}
}
);
};
};

if ($temp = $dom->at('profileDesc > langUsage > language[id]')) {
Expand Down Expand Up @@ -625,6 +651,8 @@ The order may indicate a field to be overwritten.
fileDesc editionStmt fileEditionStatement ATTACHMENT
fileDesc publicationStmt > availability availability STRING
fileDesc publicationStmt > distributor distributor ATTACHMENT
fileDesc publicationStmt > idno[type=ISBN] isbn STRING
fileDesc publicationStmt > idno @rend[0] ATTACHMENT
profileDesc > langUsage > language[id]@id language STRING
=item B<On text level>
Expand Down
4 changes: 3 additions & 1 deletion t/real/bzk_2.t
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ is($meta->{K_text_class}->[0], 'politik', 'Correct Text Class');
is($meta->{K_text_class}->[1], 'ausland', 'Correct Text Class');
ok(!$meta->{K_text_class}->[2], 'Correct Text Class');


is($meta->{D_creation_date}, '19590219', 'Creation date');
is($meta->{S_availability}, 'ACA-NC-LC', 'License');
ok(!$meta->{pages}, 'Pages');
Expand All @@ -74,6 +73,9 @@ is($meta->{T_doc_sub_title}, 'Organ des Zentralkomitees der Sozialistischen Einh
ok(!$meta->{T_doc_author}, 'Correct Doc author');
ok(!$meta->{A_doc_editor}, 'Correct doc editor');

is($meta->{A_URN},'data:application/x.korap-link;title=urn%3Anbn%3Ade%3A101%3A1-2019012904515398173807,http%3A%2F%2Fnbn-resolving.de%2Furn%3Anbn%3Ade%3A101%3A1-2019012904515398173807');
is($meta->{S_ISBN},'978-3-7325-6705-8');

# Tokenization
use_ok('KorAP::XML::Tokenizer');

Expand Down
5 changes: 5 additions & 0 deletions t/real/corpus/BZK/D59/00089/header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
<publicationStmt>
<distributor/>
<pubAddress/>
<idno type="URN">urn:nbn:de:101:1-2019012904515398173807</idno>
<idno type="URL" rend="URN;urn:nbn:de:101:1-2019012904515398173807">http://nbn-resolving.de/urn:nbn:de:101:1-2019012904515398173807</idno>
<idno type="ISBN">978-3-7325-6705-8</idno>
<idno type="URL">http://d-nb.info/1176524615/34</idno>
<idno type="IDN">1176524615</idno>
<availability region="world">ACA-NC-LC</availability>
<pubDate/>
</publicationStmt>
Expand Down

0 comments on commit 1f95122

Please sign in to comment.