From 6d24bdadec64e8f4283d8a29656885d1ab22affb Mon Sep 17 00:00:00 2001 From: Ewa Muszynska Date: Thu, 9 Aug 2018 15:14:51 +0100 Subject: [PATCH] Allow the use of 'tensed' as underspecification in EventSortinfo. --- pydmrs/components.py | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/pydmrs/components.py b/pydmrs/components.py index ea0117f..d5d7440 100644 --- a/pydmrs/components.py +++ b/pydmrs/components.py @@ -752,15 +752,17 @@ def is_more_specific(self, other): if self.cvarsort != other.cvarsort: return False for key, value in other.iter_specified(): - if not self.is_specified(key) or value != self[key]: - return False - result = False - for key, value in self.iter_specified(): - if not other.is_specified(key): - result = True - elif value != other[key]: + if not self.is_specified(key): return False - return result + elif value != self[key]: + if key == 'tense' and value == 'tensed' and self[key] != 'untensed': + continue + else: + return False + only_this_specified = set(other.iter_specified()).difference(other.iter_specified()) + if not only_this_specified: + return False + return True def is_less_specific(self, other): """ @@ -774,15 +776,17 @@ def is_less_specific(self, other): if self.cvarsort != other.cvarsort: return False for key, value in self.iter_specified(): - if not other.is_specified(key) or value != other[key]: - return False - result = False - for key, value in other.iter_specified(): - if not self.is_specified(key): - result = True - elif value != self[key]: + if not other.is_specified(key): return False - return result + elif value != other[key]: + if key == 'tense' and value == 'tensed' and other[key] != 'untensed': + continue + else: + return False + only_other_specified = set(other.iter_specified()).difference(self.iter_specified()) + if not only_other_specified: + return False + return True class EventSortinfo(Sortinfo):