Replace deprecated MultiTerm add() method from Talismane parser
Change-Id: Ifd3c024e46049d7373a30edc8632289e616391a2
diff --git a/lib/KorAP/XML/Annotation/Talismane/Dependency.pm b/lib/KorAP/XML/Annotation/Talismane/Dependency.pm
index efd301e..1b98809 100644
--- a/lib/KorAP/XML/Annotation/Talismane/Dependency.pm
+++ b/lib/KorAP/XML/Annotation/Talismane/Dependency.pm
@@ -23,6 +23,8 @@
my $rel = $content->{rel};
$rel = [$rel] unless ref $rel eq 'ARRAY';
+ my $mt;
+
# Iterate over relations
foreach (@$rel) {
my $label = $_->{-label};
@@ -36,34 +38,31 @@
# Relation is term-to-term with a found target!
if ($target) {
- $mtt->add(
- term => '>:talismane/d:' . $label,
- pti => 32, # term-to-term relation
- payload =>
- '<i>' . $target->get_pos # . # right part token position
+ $mt = $mtt->add_by_term('>:talismane/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);
+ $mt = $stream->pos($target->get_pos)
+ ->add_by_term('<:talismane/d:' . $label);
- $target_mtt->add(
- term => '<:talismane/d:' . $label,
- pti => 32, # term-to-term relation
- payload =>
- '<i>' . $source->get_pos # . # left part token position
+ $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!
elsif ($target = $tokens->span($from, $to)) {
- $mtt->add(
- term => '>:talismane/d:' . $label,
- pti => 33, # term-to-element relation
- payload =>
- '<i>' . $target->get_o_start . # end position
+ $mt = $mtt->add_by_term('>:talismane/d:' . $label);
+ $mt->set_pti(33); # term-to-element relation
+ $mt->set_payload(
+ '<i>' . $target->get_o_start . # end position
'<i>' . $target->get_o_end . # end position
'<i>' . $target->get_p_start . # right part start position
'<i>' . $target->get_p_end # . # right part end position
@@ -71,18 +70,16 @@
# '<s>0' # . $target_span->tui # right part tui
);
- my $target_mtt = $stream->pos($target->get_p_start);
- $target_mtt->add(
- term => '<:talismane/d:' . $label,
- pti => 34, # element-to-term relation
- payload =>
- '<i>' . $target->get_o_start . # end position
+ $mt = $stream->pos($target->get_p_start)
+ ->add_by_term('<:talismane/d:' . $label);
+ $mt->set_pti(34); # element-to-term relation
+ $mt->set_payload(
+ '<i>' . $target->get_o_start . # end position
'<i>' . $target->get_o_end . # end position
'<i>' . $target->get_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/Talismane/Morpho.pm b/lib/KorAP/XML/Annotation/Talismane/Morpho.pm
index bd5c30b..505706e 100644
--- a/lib/KorAP/XML/Annotation/Talismane/Morpho.pm
+++ b/lib/KorAP/XML/Annotation/Talismane/Morpho.pm
@@ -20,7 +20,7 @@
# pos tag
if (($f->{-name} eq 'pos') &&
($found = $f->{'#text'})) {
- $mtt->add(term => 'talismane/p:' . $found);
+ $mtt->add_by_term('talismane/p:' . $found);
}
# ana tag
@@ -28,7 +28,7 @@
($found = $f->{'#text'})) {
my ($pos, $msd) = split(/ /, $found);
if ($msd) {
- $mtt->add(term => 'talismane/p:' . $pos);
+ $mtt->add_by_term('talismane/p:' . $pos);
}
else {
$msd = $pos;
@@ -38,7 +38,7 @@
foreach (split '\|', $msd) {
my ($x, $y) = split "=", $_;
# case, tense, number, mood, person, degree, gender
- $mtt->add(term => 'talismane/m:' . $x . ($y ? ':' . $y : ''));
+ $mtt->add_by_term('talismane/m:' . $x . ($y ? ':' . $y : ''));
};
}
@@ -47,7 +47,7 @@
&& ($found = $f->{'#text'})
&& $found ne '--' && $found ne '_') {
# b($found)->decode('latin-1')->encode->to_string
- $mtt->add(term => 'talismane/l:' . $found);
+ $mtt->add_by_term('talismane/l:' . $found);
};
};
}) or return;