def test_match_operator_at_start_of_name(): osm_tags = { 'highway': 'services', 'landuse': 'commercial', 'name': 'Welcome Break Gordano Services', 'operator': 'Welcome Break', } wd_names = {'Gordano services': [('label', 'en')]} expect = {'name': [('good', 'Gordano services', [('label', 'en')])]} assert match.check_for_match(osm_tags, wd_names) == expect osm_tags = { 'name': 'Citizens Bank (Roslindale)', 'operator': 'Citizens Bank', } wd_names = {'Roslindale Theatre': [('label', 'en')]} assert not match.check_for_match(osm_tags, wd_names, ['theatre'])
def test_name_match_numbers(): assert match.name_match('Manhattan Community Board 1', 'Manhattan Community Board 1') assert not match.name_match('Manhattan Community Board 11', 'Manhattan Community Board 1') assert not match.name_match('Manhattan Community Board 1', 'Manhattan Community Board 11') assert not match.name_containing_initials('Manhattan Community Board 1', 'Manhattan Community Board 11') osm_tags = { 'name': 'Manhattan Community Board 11', } wikidata_names = { '1-й общественный совет': [('label', 'ru')], 'Manhattan Community Board 1': [('label', 'en'), ('sitelink', 'enwiki'), ('extract', 'enwiki')], } assert not match.check_for_match(osm_tags, wikidata_names)
def test_check_for_match(): assert match.check_for_match({}, []) == {} osm_tags = {'addr:city': 'Rome', 'name': 'test', 'alt_name': 'test'} wd_names = {'test': [('label', 'en')]} expect = { 'alt_name': [('good', 'test', [('label', 'en')])], 'name': [('good', 'test', [('label', 'en')])], } assert match.check_for_match(osm_tags, wd_names) == expect osm_tags = {'name': 'Burgers and Cupcakes'} wd_names = { 'Baryshnikov Arts Center': [('label', 'en')], 'BAC': [('extract', 'en')], } assert match.check_for_match(osm_tags, wd_names) == {} del wd_names['Baryshnikov Arts Center'] assert match.check_for_match(osm_tags, wd_names) osm_tags = {'name': 'National Museum of Mathematics (MoMath)'} wd_names = { 'National Museum of Mathematics': [('label', 'en')], 'Momath': [('alias', 'en')], 'Museum of Mathematics': [('alias', 'en')], } expect = { 'name': [('prefix', 'National Museum of Mathematics', [('label', 'en')])], } assert match.check_for_match(osm_tags, wd_names) == expect osm_tags = { 'building:levels': '6', 'name': 'Lombard Buildings', 'building': 'yes', } wd_names = {'Lombard Building': [('label', 'en'), ('sitelink', 'enwiki'), ('extract', 'enwiki')]} expect = {'name': [('good', 'Lombard Building', [('label', 'en'), ('sitelink', 'enwiki'), ('extract', 'enwiki')])]} endings = ['building'] assert match.check_for_match(osm_tags, wd_names, endings=endings) == expect osm_tags = { 'name': 'Westland London', 'shop': 'furniture', 'building': 'yes', 'addr:street': 'Leonard Street', 'addr:postcode': 'EC2A 4QX', 'addr:housename': "St. Michael's Church", } wd_names = {'Church Of St Michael': [('label', 'en')]} expect = {'addr:housename': [('both_trimmed', 'Church Of St Michael', [('label', 'en')])]} endings = ['church', 'church of'] assert match.check_for_match(osm_tags, wd_names, endings=endings) == expect osm_tags = { 'denomination': 'roman_catholic', 'name': 'Saint Vitus Catholic Church', 'amenity': 'place_of_worship', 'religion': 'christian', } wd_names = {"St. Vitus's Church, Cleveland": [('label', 'en')]} endings = ['church', 'church of', 'catholic church', 'rc church'] expect = {'name': [('both_trimmed', "St. Vitus's Church, Cleveland", [('label', 'en')])]} place_names = {'Cleveland', 'Cuyahoga County', 'Ohio'} assert match.check_for_match(osm_tags, wd_names, place_names=place_names, endings=endings) == expect wd_names = {'Samson And Lion Public House': [('label', 'en')]} osm_tags = { 'addr:city': 'Birmingham', 'addr:housenumber': '42', 'addr:postcode': 'B9 5QF', 'addr:street': 'Yardley Green Road', 'amenity': 'place_of_worship', 'building': 'yes', 'heritage': '2', 'heritage:operator': 'Historic England', 'listed_status': 'Grade II', 'name': 'Masjid Noor-Us-Sunnah', 'previous_name': 'Samson & Lion', 'previous_use': 'pub', 'religion': 'muslim', } endings = ['public house'] expect = {'previous_name': [('wikidata_trimmed', 'Samson And Lion Public House', [('label', 'en')])]} assert match.check_for_match(osm_tags, wd_names, endings=endings) == expect osm_tags = { 'area': 'yes', 'highway': 'services', 'name': 'Stop24 Folkestone Services', 'operator': 'Stop24' } wd_names = {'Folkestone services': [('sitelink', 'enwiki')], 'Stop 24 services': [('label', 'en'), ('extract', 'enwiki')]} expect = {'operator': [('wikidata_trimmed', 'Stop 24 services', [('label', 'en'), ('extract', 'enwiki')])], 'name': [('good', 'Folkestone services', [('sitelink', 'enwiki')]), ('good', 'Stop 24 services', [('label', 'en'), ('extract', 'enwiki')])]} endings = {'services'} place_names = {'Folkestone', 'Kent'} assert match.check_for_match(osm_tags, wd_names, place_names=place_names, endings=endings) == expect