Skip to content

Commit

Permalink
Add tests for fuzzy matching
Browse files Browse the repository at this point in the history
  • Loading branch information
b-j-mills committed Oct 31, 2023
1 parent 1c3286d commit 8fb6ff5
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ Association Malienne pour la Solidarité et le Développement,,,,,,,,
Care Best Initiative,,,,,,,,
AECID,,,,,,,,
Norwegian Project Office / Rural Rehabilitation Association for Afghanistan,,,,,,,,
Social and Humanitarian Assistance Organization,,,,,,,,
Social and Humanitarian Assistance Organization,,,,,,,,
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ HR.info ID,Preferred Term,Scope,Date Added (dd/mm/yyyy),Date updated (dd/mm/yyyy
444,Private sector,"Includes private sector organizations such as corporate charity arms or foundations, for-profit recruitment firms and consultancies",16/03/2017,,,,
445,Red Cross / Red Crescent,"Includes IFRC, ICRC and national Red Cross/Crescent societies",16/03/2017,,276,Red Cross/Red Crescent Movement,Exact Match
446,Religious,Includes faith-based organizations and organizations with affiliations to religious bodies,16/03/2017,,,,
447,United Nations,"Includes all UN agencies, funds and programmes",16/03/2017,,272,International Organization,Broader
447,United Nations,"Includes all UN agencies, funds and programmes",16/03/2017,,272,International Organization,Broader
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ HRinfo ID,Preferred Term,Preferred Term (fr),ACRONYM,Group Type,Homepage,Date Cr
2,Early Recovery,Relèvement rapide,ERY,Cluster,http://earlyrecovery.global/,03/16/2017,4/4/2018,Added French name
5,Emergency Telecommunications,Télécommunications d'urgence,TEL,Cluster,https://www.etcluster.org/,03/16/2017,4/4/2018,Added French name
5404,Gender Based Violence,Violences basées sur le genre,PRO-GBV,Area of Responsibility (Sub-cluster),http://gbvaor.net/,03/16/2017,4/5/2018,Updated French name based feedback from OCHA-FIS
5405,"Housing, Land and Property","Logement, terre, et biens",PRO-HLP,Area of Responsibility (Sub-cluster),http://www.globalprotectioncluster.org/en/areas-of-responsibility/housing-land-and-property.html,03/16/2017,4/4/2018,Added French name from 2012 Côte d'Ivoire workshop report
5405,"Housing, Land and Property","Logement, terre, et biens",PRO-HLP,Area of Responsibility (Sub-cluster),http://www.globalprotectioncluster.org/en/areas-of-responsibility/housing-land-and-property.html,03/16/2017,4/4/2018,Added French name from 2012 Côte d'Ivoire workshop report
73 changes: 73 additions & 0 deletions tests/test_mappings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
from hapi.pipelines.utilities.mappings import get_code_from_name


def test_get_code_from_name():
sector_lookup = {
"Emergency Shelter and NFI": "SHL",
"Camp Coordination / Management": "CCM",
"Mine Action": "PRO - MIN",
"Food Security": "FSC",
"Water Sanitation Hygiene": "WSH",
"Logistics": "LOG",
"Child Protection": "PRO - CPN",
"Protection": "PRO",
"Education": "EDU",
"Nutrition": "NUT",
"Health": "HEA",
"Early Recovery": "ERY",
"Emergency Telecommunications": "TEL",
"Gender Based Violence": "PRO - GBV",
"Housing, Land and Property": "PRO - HLP",
}
sector_map = {
"abris": "SHL",
"cccm": "CCM",
"coordination": "CCM",
"education": "EDU",
"eha": "WSH",
"erl": "ERY",
"nutrition": "NUT",
"operatioanl presence: water, sanitation & hygiene": "WSH",
"operational presence: education in emergencies": "EDU",
"operational presence: emergency shelter & non-food items": "SHL",
"operational presence: food security & agriculture": "FSC",
"operational presence: health": "HEA",
"operational presence: nutrition": "NUT",
"operational presence: protection": "PRO",
"protection": "PRO",
"sa": "FSC",
"sante": "HEA",
"wash": "WSH",
}

org_type_lookup = {
"Academic / Research": "431",
"Donor": "433",
"Embassy": "434",
"Government": "435",
"International NGO": "437",
"International Organization": "438",
"Media": "439",
"Military": "440",
"National NGO": "441",
"Other": "443",
"Private sector": "444",
"Red Cross / Red Crescent": "445",
"Religious": "446",
"United Nations": "447",
}
org_type_map = {
"agence un": "447",
"govt": "435",
"ingo": "437",
"mouv. cr": "445",
"nngo": "441",
"ong int": "437",
"ong nat": "441",
"un agency": "447",
}
assert get_code_from_name("NATIONAL_NGO", org_type_lookup, org_type_map) == "441"
assert get_code_from_name("COOPÉRATION_INTERNATIONALE", org_type_lookup, org_type_map) is None
assert get_code_from_name("LOGISTIQUE", sector_lookup, sector_map) == "LOG"
assert get_code_from_name("CCCM", sector_lookup, sector_map) == "CCM"
assert get_code_from_name("Santé", sector_lookup, sector_map) == "HEA"

0 comments on commit 8fb6ff5

Please sign in to comment.