-
Notifications
You must be signed in to change notification settings - Fork 5
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
Better cleaning #8
base: master
Are you sure you want to change the base?
Conversation
addok_france/utils.py
Outdated
@@ -50,14 +50,17 @@ | |||
|
|||
|
|||
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) |
There was a problem hiding this comment.
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? :)
There was a problem hiding this comment.
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
addok_france/utils.py
Outdated
@@ -116,14 +119,17 @@ def flag_housenumber(tokens): | |||
|
|||
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(): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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 :)
More variations for BP/CS/CIDEX/TSA like:
B.P 41
TSA N°41
Cleans phone/fax numbers too...