Skip to content

Fuzzy match entity names (primarily persons and companies) across databases

Notifications You must be signed in to change notification settings

simonschoe/fuzzy-name-match

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fuzzy Name Matcher

Overview

Fuzzy Name Matcher promotes the merging of two datasets in the absence of unique keys using entity names. Under the hood, it leverages the thefuzz Python package for fuzzy string matching.

Usage

  1. Upload the two datasets that are supposed to be merged (in .csv or .dta format). primary file and secondary file denote the left- and right-hand-side dataset of the merge. A left-join is performed, i.e., values in the secondary file are attached to rows in the primary file. In case you .csv format, please ensure that the files are encoded in utf-8.
  2. Specify the relevant merge columns:
  • ID column: Name of the column that contains the unique entity ID.
  • Name column: Name of the column that contains the entity name (e.g., firm or person name).
  • Year column (optional): Name of the column that contains year information.
  • Quarter column (optional): Name of the column that contains quarter information.

    The Year column and Quarter column fields might be relevant for panel datasets where entity names can change over time or different entities can exhibit identical names at different points in time.
  1. Choose entity type (either firm names or person names). Based on the entity type different string normalization operations are performed to preprocess the names prior to matching. Select Firm (US) or Firm (Int) if the sample is U.S.-based only or international to accomodate different sets of legal forms.
  2. Start merge by clicking on "Start Matching" and download the results. Note: Klick on "Stop Program" to interrupt matching, e.g., if the runtime exceeds budget.

Docker Deployment

  1. Uncomment corresponding app.launch() command at the end of main.py

  2. Build docker image called fnm from working repository

docker build --tag fnm .
docker images
  1. Run docker container fnm in detached mode from latest image (fnm:latest) and expose container port (7878) to host post (7000)
docker run -d -it --name fnm -p 7000:7878 fnm:latest
docker ps -a
  1. Check for successful start-up. The app should be available via http://localhost:7000/. Optionally, check container contents.
docker logs -f fnm
docker exec fnm ls /app/
  1. Stop and remove container
docker stop fnm; docker rm fnm

Output

The resulting merge file has the following structure:

ID column
(pf)
Name column
(pf)
Name normalized
(pf)
Name normalized of match
(sf)
Match score
(1-100)
ID column
(sf)
Name column
(sf)
6094 MEDICIS PHARMACEUTICAL CORP medicispharmaceutical medicispharmaceutcp 90 21186 MEDICIS PHARMACEUT CP -CL A

Matching scores indicate string similarity with higher scores reflecting more similar strings. Values above 90-95 commonly denote reasonably accurate matches.

About

Fuzzy match entity names (primarily persons and companies) across databases

Topics

Resources

Stars

Watchers

Forks