Partial fix of dependencies without nodes

Change-Id: Ife409a4d8dc52a3a1c18d9b666e7fe189e3f86ce
diff --git a/lib/KorAP/XML/Field/MultiTermToken.pm b/lib/KorAP/XML/Field/MultiTermToken.pm
index 3087e9d..ad14402 100644
--- a/lib/KorAP/XML/Field/MultiTermToken.pm
+++ b/lib/KorAP/XML/Field/MultiTermToken.pm
@@ -98,16 +98,16 @@
     return ($1, $1);
   }
 
-  # token/span to span - right token
-  elsif ($_[0] =~ m/^<i>(\d+)<i>(\d+)<s>/o) {
+  # token/span to span - right token (including character offsets)
+  elsif ($_[0] =~ m/^<i>\d+<i>\d+<i>(\d+)<i>(\d+)<s>/o) {
     return ($1, $2);
   }
 
   # span to token - right token
-  elsif ($_[0] =~ m/^<b>\d+<i>(\d+)<s>/o) {
+  elsif ($_[0] =~ m/^<i>(\d+)<s>/o) {
     return ($1, $1);
   };
-  carp 'Unknown relation format!';
+  carp 'Unknown relation format! ' . $_[0];
   return (0,0);
 };
 
diff --git a/lib/KorAP/XML/Index/Mate/Dependency.pm b/lib/KorAP/XML/Index/Mate/Dependency.pm
index bb0ab27..0d19cdd 100644
--- a/lib/KorAP/XML/Index/Mate/Dependency.pm
+++ b/lib/KorAP/XML/Index/Mate/Dependency.pm
@@ -1,6 +1,7 @@
 package KorAP::XML::Index::Mate::Dependency;
 use KorAP::XML::Index::Base;
-
+use strict;
+use warnings;
 our $NODE_LABEL = '&&&';
 
 sub parse {
@@ -39,9 +40,10 @@
 	  # next if $_->{-label} eq '--';
 
 	  # Get target node - not very elegant
-	  my $target = $stream->get_node(
-	    $source, 'mate/d:' . $NODE_LABEL
-	  );
+	  # This is only necessary for nodes with attributes
+	  #	  my $target = $stream->get_node(
+	  #	    $source, 'mate/d:' . $NODE_LABEL
+	  #	  );
 
 	  # Target is at the same position!
 	  my $pos = $source->pos;
@@ -50,8 +52,8 @@
 	    pti => 32, # term-to-term relation
 	    payload =>
 	      '<i>' . $pos . # right part token position
-		'<s>' . $target->tui . # left part tui
-		  '<s>' . $target->tui # right part tui
+		'<s>0' . # $target->tui . # left part tui
+		  '<s>0'  # . $target->tui # right part tui
 		);
 
 	  # Add relations
@@ -73,9 +75,10 @@
 	  my $to   = $_->{span}->{-to};
 
 	  # Get source node
-	  my $source_term = $stream->get_node(
-	    $source, 'mate/d:' . $NODE_LABEL
-	  );
+	  # This is only necessary for nodes with attributes
+	  #	  my $source_term = $stream->get_node(
+	  #	    $source, 'mate/d:' . $NODE_LABEL
+	  #	  );
 
 	  # Target
 	  my $target = $tokens->token($from, $to);
@@ -84,17 +87,17 @@
 	  if ($target) {
 
 	    # Get target node
-	    my $target_term = $stream->get_node(
-	      $target, 'mate/d:' . $NODE_LABEL
-	    );
+	    #	    my $target_term = $stream->get_node(
+	    #	      $target, 'mate/d:' . $NODE_LABEL
+	    #	    );
 
 	    $mtt->add(
 	      term => '>:mate/d:' . $label,
 	      pti => 32, # term-to-term relation
 	      payload =>
 		'<i>' . $target->pos . # right part token position
-		  '<s>' . $source_term->tui . # left part tui
-		    '<s>' . $target_term->tui # right part tui
+		  '<s>0' . # $source_term->tui . # left part tui
+		    '<s>0' # . $target_term->tui # right part tui
 	    );
 
 	    my $target_mtt = $stream->pos($target->pos);
@@ -103,8 +106,8 @@
 	      pti => 32, # term-to-term relation
 	      payload =>
 		'<i>' . $source->pos . # left part token position
-		  '<s>' . $source_term->tui . # left part tui
-		    '<s>' . $target_term->tui # right part tui
+		  '<s>0' . # $source_term->tui . # left part tui
+		    '<s>0' # . $target_term->tui # right part tui
 	    );
 	  }
 
@@ -112,18 +115,20 @@
 	  elsif ($target = $tokens->span($from, $to)) {
 
 	    # Get target node
-	    my $target_span = $stream->get_node(
-	      $target, 'mate/d:' . $NODE_LABEL
-	    );
+	    #	    my $target_span = $stream->get_node(
+	    #	      $target, 'mate/d:' . $NODE_LABEL
+	    #	    );
 
 	    $mtt->add(
 	      term => '>:mate/d:' . $label,
 	      pti => 33, # term-to-element relation
 	      payload =>
-		'<i>' . $target->p_start . # right part start position
-		  '<i>' . $target->p_end . # right part end position
-		    '<s>' . $source_term->tui . # left part tui
-		      '<s>' . $target_span->tui # right part tui
+		'<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
+			'<s>0' . # $source_term->tui . # left part tui
+			  '<s>0' # . $target_span->tui # right part tui
 	    );
 
 	    my $target_mtt = $stream->pos($target->p_start);
@@ -131,16 +136,15 @@
 	      term => '<:mate/d:' . $label,
 	      pti => 34, # element-to-term relation
 	      payload =>
-		'<i>' . $target_span->p_end . # end position
-		  '<i>' . $source->pos . # left part token position
-		    '<s>' . $source_term->tui . # left part tui
-		      '<s>' . $target_span->tui # right part tui
+		'<i>' . $source->pos . # left part token position
+		  '<s>0' . # $source_term->tui . # left part tui
+		    '<s>0' # . $target_span->tui # right part tui
 
 	    );
 	  }
 	  else {
-#	    use Data::Dumper;
-#	    warn '2###### ' . Dumper($content);
+	    #	    use Data::Dumper;
+	    #	    warn '2###### ' . Dumper($content);
 	  };
 	};
       };
