Fixing the sort order (2)
Change-Id: Ifb9cf8bc32368f81fc56c267e4c93f036c8e21d5
diff --git a/lib/KorAP/XML/Field/MultiTermToken.pm b/lib/KorAP/XML/Field/MultiTermToken.pm
index c12d35a..dbc0880 100644
--- a/lib/KorAP/XML/Field/MultiTermToken.pm
+++ b/lib/KorAP/XML/Field/MultiTermToken.pm
@@ -147,18 +147,17 @@
(index($b->[5], '<:') == 0 || index($b->[5],'>:') == 0)) {
my $a_end = ($a->pti < 34 ? $a->p_start : (
- ($a->pti == 35 ? ($a->[0] =~ /^(?:<i>\d+){4}<i>(\d+)</) :
- ($a->[0] =~ /^(?:<i>\d+){2}<i>(\d+)</)
+ ($a->pti == 35 ? ($a->[0] =~ /^(?:<i>\d+){4}<i>(\d+)</ && $1) :
+ ($a->[0] =~ /^(?:<i>\d+){2}<i>(\d+)</ && $1)
)
));
my $b_end = ($b->pti < 34 ? $b->p_start : (
- ($b->pti == 35 ? ($b->[0] =~ /^(?:<i>\d+){4}<i>(\d+)</) :
- ($b->[0] =~ /^(?:<i>\d+){2}<i>(\d+)</)
+ ($b->pti == 35 ? ($b->[0] =~ /^(?:<i>\d+){4}<i>(\d+)</ && $1) :
+ ($b->[0] =~ /^(?:<i>\d+){2}<i>(\d+)</ && $1)
)
));
-
# my $a_end = $a->[2] // 0;
# my $b_end = $b->[2] // 0;
diff --git a/t/sort_tokens.t b/t/sort_tokens.t
index 379f835..e729729 100644
--- a/t/sort_tokens.t
+++ b/t/sort_tokens.t
@@ -123,36 +123,6 @@
'<i>7<i>4<i>7<s>6<s>4<s>2'), 'New rel');
-is($mtt->to_string,
- '[(0-5)'.
- # 2 -> 2-4
- '>:child-of$<b>33<i>0<i>0' . '<i>2<i>4<s>2<s>1<s>3|'.
- # 2-7 -> 1-7
- '>:child-of$<b>35<i>0<i>0<i>0<i>0' . '<i>7' . '<i>1<i>7<s>2<s>4<s>2|'.
- # 2-7 -> 2-4
- '<:child-of$<b>35<i>0<i>0<i>0<i>0' . '<i>7' . '<i>2<i>4<s>5<s>4<s>3|'.
-
- # 2-7 -> 4-7
- '<:child-of$<b>35<i>0<i>0<i>0<i>0' . '<i>7' . '<i>4<i>7<s>6<s>4<s>2|' .
-
- # 2 -> 3
- # '>:child-of$<b>32' . '<i>3<s>2<s>4<s>2|'.
- # 2-4 -> 2-7
- '>:child-of$<b>35<i>0<i>0<i>0<i>0' . '<i>4' . '<i>2<i>7<s>1<s>3<s>4|'.
- # 2-4 -> 3
- '<:child-of$<b>34<i>0<i>0' . '<i>4' . '<i>3<s>3<s>3<s>1|' .
- # 2-4 -> 4
- '<:child-of$<b>34<i>0<i>0' . '<i>4' . '<i>4<s>4<s>3<s>1' . #|'.
- ']' ,
- 'Check sorted relations'
- );
-
-done_testing;
-__END__
-
-
-
-
# 2 to 3
ok($mtt->add(term => '>:child-of',
@@ -160,48 +130,31 @@
payload => '<i>3<s>2<s>4<s>2'
), 'New rel');
-
-done_testing;
-__END__
-
-NOTE: Sorting of the candidate spans can alternatively be done in
- * indexing, instead of here. (first by left positions and then by
- * right positions)
-
-
+#NOTE: Sorting of the candidate spans can alternatively be done in
+# * indexing, instead of here. (first by left positions and then by
+# * right positions)
is($mtt->to_string,
'[(0-5)'.
- '>:child-of$<i>2<i>4<s>2<s>1<s>3|'.
- '>:child-of$<i>3<s>2<s>4<s>2|'.
-
- '>:child-of$<i>4<i>2<i>7<s>1<s>3<s>4|'.
- '<:child-of$<i>4<b>0<i>3<s>3<s>3<s>1|'.
- '<:child-of$<i>4<b>0<i>4<s>4<s>3<s>1|'.
- '>:child-of$<i>7<i>1<i>7<s>2<s>4<s>2|'.
- '<:child-of$<i>7<i>2<i>4<s>5<s>4<s>3|'.
- '<:child-of$<i>7<i>4<i>7<s>6<s>4<s>2]',
+ # 2 -> 2-4
+ '>:child-of$<b>33<i>0<i>0' . '<i>2<i>4<s>2<s>1<s>3|'.
+ # 2 -> 3
+ '>:child-of$<b>32' . '<i>3<s>2<s>4<s>2|'.
+ # 2-4 -> 2-7
+ '>:child-of$<b>35<i>0<i>0<i>0<i>0' . '<i>4' . '<i>2<i>7<s>1<s>3<s>4|'.
+ # 2-4 -> 3
+ '<:child-of$<b>34<i>0<i>0' . '<i>4' . '<i>3<s>3<s>3<s>1|' .
+ # 2-4 -> 4
+ '<:child-of$<b>34<i>0<i>0' . '<i>4' . '<i>4<s>4<s>3<s>1|'.
+ # 2-7 -> 1-7
+ '>:child-of$<b>35<i>0<i>0<i>0<i>0' . '<i>7' . '<i>1<i>7<s>2<s>4<s>2|'.
+ # 2-7 -> 2-4
+ '<:child-of$<b>35<i>0<i>0<i>0<i>0' . '<i>7' . '<i>2<i>4<s>5<s>4<s>3|'.
+ # 2-7 -> 4-7
+ '<:child-of$<b>35<i>0<i>0<i>0<i>0' . '<i>7' . '<i>4<i>7<s>6<s>4<s>2' .
+ ']' ,
'Check sorted relations'
);
-# 2 -> 2-4
-# >:child-of$<i>2<i>4<s>2<s>1<s>3
-# 2 -> 3
-# >:child-of$<i>3<s>2<s>4<s>2
-# 2-4 -> 2-7
-# >:child-of$<i>4<i>2<i>7<s>1<s>3<s>4
-# 2-4 -> 3
-# <:child-of$<i>4<b>0<i>3<s>3<s>3<s>1
-# 2-4 -> 4
-# <:child-of$<i>4<b>0<i>4<s>4<s>3<s>1
-# 2-7 -> 1-7
-# >:child-of$<i>7<i>1<i>7<s>2<s>4<s>2
-# 2-7 -> 2-4
-# <:child-of$<i>7<i>2<i>4<s>5<s>4<s>3
-# 2-7 -> 4-7
-# <:child-of$<i>7<i>4<i>7<s>6<s>4<s>2
-
done_testing;
-
-
__END__