DeNederlandscheBank / name_matching

Other
128 stars 43 forks source link

Code example is not working (here's a working one) #10

Closed guy4261 closed 1 year ago

guy4261 commented 1 year ago

Example in your pypi page is wrong - various errors occur as your underlying API has changed. This works (and I added my brothers' names as example data).

#!/usr/bin/env python
import pandas as pd
from name_matching.name_matcher import NameMatcher

# initialise the name matcher
matcher = NameMatcher(
    number_of_matches=3, legal_suffixes=True, common_words=False, top_n=50, verbose=True
)

# adjust the distance metrics to use
matcher.set_distance_metrics(["bag", "typo", "refined_soundex"])

# load the data to which the names should be matched
df_gleif = pd.DataFrame({"name": ["guy", "ron", "chen"]})
matcher.load_and_process_master_data("name", df_gleif, transform=True)

unknown_counterparties = pd.DataFrame({"name": ["guy", "ron", "chen"]})
# perform the name matching on the data you want matched
matches = matcher.match_names(
    to_be_matched=unknown_counterparties, column_matching="name"
)

print(matches)
guy4261 commented 1 year ago

https://pypi.org/project/name-matching/

mnijhuis-dnb commented 1 year ago

Thanks a lot for pointing it out and giving a nice working example 😄 The example in the readme and on the PyPi page should now work