Add --auto-textsigle <start-sigle> option

Also allows for processing plain TEI P5 files without any IDs.

Change-Id: Ic16b089c916d2e50458aa1aa6cb80ce4d37d97ba
diff --git a/lib/KorAP/XML/TEI.pm b/lib/KorAP/XML/TEI.pm
index 1111c8b..f7768e7 100644
--- a/lib/KorAP/XML/TEI.pm
+++ b/lib/KorAP/XML/TEI.pm
@@ -4,7 +4,7 @@
 use warnings;
 
 use Exporter 'import';
-our @EXPORT_OK = qw(remove_xml_comments escape_xml escape_xml_minimal replace_entities);
+our @EXPORT_OK = qw(remove_xml_comments escape_xml escape_xml_minimal replace_entities increase_auto_textsigle);
 
 # convert '&', '<' and '>' into their corresponding sgml-entities
 my %ent_without_quot = (
@@ -180,4 +180,16 @@
   return($_);
 };
 
+sub increase_auto_textsigle {
+  my $sigle = shift;
+
+  if ($sigle =~ /(\d+)$/) {
+    my $number = $1;
+    my $length = length($number);
+    $number++;
+    my $new_number = sprintf("%0${length}d", $number);
+    $sigle =~ s/\d+$/$new_number/;
+  }
+  return $sigle;
+}
 1;