Index translator as a text using env variable
Change-Id: I42ba850d6d489643ac0fc382b79229450d7efd07
diff --git a/Changes b/Changes
index 9c1efe6..927bf37 100644
--- a/Changes
+++ b/Changes
@@ -1,7 +1,10 @@
-0.57 2024-07-25
+0.57 2024-07-26
- Support award notes in i5.
- Add support for idno (with @rend) in i5.
- Add support for ISBN in i5.
+ - Translator is now indexed as Text in i5, when
+ K2K_TRANSLATOR_TEXT is set as an environment
+ variable.
0.56 2024-06-05
- Add support für corpusexplorer.
diff --git a/lib/KorAP/XML/Meta/I5.pm b/lib/KorAP/XML/Meta/I5.pm
index 36598fd..703b609 100644
--- a/lib/KorAP/XML/Meta/I5.pm
+++ b/lib/KorAP/XML/Meta/I5.pm
@@ -53,7 +53,6 @@
# "pubDate",
# "creationDate"
-
sub _squish ($) {
for ($_[0]) {
s!\s\s+! !g;
@@ -140,7 +139,14 @@
if ($editor && $editor->attr('role') && $editor->attr('role') eq 'translator') {
# Translator is only supported on the text level currently
$translator = _squish $editor->all_text;
- $self->{A_translator} = $translator if $translator;
+ if ($translator) {
+ if (!!($ENV{K2K_TRANSLATOR_TEXT})) {
+ $self->{'T_translator'} = $translator;
+ } else {
+ $self->{'A_translator'} = $translator;
+ $self->log->warn('Indexing translator as an attachment is deprecated');
+ };
+ };
$editor = undef;
}
else {
@@ -633,7 +639,7 @@
=item B<On all levels>
- (analytic, monogr) editor[role=translator] translator ATTACHMENT
+ (analytic, monogr) editor[role=translator] translator ATTACHMENT/TEXT
pubPlace@key pubPlaceKey STRING
pubPlace pubPlace STRING
imprint publisher publisher ATTACHMENT
diff --git a/t/real/drukola.t b/t/real/drukola.t
index bc073ed..74dfef3 100644
--- a/t/real/drukola.t
+++ b/t/real/drukola.t
@@ -43,6 +43,7 @@
ok(!$meta->{A_publisher}, 'Publisher');
ok(!$meta->{A_editor}, 'Editor');
is($meta->{A_translator}, '[TRANSLATOR]', 'Translator');
+ok(!$meta->{T_translator}, 'Translator');
#is($meta->{S_text_type}, 'Autobiographie', 'Correct Text Type');
ok(!$meta->{S_text_type_art}, 'Correct Text Type Art');
# is($meta->{S_text_type_ref}, '', 'Correct Text Type Ref');
@@ -148,5 +149,20 @@
is($meta->corpus_sigle, 'Corola-Journal', 'Corpus Sigle');
is($meta->{T_title}, 'APOGEUL ARHITECTURĂ ȘI DESIGN', 'Title');
+
+
+# Old translator behaviour:
+our %ENV;
+$ENV{K2K_TRANSLATOR_TEXT} = 1;
+$path = catdir(dirname(__FILE__), 'corpus','CoRoLa','BBU','BLOG','83709_a_82384');
+ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document');
+ok($doc->parse, 'Parse document');
+
+is($doc->text_sigle, 'BBU/BLOG/83709_a_82384', 'Correct text sigle');
+$meta = $doc->meta;
+is($meta->{T_translator}, '[TRANSLATOR]', 'Translator');
+ok(!$meta->{A_translator}, 'Translator');
+
+
done_testing;
__END__