Skip to content

Better cleaning#8

Open
cquest wants to merge 29 commits intomainfrom
better_cleaning
Open

Better cleaning#8
cquest wants to merge 29 commits intomainfrom
better_cleaning

Conversation

@cquest
Copy link
Member

@cquest cquest commented Feb 14, 2018

More variations for BP/CS/CIDEX/TSA like:
B.P 41
TSA N°41

Cleans phone/fax numbers too...


def clean_query(q):
q = re.sub(r'([\d]{5})', r' \1 ', q, flags=re.IGNORECASE)
q = re.sub(r'(^| )(boite postale|b\.?p\.?|cs|tsa|cidex) *(n(o|°|) *|)[\d]+ *', r'\1', q, flags=re.IGNORECASE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regex is quite slow, I'm not sure we wanna go that far in cleaning.
Have you had a look on perfs? :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regexp are not that slow (I measured 3µs for this one)... and it is called just once to clean the query

def fold_ordinal(s):
"""3bis => 3b."""
if s[0].isdigit() and not s.isdigit():
if s is not None and s !='' and s[0].isdigit() and not s.isdigit():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this needs to be fixed properly beforehand. I'll have a look.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No way to reproduce the issue, neither from the shell, the pyshell or the http API.

Can you be a bit more specific on how you get the issue here? A simple way to reproduce from shell or pyshell would help :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs either a reproducable test case (so we can understand) either removal :)

@jdesboeufs jdesboeufs mentioned this pull request Nov 1, 2025
jdesboeufs added a commit that referenced this pull request Nov 1, 2025
- Ajout de 22 nouveaux types de voies : aérodrome, déviation, digue,
  embranchement, jardin, jetée, passerelle, placette, parvis, quartier,
  ruelle, terrasse, tunnel, viaduc, villa, etc.
- Amélioration de 22 patterns existants pour mieux reconnaître les
  abréviations courantes : bld/blvd, ch/chem, pass, dom, res, prom,
  ham, fbg, carr, trav, espl, etc.
- Ajout de tests pour valider la reconnaissance des numéros de rue
  avec ces nouveaux types et abréviations

Source: PR #8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants