Skip to content

Commit eea341f

Browse files
committed
feat: add support mutary relation
1 parent f3ecd4a commit eea341f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

treedlib/features.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from treedlib.templates import *
22
import lxml.etree as et
33

4-
def compile_relation_feature_generator(dictionaries=None, opts={}):
4+
def compile_relation_feature_generator(dictionaries=None, opts={}, is_multary=False):
55
"""
66
Given optional arguments, returns a generator function which accepts an xml root
77
and two lists of mention indexes, and will generate relation features for this relation
@@ -66,7 +66,9 @@ def compile_relation_feature_generator(dictionaries=None, opts={}):
6666
templates.append(DictionaryIntersect(SeqBetween(), d_name, d))
6767

6868
# return generator function
69-
return Compile(templates).apply_relation
69+
if is_multary:
70+
return Compile(templates).apply_multary_relation
71+
return Compile(templates).apply_relation
7072

7173
"""
7274
For calibrating the bin sizes

treedlib/templates.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,5 +428,8 @@ def apply_mention(self, root, mention_idxs, dict_sub={}, stopwords=None):
428428
def apply_relation(self, root, mention1_idxs, mention2_idxs, dict_sub={}, stopwords=None):
429429
return self.apply(root, [mention1_idxs, mention2_idxs], dict_sub=dict_sub, stopwords=stopwords)
430430

431+
def apply_multary_relation(self, root, mentions, dict_sub={}, stopwords=None):
432+
return self.apply(root, mentions, dict_sub=dict_sub, stopwords=stopwords)
433+
431434
def __repr__(self):
432435
return '\n'.join(str(op) for op in self._iterops())

0 commit comments

Comments
 (0)