wanasit / chrono

A natural language date parser in Javascript
MIT License
4.6k stars 341 forks source link

Question: auThursday eptember 28 12:00 PM parsed as Sat Oct 07 2023 12:00:00 #537

Open tiny-dancer opened 1 year ago

tiny-dancer commented 1 year ago

I've started using chrono node to help with post processing ocr. When running the following code on October 7:

parsedDateTime = chrono.parseDate(
          `auThursday eptember 28 12:00 PM`
        );
console.log(`Parsed Date: ${parsedDateTime}`);

Outputs: Parsed Date: Sat Oct 07 2023 12:00:00 GMT-0500 (Central Daylight Time)

It appears reasonable for chrono node to parse auThursday eptember 28 12:00 PM as indeed September 28 12:00.

Are my expectations reasonable for chrono-node? Are there further configurations that would help improve the parsing results?

Asking these questions to gauge if i need to use spellcheckers ahead of chrono-node or if it reasonable for chrono-node to handle fuzzy matching similar to this example

Thanks!

tiny-dancer commented 1 year ago

Another result for reference and if this is inline with expectations (executed on October 7):

parsedDateTime = chrono.parseDate(
         'Thursday eptember 28 12:00 PM'
        );

console.log(`Parsed Date: ${parsedDateTime}`);
Parsed Date: Thu Oct 05 2023 12:00:00 GMT-0500 (Central Daylight Time)
wanasit commented 1 year ago

Hello. Thanks for letting me know about your use case.

It is an interesting problem, but I am afraid it would be difficult to make Chrono handle spellchecking.

--

One idea you could try is populating Chrono dictionary (e.g. locales/en/constants.ts) with the common misspelled words (e.g. "September" => "eptember", "Sptember", "Setember", "Sepember", ...).

Because Chrono doesn't make those expose its dictionary to API, you probably need to fork and modify the library.

--

Sorry that I cannot really help you much on this. Please let me know how it goes.