Fix opens_at keeping the raw separator on non-English locales - #20
Open
Benjapieres wants to merge 1 commit into
Open
Fix opens_at keeping the raw separator on non-English locales#20Benjapieres wants to merge 1 commit into
Benjapieres wants to merge 1 commit into
Conversation
extract_place() splits the opening-hours string on U+22C5 DOT OPERATOR
to drop the leading open/closed status, but Google serves U+00B7 MIDDLE
DOT in at least some locales. The two render almost identically, so the
split silently never matches, falls through to the else branch and
stores the whole raw string.
Scraping "cafeterias en Palermo Buenos Aires" currently yields:
' · Cierra a las 8p.m.'
'Abierto · Cierra a las 8p.m.'
instead of the intended 'Cierra a las 8p.m.'. The field is inconsistent
between rows depending on whether the status prefix was present.
parse_opens_at() now accepts either separator and strips the result.
U+22C5 is tried first, so locales that already worked are unaffected.
The two duplicated extraction branches collapse into one, since the
only difference between them was which XPath produced the raw string.
Verified against a live scrape:
'Abre a las 7p.m.' <- Winston Club
'Abre a las 12p.m.' <- Estilo Campo Restaurante
'Abre a las 8p.m.' <- Brukbar Buenos Aires
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
extract_place()splits the opening-hours string on⋅(U+22C5 DOT OPERATOR) to drop the leading open/closed status. Google serves·(U+00B7 MIDDLE DOT) in at least some locales. The two characters render almost identically but are not equal, so the split never matches, falls through to theelsebranch, and stores the whole raw string.Scraping
"cafeterias en Palermo Buenos Aires"on currentmaingives:instead of the intended
'Cierra a las 8p.m.'. Note the field is also inconsistent row to row, depending on whether the status prefix happened to be present — so it can't be parsed downstream either.Confirmed by codepoint rather than by eye:
Fix
parse_opens_at()accepts either separator and strips the result. U+22C5 is tried first, so locales that already worked keep their exact current behavior. Both characters are spelled as\uescapes because they are indistinguishable in source.The two duplicated extraction branches collapse into one — the only difference between them was which XPath produced the raw string, so
orcovers the fallback.Verification
Live scrape after the fix:
Parser cases, including the old separator and no-separator inputs:
' · Cierra a las 8p.m.''Cierra a las 8p.m.''Abierto · Cierra a las 8p.m.''Cierra a las 8p.m.''Open ⋅ Closes 8 PM'(U+22C5)'Closes 8PM''Abierto 24 horas'(sin separador)'Abierto 24 horas''Cerrado''Cerrado'Independent of #19 — different function, no overlap.
🤖 Generated with Claude Code