Added mate morpho tests

Change-Id: I16ab6b777b0d9f1241b755e25f3e0682ce18baaa
diff --git a/lib/KorAP/Field/MultiTermToken.pm b/lib/KorAP/Field/MultiTermToken.pm
index e658f0d..4884e7f 100644
--- a/lib/KorAP/Field/MultiTermToken.pm
+++ b/lib/KorAP/Field/MultiTermToken.pm
@@ -109,6 +109,11 @@
     # Both are attributes
     # Order attributes by reference id
     if (index($a->[5], '@:') == 0 && index($b->[5], '@:') == 0) {
+
+
+#      use Data::Dumper;
+#      die Dumper $a;
+
       my ($a_id) = ($a->[0] =~ m/^<s>(\d+)/);
       my ($b_id) = ($b->[0] =~ m/^<s>(\d+)/);
       if ($a_id > $b_id) {
diff --git a/lib/KorAP/Index/Mate/Morpho2.pm b/lib/KorAP/Index/Mate/MorphoAttr.pm
similarity index 68%
rename from lib/KorAP/Index/Mate/Morpho2.pm
rename to lib/KorAP/Index/Mate/MorphoAttr.pm
index e032f2f..74ba26b 100644
--- a/lib/KorAP/Index/Mate/Morpho2.pm
+++ b/lib/KorAP/Index/Mate/MorphoAttr.pm
@@ -1,4 +1,4 @@
-package KorAP::Index::Mate::Morpho;
+package KorAP::Index::Mate::MorphoAttr;
 use KorAP::Index::Base;
 
 # This attaches morphological information as attributes to the pos
@@ -15,11 +15,12 @@
 
       my $content = $token->hash->{fs}->{f};
 
-      my ($found, $pos, $msd, $id);
+      my ($found, $pos, $msd, $tui);
 
       my $capital = 0;
 
       foreach my $f (@{$content->{fs}->{f}}) {
+
 	#pos
 	if (($f->{-name} eq 'pos') && ($found = $f->{'#text'})) {
 	  $pos = $found;
@@ -37,18 +38,32 @@
 		 ($found = $f->{'#text'}) &&
 		   ($found ne '_')) {
 	  $msd = $found;
-	  $id = $mtt->id_counter;
+	  $tui = $mtt->id_counter;
 	};
       };
 
-      $mtt->add(term => 'mate/m:' . $pos . ($id ? ('$<s>' . $id) : ''));
+      my %term = (
+	term => 'mate/p:' . $pos
+      );
+
+      # There are attributes needed
+      if ($tui) {
+	$term{pti} = 128;
+	$term{payload} = '<s>' . $tui
+      };;
+
+      $mtt->add(%term);
 
       # MSD
       if ($msd) {
 	foreach (split '\|', $msd) {
 	  my ($x, $y) = split "=", $_;
 	  # case, tense, number, mood, person, degree, gender
-	  $mtt->add(term => '@:' . $x . ($y ? '=' . $y : '') . '$<s>' . $id);
+	  $mtt->add(
+	    term => '@:' . $x . ($y ? '=' . $y : ''),
+	    pti => 16,
+	    payload => '<s>' . $tui
+	  );
 	};
       };
     }) or return;
@@ -57,7 +72,7 @@
 };
 
 sub layer_info {
-    ['mate/l=tokens', 'mate/m=tokens']
+    ['mate/l=tokens', 'mate/p=tokens']
 };
 
 1;
diff --git a/lib/KorAP/Index/TreeTagger/Morpho.pm b/lib/KorAP/Index/TreeTagger/Morpho.pm
index 989728b..487b78a 100644
--- a/lib/KorAP/Index/TreeTagger/Morpho.pm
+++ b/lib/KorAP/Index/TreeTagger/Morpho.pm
@@ -42,7 +42,10 @@
 	    my %term = (
 	      term => 'tt/l:' . $found
 	    );
-	    $term{payload} = '<b>' . $certainty if $certainty;
+	    if ($certainty) {
+	      $term{pti} = 129;
+	      $term{payload} = '<b>' . $certainty;
+	    };
 	    $mtt->add(%term);
 	  };
 
@@ -51,7 +54,10 @@
 	    my %term = (
 	      term => 'tt/p:' . $found
 	    );
-	    $term{payload} = '<b>' . $certainty if $certainty;
+	    if ($certainty) {
+	      $term{pti} = 129;
+	      $term{payload} = '<b>' . $certainty;
+	    };
 	    $mtt->add(%term);
 	  };
 	};
diff --git a/lib/KorAP/Index/TreeTagger/Sentences.pm b/lib/KorAP/Index/TreeTagger/Sentences.pm
index 37b49e0..1d62d9f 100644
--- a/lib/KorAP/Index/TreeTagger/Sentences.pm
+++ b/lib/KorAP/Index/TreeTagger/Sentences.pm
@@ -16,7 +16,8 @@
 	o_start => $span->o_start,
 	o_end => $span->o_end,
 	p_end => $span->p_end,
-	payload => '<b>2' # Depth is 2 by default t/p/s
+	pti => 64,
+	payload => '<b>0' # Could be 2 as well t/p/s
       );
       $i++;
     }