hebcal / hebcal-js

⛔️ DEPRECATED - a perpetual Jewish Calendar (JavaScript)
GNU General Public License v3.0
123 stars 40 forks source link

findSedra should work better #17

Closed Scimonster closed 8 years ago

Scimonster commented 9 years ago
var year = new Hebcal(5775); // define the year

year.findSedra('Miketz') // good
year.findSedra('miketz') // not found
year.findSedra('מקץ') // not found
year.findSedra('מקצ','h') // not found
year.findParsha('Shemos','a') // good
year.findParsha('Shemos') // nope

Expected behavior: Find the parsha regardless of spelling.

MosheBerman commented 8 years ago

Can you please detail the fixes, since your commit says "partially fixes?"

Scimonster commented 8 years ago

@MosheBerman Now it searches all spellings, but is still case sensitive.

year.findSedra('Miketz') // good
year.findSedra('miketz') // not found
year.findSedra('מקץ') // found -- new!
year.findSedra('מקצ','h') // not found
year.findParsha('Shemos','a') // good
year.findParsha('Shemos') // found -- new!
MosheBerman commented 8 years ago

Ah, cool! What do the 'h', and 'a' arguments do?

MosheBerman commented 8 years ago

I'm thinking that you can do some basic operations to solve this. For the english strings, storing them as all lowercase, then lowercasing any english search string would solve the problem. And replacing the 5 end characters for your מקץ/מקצ case should also be fairly simple. The principle is the same:

Pick a canonical storage format and convert any incoming queries to that format. For display, it might become necessary to format again (for example, back to uppercase.)

I'm not sure if I'm going to break things by changing your arrays. Does anything else depend on that code being uppercase or spelled a specific way?