@@ -149,10 +153,10 @@
   return 1;
 };
 
-
 sub layer_info {
   ['mate/d=rels']
 };
 
-
 1;
+
+__END__
diff --git a/t/index/mate_dependency.t b/t/index/mate_dependency.t
index 06a2ce5..e322bd2 100644
--- a/t/index/mate_dependency.t
+++ b/t/index/mate_dependency.t
@@ -14,20 +14,17 @@
 
 my $data = $tokens->to_data->{data}->{stream};
 
-# Unary relation
-is($data->[4]->[2], '<:mate/d:--$<b>32<i>4<s>1<s>1', '< rel 1 (unary)');
-is($data->[4]->[1], '>:mate/d:--$<b>32<i>4<s>1<s>1', '> rel 1 (unary)');
-is($data->[4]->[8], 'mate/d:&&&$<b>128<s>1', 'token for rel 1 (unary)');
+is($data->[4]->[1], '<:mate/d:--$<b>32<i>4<s>0<s>0', '< rel 1 (unary)');
+is($data->[4]->[2], '>:mate/d:--$<b>32<i>4<s>0<s>0', '> rel 1 (unary)');
+#is($data->[4]->[8], 'mate/d:&&&$<b>128<s>1', 'token for rel 1 (unary)');
 
-is($data->[1]->[0], '>:mate/d:NK$<b>32<i>3<s>1<s>1', '> rel 2 (term-to-term)');
-is($data->[1]->[3], 'mate/d:&&&$<b>128<s>1', '< rel 2 (term-to-term)');
-is($data->[3]->[1], '<:mate/d:NK$<b>32<i>1<s>1<s>1', '< rel 2 (term-to-term)');
-is($data->[3]->[5], 'mate/d:&&&$<b>128<s>1', '< rel 2 (term-to-term)');
+is($data->[1]->[0], '>:mate/d:NK$<b>32<i>3<s>0<s>0', '> rel 2 (term-to-term)');
+#is($data->[1]->[3], 'mate/d:&&&$<b>128<s>1', '< rel 2 (term-to-term)');
+
+is($data->[3]->[1], '<:mate/d:NK$<b>32<i>1<s>0<s>0', '< rel 2 (term-to-term)');
+#is($data->[3]->[5], 'mate/d:&&&$<b>128<s>1', '< rel 2 (term-to-term)');
 
 
 done_testing;
-
 __END__
 
-
-
diff --git a/t/real/wpd.t b/t/real/wpd.t
index c3ddc7b..3dcea9d 100644
--- a/t/real/wpd.t
+++ b/t/real/wpd.t
@@ -72,10 +72,10 @@
 
 my $stream = $tokens->to_data->{data}->{stream};
 
-is($stream->[77]->[0], '<:mate/d:--$<b>34<i>78<i>78<s>1<s>1', 'element to term');
-is($stream->[77]->[1], '<>:mate/d:&&&$<b>64<i>498<i>499<i>78<b>0<s>1', 'element to term');
-is($stream->[78]->[0], '>:mate/d:--$<b>33<i>77<i>78<s>1<s>1', 'term to element');
-is($stream->[78]->[3], 'mate/d:&&&$<b>128<s>1', 'Node');
+is($stream->[77]->[0], '<:mate/d:--$<b>34<i>498<i>499<i>78<i>78<s>0<s>0', 'element to term');
+#is($stream->[77]->[1], '<>:mate/d:&&&$<b>64<i>498<i>499<i>78<b>0<s>1', 'element to term');
+is($stream->[78]->[0], '>:mate/d:--$<b>33<i>77<i>78<s>0<s>0', 'term to element');
+# is($stream->[78]->[3], 'mate/d:&&&$<b>128<s>1', 'Node');
 
 
 done_testing;
diff --git a/t/transform.t b/t/transform.t
index 498572b..6b83124 100644
--- a/t/transform.t
+++ b/t/transform.t
@@ -167,8 +167,8 @@
   'tt/p:FM$<b>129<b>54|'.
   '<>:tt/s:s$<b>64<i>0<i>6083<i>923<b>0|'.
   '-:tt/sentences$<i>1|'.
-  '>:mate/d:PNC$<b>32<i>2<s>1<s>1|'.
-  'mate/d:&&&$<b>128<s>1|'.
+  '>:mate/d:PNC$<b>32<i>2<s>0<s>0|'.
+#  'mate/d:&&&$<b>128<s>1|'.
   'xip/p:SYMBOL|'.
   'xip/l:A|'.
   '<>:xip/c:TOP$<b>64<i>0<i>74<i>13<b>0|'.