Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(AreaMatcher): changed osm to optional #106

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions sloyka/src/utils/data_processing/area_matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,20 @@ def match_group_to_area(self, group_name, df_areas):
max_partial_ratio = partial_ratio
max_token_sort_ratio = token_sort_ratio
best_match = row["area_name"]
admin_level = row["admin_level"]

return best_match, admin_level
return best_match

def run(self, df, place_name):
def run(self, df, from_osm: bool = True, areas = None, place_name: str = None):
df['processed_group_name'] = df.group_name.map(lambda x: self.preprocess_group_name(x))
df_areas = self.get_osm_areas(place_name)
print('processed group names')
if from_osm:
df_areas = self.get_osm_areas(place_name)
else:
df_areas = areas
df_areas = self.preprocess_area_names(df_areas)
df[["best_match", "admin_level"]] = df.apply(
print('processed area names')
df["best_match"] = df.apply(
lambda row: pd.Series(self.match_group_to_area(row["processed_group_name"], df_areas)), axis=1
)
print('found matches')
return df
Loading