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

Improve input tolerance to understand all languages. #122

Open
amenk opened this issue Nov 10, 2015 · 16 comments
Open

Improve input tolerance to understand all languages. #122

amenk opened this issue Nov 10, 2015 · 16 comments
Labels
type: feature Introduction of new functionality.
Milestone

Comments

@amenk
Copy link

amenk commented Nov 10, 2015

Example:

2015 Mär 10 10:00-20:00

2015 März 10 10:00-20:00

on

http://ypid.de/~osm/evaluation_tool/

Gives:

2015 Mä <--- (Unexpected token: "m" This means that the syntax is not valid at that point or it is currently not supported.)

@amenk
Copy link
Author

amenk commented Nov 10, 2015

But

"2015 Mär 10 10:00-20:00".substr(6,1)

properly gives "ä"

@ypid
Copy link
Member

ypid commented Nov 10, 2015

März confirmed working in Firefox 38.4.0, Chromium, IE 11 and NodeJS.

März <--- (Bitte benutze die englische Abkürzung "Mar" für "märz".)
März <--- (This rule is not very explicit because there is no time selector being used. Please add a time selector to this rule or use a comment to make it more explicit.)
März <--- (There was no PH (public holiday) specified. This is not very explicit. Unfortunately the tag key (e.g. "opening_hours", or "lit") is unknown to opening_hours.js. This warning only applies to the key opening_hours. If your value is for that key than read on. If not you can ignore the following. Please either append a "PH off" rule if the amenity is closed on all public holidays or use something like "Sa,Su,PH 12:00-16:00" to say that on Saturdays, Sundays and on public holidays the amenity is open 12:00-16:00. If you are not certain try to find it out. If you can’t then do not add PH to the value and ignore this warning.)

Mär is not yet supported. https://github.com/ypid/opening_hours.js/blob/8ecb8e096d781db3fb38ade15036271f379f5bfe/opening_hours.js#L2911

With what did you test?

@ypid ypid added the type: feature Introduction of new functionality. label Nov 10, 2015
@ypid ypid added this to the v3.4.0 milestone Nov 10, 2015
@amenk
Copy link
Author

amenk commented Nov 10, 2015

Sorry, März is working. The point is, that I render it in Germany, so it becomes "Mär" in my case, which does not work afterwards.
The localized generation of the beautified string takes the first three letters from the long month name, so we have to support all those.
Just add it manually?

@ypid
Copy link
Member

ypid commented Nov 10, 2015

Just add it manually?

I would say yes but if you find a good way to get that from the moment lib, why not. It is included anyway and input tolerance does not need to be optimized for performance.

@ypid
Copy link
Member

ypid commented Nov 10, 2015

Sure, I meant more a solution which supports all months and weekdays which the moment lib supports. To be done later.

@amenk
Copy link
Author

amenk commented Nov 10, 2015

Yes .. my code would support that, if you want to reuse it..

@ypid
Copy link
Member

ypid commented Nov 10, 2015

Sorry, I was in a hurry. I meant to support all months and weekdays in all languages which the moment lib supports. So ideally there would be a way to iterate over all support languages of the lib.

@amenk
Copy link
Author

amenk commented Nov 10, 2015

But there will be probably collisions over the different languages. Is that
a problem?
Am 10.11.2015 6:40 nachm. schrieb "Robin Schneider" <
notifications@github.com>:

I was in a hurry. I meant to support all months and weekdays in all
languages which the moment lib supports. So ideally there would be a way to
iterate over all support languages of the lib.


Reply to this email directly or view it on GitHub
https://github.com/ypid/opening_hours.js/issues/122#issuecomment-155505587
.

@ypid
Copy link
Member

ypid commented Nov 10, 2015

That is likely. Will need to be checked and tested. Concerning the data structure it would be no real problem as the first match is used.

@amenk
Copy link
Author

amenk commented Nov 10, 2015

For my use case it would also be sufficient to specify only one language to
search in.
Am 10.11.2015 7:33 nachm. schrieb "Robin Schneider" <
notifications@github.com>:

That is likely. Will need to be checked and tested. Concerning the data
structure it would be no real problem as the first match is used.


Reply to this email directly or view it on GitHub
https://github.com/ypid/opening_hours.js/issues/122#issuecomment-155524446
.

@ypid
Copy link
Member

ypid commented Nov 15, 2015

I wrote a script to generate the list for all languages. Still WIP. This will be done later together with #107.

@ypid ypid modified the milestones: All problems solved., v3.4.0 Nov 15, 2015
@ypid ypid changed the title Month "März" is not recognized - UTF8 problem? Imrpove input tolerance to understand all languages. Nov 15, 2015
@amenk amenk changed the title Imrpove input tolerance to understand all languages. Improve input tolerance to understand all languages. Nov 17, 2015
@amenk
Copy link
Author

amenk commented Nov 17, 2015

Thanks. works well.

#chat: Did I mention I hate NPM?

@ypid
Copy link
Member

ypid commented Nov 17, 2015

Good to know.

#chat: You did. I like npm though.

@no-trick-pony
Copy link

Are there any updates on this? I'm currently facing the same problem - opening_hours does not understand it's own output for month "März", because moment.js uses "Mrz." which does not match the regex used in opening_hours.js ("März?") in its localization file.
I think the current implementation is kinda hacky and it would be indeed better to retrieve the localizations from moment.js and let the user optionally decide, which language opening_hours.js is currently parsing (to avoid clashes, if there are any).

@ypid
Copy link
Member

ypid commented Feb 11, 2016

Not yet but the initial design has already been done and implemented: https://github.com/opening-hours/opening_hours.js/blob/master/gen_word_error_correction.js
Want to help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature Introduction of new functionality.
Projects
None yet
Development

No branches or pull requests

3 participants