Skip to content

Commit

Permalink
Merge pull request #1678 from Sefaria/gershayim
Browse files Browse the repository at this point in the history
Gershayim
  • Loading branch information
YishaiGlasner authored Oct 30, 2023
2 parents 4a74a32 + da542b9 commit a4bd282
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sefaria/model/autospell.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
+ "\u05c1\u05c2" \
+ "\u05d0\u05d1\u05d2\u05d3\u05d4\u05d5\u05d6\u05d7\u05d8\u05d9\u05da\u05db\u05dc\u05dd\u05de\u05df" \
+ "\u05e0\u05e1\u05e2\u05e3\u05e4\u05e5\u05e6\u05e7\u05e8\u05e9\u05ea" \
+ "\u05f3\u05f4" \
+ "\u200e\u200f\u2013\u201c\u201d\ufeff" \
+ " Iabcdefghijklmnopqrstuvwxyz1234567890[]`:;.-,*$()'&?/\""

Expand Down Expand Up @@ -218,6 +217,7 @@ def complete(self, instring, limit=0, redirected=False):
:return: completions list, completion objects list
"""
instring = instring.strip() # A terminal space causes some kind of awful "include everything" behavior
instring = self.normalizer(instring)
if len(instring) >= self.max_completion_length:
return [], []
cm = Completions(self, self.lang, instring, limit,
Expand Down
5 changes: 5 additions & 0 deletions static/js/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,11 @@ class SearchBar extends Component {
this.submitSearch(Sefaria.repairCaseVariant(query, d));
return;
}
const repairedQuery = Sefaria.repairGershayimVariant(query, d);
if (repairedQuery !== query) {
this.submitSearch(repairedQuery);
return;
}

if (d["is_ref"]) {
var action = d["is_book"] ? "Search Box Navigation - Book" : "Search Box Navigation - Citation";
Expand Down
14 changes: 14 additions & 0 deletions static/js/sefaria/sefaria.js
Original file line number Diff line number Diff line change
Expand Up @@ -1947,6 +1947,20 @@ _media: {},
// Used when isACaseVariant() is true to prepare the alternative
return data["completions"][0] + query.slice(data["completions"][0].length);
},
repairGershayimVariant: function(query, data) {
if (!data["is_ref"] && data.completions && !data.completions.includes(query)) {
function normalize_gershayim(string) {
return string.replace('״', '"');
}
const normalized_query = normalize_gershayim(query);
for (let c of data.completions) {
if (normalize_gershayim(c) === normalized_query) {
return c;
}
}
}
return query;
},
makeSegments: function(data, withContext, sheets=false) {
// Returns a flat list of annotated segment objects,
// derived from the walking the text in data
Expand Down

0 comments on commit a4bd282

Please sign in to comment.