Cleanup: to_zip should be chainable to always reset after to_zip
Change-Id: I24a0bb0b24657cfbc722567550789278926d287c
diff --git a/lib/KorAP/XML/TEI/Annotations.pm b/lib/KorAP/XML/TEI/Annotations.pm
index 2f7895a..ab450fc 100644
--- a/lib/KorAP/XML/TEI/Annotations.pm
+++ b/lib/KorAP/XML/TEI/Annotations.pm
@@ -56,8 +56,9 @@
# Write data to zip stream
sub to_zip {
- my ($self, $zip, $text_id) = @_;
- $zip->print(encode('UTF-8', $self->to_string($text_id)));
+ my ($self, $zip, $text_id, $param) = @_;
+ $zip->print(encode('UTF-8', $self->to_string($text_id, $param)));
+ return $self;
};
diff --git a/lib/KorAP/XML/TEI/Annotations/Collector.pm b/lib/KorAP/XML/TEI/Annotations/Collector.pm
index ed11d23..510d339 100644
--- a/lib/KorAP/XML/TEI/Annotations/Collector.pm
+++ b/lib/KorAP/XML/TEI/Annotations/Collector.pm
@@ -1,7 +1,6 @@
package KorAP::XML::TEI::Annotations::Collector;
use base 'KorAP::XML::TEI::Annotations';
use KorAP::XML::TEI::Annotations::Annotation;
-use Encode qw(encode decode);
use Log::Any '$log';
use strict;
use warnings;
@@ -91,11 +90,4 @@
};
-# Write data to zip stream (as utf8)
-sub to_zip {
- my ($self, $zip, $text_id, $param) = @_;
- $zip->print(encode('UTF-8', $self->to_string($text_id, $param)));
-};
-
-
1;
diff --git a/lib/KorAP/XML/TEI/Data.pm b/lib/KorAP/XML/TEI/Data.pm
index 0de4aca..9d4b71c 100644
--- a/lib/KorAP/XML/TEI/Data.pm
+++ b/lib/KorAP/XML/TEI/Data.pm
@@ -93,6 +93,7 @@
# which are counted as 1 (search for '&' in data.xml and see
# corresponding indices in $_tokens_file)
$zip->print(encode('UTF-8', $self->to_string($text_id)));
+ return $self;
};
diff --git a/lib/KorAP/XML/TEI/Header.pm b/lib/KorAP/XML/TEI/Header.pm
index b5b92dc..870a2f9 100644
--- a/lib/KorAP/XML/TEI/Header.pm
+++ b/lib/KorAP/XML/TEI/Header.pm
@@ -168,6 +168,7 @@
sub to_zip {
my ($self, $zip) = @_;
$zip->print(encode('UTF-8', $self->to_string));
+ return $self;
};
diff --git a/script/tei2korapxml b/script/tei2korapxml
index e276822..c18f941 100755
--- a/script/tei2korapxml
+++ b/script/tei2korapxml
@@ -262,10 +262,6 @@
$param |= XCT_LINE_NUMBERS if DEBUG;
my $tree_data = XML::CompactTree::XS::readSubtreeToPerl($reader, $param);
- $structures->reset;
-
- $tokens->reset unless $skip_inline_tokens;
-
# ~ whitespace related issue ~
$add_one = 0;
%ws = ();
@@ -304,15 +300,12 @@
$cons_tok->tokenize($data->data)->to_zip(
$zipper->new_stream("$dir/$base_dir/" . $cons_tok->name . '.xml'),
$text_id_esc
- );
+ )->reset;
$aggr_tok->tokenize($data->data)->to_zip(
$zipper->new_stream("$dir/$base_dir/" . $aggr_tok->name . '.xml'),
$text_id_esc
- );
-
- $aggr_tok->reset;
- $cons_tok->reset;
+ )->reset;
};
# ~ write structures ~
@@ -321,7 +314,7 @@
$zipper->new_stream("$dir/$_structure_dir/${_structure_file}.xml"),
$text_id_esc,
2 # = structure serialization
- );
+ )->reset;
};
# ~ write tokens ~
@@ -330,7 +323,7 @@
$zipper->new_stream("$dir/$_tokens_dir/${_tokens_file}.xml"),
$text_id_esc,
$_INLINE_ANNOT # Either 0 = tokens without inline or 1 = tokens with inline
- );
+ )->reset;
};
# reinit.