def test_match_lexeme_form_to_template_form_missing_statement(): lexeme_form = {'grammaticalFeatures': ['Q1']} template_form = { 'grammatical_features_item_ids': ['Q1'], 'statements': {'P31': [make_statement('P31', 'Q4115189')]}, } assert matching.match_lexeme_form_to_template_form(False, lexeme_form, template_form) == 0
def test_match_lexeme_form_to_template_form_conflicting_statement(): lexeme_form = { 'grammaticalFeatures': ['Q1'], 'claims': {'P5185': [make_statement('P5185', 'Q4115189'), make_statement('P5185', 'Q13406268')]}, } template_form = { 'grammatical_features_item_ids': ['Q1'], 'statements': {'P5185': [make_statement('P5185', 'Q4115189')]}, } assert matching.match_lexeme_form_to_template_form(False, lexeme_form, template_form) == 0
def test_match_lexeme_form_to_template_form_optional_feature_present(): lexeme_form = { 'grammaticalFeatures': ['Q1', 'Q2'], } template_form = { 'grammatical_features_item_ids': ['Q1', 'Q2'], 'grammatical_features_item_ids_optional': set(['Q2']) } assert matching.match_lexeme_form_to_template_form(False, lexeme_form, template_form) == 2
def test_match_lexeme_form_to_template_form_counts_grammatical_features_and_statements(): lexeme_form = { 'grammaticalFeatures': ['Q1', 'Q2', 'Q3', 'Q4'], 'claims': { 'P31': [make_statement('P31', 'Q4115189'), make_statement('P31', 'Q13406268')], 'P5185': [make_statement('P5185', 'Q4115189')], }, } template_form = { 'grammatical_features_item_ids': ['Q1', 'Q2'], 'statements': { 'P31': [make_statement('P31', 'Q4115189')], 'P5185': [make_statement('P5185', 'Q4115189')], }, } assert matching.match_lexeme_form_to_template_form(False, lexeme_form, template_form) == 4
def test_match_lexeme_form_to_template_form_missing_grammatical_feature(): lexeme_form = {'grammaticalFeatures': ['Q1', 'Q3']} template_form = {'grammatical_features_item_ids': ['Q1', 'Q2', 'Q3']} assert matching.match_lexeme_form_to_template_form(False, lexeme_form, template_form) == 0
def test_match_lexeme_form_to_template_form_optional_features_undefined(): lexeme_form = {'grammaticalFeatures': ['Q1']} template_form = {'grammatical_features_item_ids': ['Q1']} assert matching.match_lexeme_form_to_template_form(False, lexeme_form, template_form) == 1