Replace deprecated MultiTerm add() method from XIP parser
Change-Id: I09712c39518feaa7eb613d9cb1e7e6901a2a75a6
diff --git a/lib/KorAP/XML/Annotation/XIP/Constituency.pm b/lib/KorAP/XML/Annotation/XIP/Constituency.pm
index 1637279..e146d93 100644
--- a/lib/KorAP/XML/Annotation/XIP/Constituency.pm
+++ b/lib/KorAP/XML/Annotation/XIP/Constituency.pm
@@ -36,11 +36,14 @@
$rel = [$rel] unless ref $rel eq 'ARRAY';
+ my $target;
+
# Iterate over all relations
foreach (@$rel) {
+
next if $_->{-label} ne 'dominates';
- my $target = $_->{-target};
+ $target = $_->{-target};
if (!$target && $_->{-uri} &&
$_->{-uri} =~ $URI_RE) {
$target = $1;
@@ -89,18 +92,14 @@
};
# $type is now NPA, NP, NUM ...
- my %term = (
- term => '<>:xip/c:' . $type,
- o_start => $span->get_o_start,
- o_end => $span->get_o_end,
- p_end => $span->get_p_end,
- pti => 64
- );
+ my $mt = $mtt->add_by_term('<>:xip/c:' . $type);
+ $mt->set_o_start($span->get_o_start);
+ $mt->set_o_end($span->get_o_end);
+ $mt->set_p_end($span->get_p_end);
+ $mt->set_pti(64);
# Only add level payload if node != root
- $term{payload} ='<b>' . ($level // 0);
-
- $mtt->add(%term);
+ $mt->set_payload('<b>' . ($level // 0));
# my $this = __SUB__
my $this = $add_const;
diff --git a/lib/KorAP/XML/Annotation/XIP/Dependency.pm b/lib/KorAP/XML/Annotation/XIP/Dependency.pm
index 2efd2b1..2323e00 100644
--- a/lib/KorAP/XML/Annotation/XIP/Dependency.pm
+++ b/lib/KorAP/XML/Annotation/XIP/Dependency.pm
@@ -20,49 +20,45 @@
encoding => 'xip',
cb => sub {
my ($stream, $token, $tokens) = @_;
- my $mtt = $stream->pos($token->pos);
+ my $mtt = $stream->pos($token->get_pos);
+ my $mt;
- my $content = $token->hash;
+ my $content = $token->get_hash;
my $rel = $content->{rel};
$rel = [$rel] unless ref $rel eq 'ARRAY';
foreach (@$rel) {
- my $label = $_->{-label};
+ my $label = $_->{-label};
- # Relation is "unary" - meaning relation to itself
- if ($_->{-type} && $_->{-type} eq 'unary') {
- $mtt->add(
- term => '>:xip/d:' . $label,
- payload => '<i>' . $token->pos
- );
- $mtt->add(
- term => '<:xip/d:' . $label,
- payload => '<i>' . $token->pos
- );
- }
- else {
+ # Relation is "unary" - meaning relation to itself
+ if ($_->{-type} && $_->{-type} eq 'unary') {
+ $mt = $mtt->add_by_term('>:xip/d:' . $label);
+ $mt->set_payload('<i>' . $token->get_pos);
- my $from = $_->{span}->{-from};
- my $to = $_->{span}->{-to};
+ };
+ $mt = $mtt->add_by_term('<:xip/d:' . $label);
+ $mt->set_payload('<i>' . $token->get_pos);
+ }
+ else {
- my $rel_token = $tokens->token($from, $to) or next;
+ my $from = $_->{span}->{-from};
+ my $to = $_->{span}->{-to};
- # die $token->pos . ' -' . $label . '-> ' . $rel_token->pos;
- $mtt->add(
- term => '>:xip/d:' . $label,
- payload => '<i>' . $rel_token->pos
- );
+ my $rel_token = $tokens->token($from, $to) or next;
- $stream->pos($rel_token->pos)->add(
- term => '<:xip/d:' . $label,
- payload => '<i>' . $token->pos
- );
- };
+ # die $token->pos . ' -' . $label . '-> ' . $rel_token->pos;
+ $mt = $mtt->add_by_term('>:xip/d:' . $label);
+ $mt->set_payload('<i>' . $rel_token->get_pos);
+ );
-# print $label,"\n";
- };
- }) or return;
+ $mt = $stream->pos($rel_token->get_pos)
+ ->add_by_term('<:xip/d:' . $label);
+ $mt->set_payload('<i>' . $token->get_pos);
+
+ # print $label,"\n";
+ }
+ ) or return;
return 1;
};
diff --git a/lib/KorAP/XML/Annotation/XIP/Morpho.pm b/lib/KorAP/XML/Annotation/XIP/Morpho.pm
index 012207d..a12aa91 100644
--- a/lib/KorAP/XML/Annotation/XIP/Morpho.pm
+++ b/lib/KorAP/XML/Annotation/XIP/Morpho.pm
@@ -21,9 +21,7 @@
# pos
if (($_->{-name} eq 'pos') &&
($found = $_->{'#text'})) {
- $mtt->add(
- term => 'xip/p:' . $found
- );
+ $mtt->add_by_term('xip/p:' . $found);
$capital = 1 if $found eq 'NOUN';
}
@@ -35,9 +33,9 @@
($found = $_->{'#text'})) {
# Verb delimiter (aus=druecken)
- $mtt->add(term => 'xip/l:' . $found);
+ $mtt->add_by_term('xip/l:' . $found);
if ($found =~ tr/=//d) {
- $mtt->add(term => 'xip/l:' . $found);
+ $mtt->add_by_term('xip/l:' . $found);
};
# Composites
@@ -49,7 +47,7 @@
foreach (@token) {
$full .= $_;
$_ =~ s{/\w+$}{};
- $mtt->add(term => 'xip/l:#' . $_);
+ $mtt->add_by_term('xip/l:#' . $_);
};
};
};
@@ -59,7 +57,7 @@
};
sub layer_info {
- ['xip/l=tokens', 'xip/p=tokens']
+ ['xip/l=tokens', 'xip/p=tokens']
};
diff --git a/lib/KorAP/XML/Annotation/XIP/Sentences.pm b/lib/KorAP/XML/Annotation/XIP/Sentences.pm
index 03cb585..cc1474c 100644
--- a/lib/KorAP/XML/Annotation/XIP/Sentences.pm
+++ b/lib/KorAP/XML/Annotation/XIP/Sentences.pm
@@ -13,15 +13,13 @@
cb => sub {
my ($stream, $span) = @_;
- my $mtt = $stream->pos($span->get_p_start);
- $mtt->add(
- term => '<>:xip/s:s',
- o_start => $span->get_o_start,
- o_end => $span->get_o_end,
- p_end => $span->get_p_end,
- pti => 64,
- payload => '<b>0' # Could be 2 as well for t/p/s
- );
+ my $mt = $stream->pos($span->get_p_start)
+ ->add_by_term('<>:xip/s:s');
+ $mt->set_o_start($span->get_o_start);
+ $mt->set_o_end($span->get_o_end);
+ $mt->set_p_end($span->get_p_end);
+ $mt->set_pti(64);
+ $mt->set_payload('<b>0'); # Could be 2 as well for t/p/s
$i++;
}
) or return;