Introduce support for CorpusExplorer

Change-Id: I2133463dbf5e851b371e46f4b9c76bba71611532
diff --git a/lib/KorAP/XML/Annotation/CorpusExplorer/Morpho.pm b/lib/KorAP/XML/Annotation/CorpusExplorer/Morpho.pm
new file mode 100644
index 0000000..5d128bf
--- /dev/null
+++ b/lib/KorAP/XML/Annotation/CorpusExplorer/Morpho.pm
@@ -0,0 +1,60 @@
+package KorAP::XML::Annotation::CorpusExplorer::Morpho;
+use KorAP::XML::Annotation::Base;
+use Mojo::Util qw'trim';
+
+sub parse {
+  my $self = shift;
+
+  $$self->add_tokendata(
+    foundry => 'corpusexplorer',
+    layer => 'morpho',
+    cb => sub {
+      my ($stream, $token) = @_;
+      my $mtt = $stream->pos($token->get_pos);
+
+      my $content = $token->get_hash->{fs}->{f} or return;
+
+      $content = ref $content ne 'ARRAY' ? [$content] : $content;
+
+      my $start = $token->get_hash->{-from};
+
+      # Iterate over feature structures
+      foreach my $fs (@$content) {
+        $content = $fs->{fs}->{f} or next;
+
+        foreach (@$content) {
+
+          next unless $_->{'#text'};
+          my $value = trim $_->{'#text'} or next;
+
+          # POS
+          if ($_->{-name} eq 'ctag') {
+            $mtt->add_by_term('cex/p:' . $value);
+          }
+
+          # Lemma
+          elsif ($_->{-name} eq 'lemma') {
+            $mtt->add_by_term('cex/l:' . $value);
+          }
+
+          # Phrase
+          elsif ($_->{-name} eq 'phrase') {
+            $mtt->add_by_term('cex/phrase:' . $value);
+          };
+
+          if ($start == 809) {
+            warn $mtt->to_string;
+            warn $value;
+          };
+        };
+      };
+    }) or return;
+
+  return 1;
+};
+
+sub layer_info {
+  ['cex/p=tokens','cex/l=tokens','cex/phrase=tokens'];
+};
+
+1;
diff --git a/lib/KorAP/XML/Krill.pm b/lib/KorAP/XML/Krill.pm
index ead3638..e8f10c4 100644
--- a/lib/KorAP/XML/Krill.pm
+++ b/lib/KorAP/XML/Krill.pm
@@ -16,7 +16,7 @@
 
 our @EXPORT_OK = qw(get_file_name get_file_name_from_glob);
 
-our $VERSION = '0.55';
+our $VERSION = '0.56';
 
 has 'path';
 has [qw/text_sigle doc_sigle corpus_sigle/];
diff --git a/lib/KorAP/XML/Meta/I5.pm b/lib/KorAP/XML/Meta/I5.pm
index 4e28876..49841c7 100644
--- a/lib/KorAP/XML/Meta/I5.pm
+++ b/lib/KorAP/XML/Meta/I5.pm
@@ -291,6 +291,10 @@
           $key = 'A_';
           my $title = $_->att('desc');
           $value = $self->korap_data_uri($value, title => ($title // $value));
+        } elsif ($xtype eq 'number') {
+          $self->log->warn('Number currently not supported as xenodata type, treated as string');
+          $key = 'S_';
+          # Maybe render as Integer - but it's understood as a string
         } else {
           $self->log->warn('Unknown xenodata type: ' . $xtype);
           return;