Implemented eq for Msd and Properties

This commit is contained in:
Cyprian Laskowski 2021-10-12 18:09:39 +02:00
parent 6b63b9940e
commit 6ec785dc65

View File

@ -208,6 +208,13 @@ class Properties:
return 'language={language}, category={category}, lexeme features={lexeme_features}, form_features={form_features}'.\ return 'language={language}, category={category}, lexeme features={lexeme_features}, form_features={form_features}'.\
format(language=self.language, category=self.category, lexeme_features=str(self.lexeme_feature_map), form_features=str(self.form_feature_map)) format(language=self.language, category=self.category, lexeme_features=str(self.lexeme_feature_map), form_features=str(self.form_feature_map))
def __eq__(self, obj):
return isinstance(obj, Properties)\
and self.category == obj.category\
and self.lexeme_feature_map == obj.lexeme_feature_map\
and self.form_feature_map == obj.form_feature_map\
and self.language == obj.language
class Msd: class Msd:
"""JOS msd.""" """JOS msd."""
@ -219,6 +226,9 @@ class Msd:
def __str__(self): def __str__(self):
return 'code={code}, language={language}'.format(code=self.code, language=self.language) return 'code={code}, language={language}'.format(code=self.code, language=self.language)
def __eq__(self, obj):
return isinstance(obj, Msd) and self.code == obj.code and self.language == obj.language
class Converter: class Converter:
"""Converter between Msd and Properties objects.""" """Converter between Msd and Properties objects."""