in src/morphological_filtering.py [0:0]
def _matches_gender(self, sentence: str, gender: str) -> bool:
"""
Check whether a sentence matches the indicated gender. We consider a sentence to match the gender if *none* of
the words in the sentence correspond to a non-indicated gender *and* there is at least one word with the
indicated gender.
:param sentence: String to classify by morphological gender.
:param gender: Indicated gender that we expect the sentence to match.
:return: True if the gender matches the indicated gender, else False.
"""
gender_per_word = self._get_gender_per_word(sentence)
has_matching_gender = False
for current_gender in gender_per_word:
if current_gender in self.OTHER_GENDER_LABELS[gender]:
return False
if current_gender in self.MATCH_GENDER_LABELS[gender]:
has_matching_gender = True
return has_matching_gender