[ReaderDictionary] clean interpuncts, pipes and up arrows from text selection#14031
Conversation
| text = text:gsub("·", "") -- interpunct | ||
| text = text:gsub("|", "") -- pipe | ||
| text = text:gsub("↑", "") -- and up arrow, used in some dictionaries to indicate related words |
There was a problem hiding this comment.
(inconsistant indentation of the comment on the last one)
|
It can be one line using brackets. |
|
Agreed, it's simple enough for that. |
|
Sorry, don't really how gsub works, but isn't this now looking for the combination of the three characters? Also, comments of the first two didn't make it to the revised one-liner |
No, |
|
what do you mean by "only once"? |
|
I phrased that badly. I was trying to explain that the pattern itself matches a single character. In this case the gsub function means that pattern (i.e., the single character) will be matched any time it occurs. Whereas something like |
What do |
|
Seeing an example probably explains best. It's mostly used for getting specific parts out of a larger string. The Lines 26 to 42 in e0c8530 |
|
I thought you were suggesting there was a problem, unless you are ;) |
This one is still to be solved :) (and/or the current splitting on 2 lines is odd, first line with a full comment ends with a period. 2nd line tail of the code starts with a lowercase). |
poire-z
left a comment
There was a problem hiding this comment.
Fine with me, if you have checked it works with each of the 3 chars after your last rewrite.
|
Works fine with interpuncts and pipes, i don’t have any dicts with arrows though. But you also sound as if you're suggesting something is wrong, are you? |
|
No no, but with regexps, best to triple check when making changes. |
|
oops, can I add this one as well?
|
|
What's it for though? :-D |
|
these pesky little guys: 1word or word1 --> word |
|
Is this for number of syllables? |
|
I suppose exceptions like A1 Sauce are rare enough for it to be an improvement most of the time. |
I guess %a may not match Chinese or Arabic letters. |
if you think that is safe, ... I don't mind.
apparently, but that wouldn't be problematic here, what would be is as @Frenzie mentioned, things like A1 (the sauce and the paper size), 3D, MI6
what do you mean by "remove any digit"?
that seems highly unlikely but I suppose not impossible, I think is safe to assume it does not happen. |
You should mind testing :) (I just gave a thought, no idea if it is safe and working).
I remember that recently, you proposed to lookup an additional transformed word in some case (dunno if this was merged or not). Again, just asking: what if a word contains digits, lookup first a word with the digits removed, then the original word ? |
|
#13884, but i am not sure that is a better approach, suddenly we'd be searching for |




what's new
frontend/apps/reader/modules/readerdictionary.lua: Added logic to remove interpuncts (·), pipes (|), and up arrows (↑) from text selections, as these characters are used in some dictionaries for syllable delimitation or indicating related words.as seen is #14013
This change is