Skip to content

Commit

Permalink
feat: Allow matching after unable to decide and manual check.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpriskorn committed Jul 14, 2023
1 parent 1b3a79a commit db51c2a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/models/enrich_hiking_trails.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __lookup_in_waymarked_trails__(trail_item: TrailItem) -> None:
f"Try looking at {trail_item.waymarked_hiking_trails_search_url} "
f"and see if any fit with {trail_item.item.get_entity_url()}"
)
# TODO help the user match again
trail_item.try_matching_again()
else:
trail_item.osm_id_source = OsmIdSource.QUESTIONNAIRE
trail_item.enrich_wikidata()
Expand Down
17 changes: 14 additions & 3 deletions src/models/trail_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from urllib.parse import quote

import pydash
import questionary
import requests
from dateutil.parser import parse # type: ignore
from dateutil.tz import tzutc # type: ignore
Expand Down Expand Up @@ -197,9 +198,8 @@ def __prepare_choices__(self):
)

def __ask_question__(self) -> QuestionaryReturn:
"""This presents a choice and returns"""
# present the result to the user to choose from
import questionary

if not self.item:
raise NoItemError()
return_ = questionary.select(
Expand Down Expand Up @@ -245,7 +245,6 @@ def fetch_and_lookup_from_waymarked_trails_and_present_choice_to_user(self):
self.__get_item_details__()
self.__lookup_label_on_waymarked_trails_and_ask_user_to_choose_a_match__()

# @validate_arguments()
def enrich_wikidata(self):
"""We enrich Wikidata based on the choice of the user"""
if self.osm_id_source == OsmIdSource.QUESTIONNAIRE:
Expand Down Expand Up @@ -522,3 +521,15 @@ def __remove_not_found_in_osm_claim__(self):
self.item.claims.remove(Property.OSM_RELATION_ID.value)
except KeyError:
logger.debug("No NOT_FOUND_IN found on this item to remove")

def try_matching_again(self):
if self.questionary_return.could_not_decide is True:
result = questionary.select(
"Do you want to match again after manually ",
choices=[
Choice(title="Yes", value=True),
Choice(title="No", value=False),
],
).ask()
if result:
self.questionary_return = self.__ask_question__()

0 comments on commit db51c2a

Please sign in to comment.