Replace deprecated MultiTerm add() method from Mate parser

Change-Id: I9eadf2b5078859682e838900294f365387322b11
diff --git a/lib/KorAP/XML/Annotation/Mate/Dependency.pm b/lib/KorAP/XML/Annotation/Mate/Dependency.pm
index 7a85859..97d69aa 100644
--- a/lib/KorAP/XML/Annotation/Mate/Dependency.pm
+++ b/lib/KorAP/XML/Annotation/Mate/Dependency.pm
@@ -27,6 +27,7 @@
       # Get relation information
       my $rel = $content->{rel};
       $rel = [$rel] unless ref $rel eq 'ARRAY';
+      my $mt;
 
       # Iterate over relations
       foreach (@$rel) {
@@ -48,23 +49,17 @@
           # Target is at the same position!
           my $pos = $source->get_pos;
 
-          my %rel = (
-            pti => 32, # term-to-term relation
-            payload =>
-              '<i>' . $pos # . # right part token position
+          # Add relations
+          $mt = $mtt->add_by_term('>:mate/d:' . $label);
+          $mt->set_pti(32); # term-to-term relation
+          $mt->set_payload(
+            '<i>' . $pos # . # right part token position
               #    '<s>0' . # $target->tui . # left part tui
               #      '<s>0'  # . $target->tui # right part tui
-            );
-
-          # Add relations
-          $mtt->add(
-            term => '>:mate/d:' . $label,
-            %rel
           );
-          $mtt->add(
-            term => '<:mate/d:' . $label,
-            %rel
-          );
+          my $clone = $mt->clone;
+          $clone->set_term('<:mate/d:' . $label);
+          $mtt->add_blessed($clone);
         }
 
         # Not unary
@@ -91,24 +86,22 @@
             #        $target, 'mate/d:' . $NODE_LABEL
             #      );
 
-            $mtt->add(
-              term => '>:mate/d:' . $label,
-              pti => 32, # term-to-term relation
-              payload =>
-                '<i>' . $target->get_pos # . # right part token position
+            $mt = $mtt->add_by_term('>:mate/d:' . $label);
+            $mt->set_pti(32); # term-to-term relation
+            $mt->set_payload(
+              '<i>' . $target->get_pos # . # right part token position
                 #      '<s>0' . # $source_term->tui . # left part tui
                 #        '<s>0' # . $target_term->tui # right part tui
-              );
+            );
 
             my $target_mtt = $stream->pos($target->get_pos);
-            $target_mtt->add(
-              term => '<:mate/d:' . $label,
-              pti => 32, # term-to-term relation
-              payload =>
-                '<i>' . $source->get_pos # . # left part token position
+            $mt = $target_mtt->add_by_term('<:mate/d:' . $label);
+            $mt->set_pti(32); # term-to-term relation
+            $mt->set_payload(
+              '<i>' . $source->get_pos # . # left part token position
                 #      '<s>0' . # $source_term->tui . # left part tui
                 #        '<s>0' # . $target_term->tui # right part tui
-              );
+            );
           }
 
           # Relation is possibly term-to-element with a found target!
@@ -119,11 +112,10 @@
             #        $target, 'mate/d:' . $NODE_LABEL
             #      );
 
-            $mtt->add(
-              term => '>:mate/d:' . $label,
-              pti => 33, # term-to-element relation
-              payload =>
-                '<i>' . $target->o_start . # end position
+            $mt = $mtt->add_by_term('>:mate/d:' . $label);
+            $mt->set_pti(33); # term-to-element relation
+            $mt->set_payload(
+              '<i>' . $target->o_start . # end position
                 '<i>' . $target->o_end . # end position
                 '<i>' . $target->p_start . # right part start position
                 '<i>' . $target->p_end # . # right part end position
@@ -132,17 +124,15 @@
               );
 
             my $target_mtt = $stream->pos($target->p_start);
-            $target_mtt->add(
-              term => '<:mate/d:' . $label,
-              pti => 34, # element-to-term relation
-              payload =>
-                '<i>' . $target->o_start . # end position
+            $mt = $target_mtt->add_by_term('<:mate/d:' . $label);
+            $mt->set_pti(34); # element-to-term relation
+            $mt->set_payload(
+              '<i>' . $target->o_start . # end position
                 '<i>' . $target->o_end . # end position
                 '<i>' . $target->p_end . # right part end position
                 '<i>' . $source->get_pos # . # left part token position
                 #      '<s>0' . # $source_term->tui . # left part tui
                 #        '<s>0' # . $target_span->tui # right part tui
-
               );
           }
           else {
diff --git a/lib/KorAP/XML/Annotation/Mate/Morpho.pm b/lib/KorAP/XML/Annotation/Mate/Morpho.pm
index 0d1744b..54d07e5 100644
--- a/lib/KorAP/XML/Annotation/Mate/Morpho.pm
+++ b/lib/KorAP/XML/Annotation/Mate/Morpho.pm
@@ -22,7 +22,7 @@
         #pos
         if (($f->{-name} eq 'pos') &&
               ($found = $f->{'#text'})) {
-          $mtt->add(term => 'mate/p:' . $found);
+          $mtt->add_by_term('mate/p:' . $found);
         }
 
         # lemma
@@ -30,7 +30,7 @@
                  && ($found = $f->{'#text'})
                  && $found ne '--') {
           # b($found)->decode('latin-1')->encode->to_string
-          $mtt->add(term => 'mate/l:' . $found);
+          $mtt->add_by_term('mate/l:' . $found);
         }
 
         # MSD
@@ -40,7 +40,7 @@
           foreach (split '\|', $found) {
             my ($x, $y) = split "=", $_;
             # case, tense, number, mood, person, degree, gender
-            $mtt->add(term => 'mate/m:' . $x . ($y ? ':' . $y : ''));
+            $mtt->add_by_term('mate/m:' . $x . ($y ? ':' . $y : ''));
           };
         };
       };
diff --git a/lib/KorAP/XML/Annotation/Mate/MorphoAttr.pm b/lib/KorAP/XML/Annotation/Mate/MorphoAttr.pm
index 67818f6..fd0b9c4 100644
--- a/lib/KorAP/XML/Annotation/Mate/MorphoAttr.pm
+++ b/lib/KorAP/XML/Annotation/Mate/MorphoAttr.pm
@@ -19,6 +19,8 @@
 
       my $capital = 0;
 
+      my $mt;
+
       foreach my $f (@{$content->{fs}->{f}}) {
 
         #pos
@@ -30,7 +32,7 @@
         elsif (($f->{-name} eq 'lemma')
                  && ($found = $f->{'#text'})
                  && $found ne '--') {
-          $mtt->add(term => 'mate/l:' . $found);
+          $mtt->add_by_term('mate/l:' . $found);
         }
 
         # MSD
@@ -42,28 +44,22 @@
         };
       };
 
-      my %term = (
-        term => 'mate/p:' . $pos
-      );
+      $mt = $mtt->add_by_term('mate/p:' . $pos);
 
       # There are attributes needed
       if ($tui) {
-        $term{pti} = 128;
-        $term{payload} = '<s>' . $tui
+        $mt->set_pti(128);
+        $mt->set_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 : ''),
-            pti => 16,
-            payload => '<s>' . $tui
-          );
+          $mt = $mtt->add_by_term('@:' . $x . ($y ? '=' . $y : ''));
+          $mt->set_pti(16);
+          $mt->set_payload('<s>' . $tui);
         };
       };
     }) or return;