View Single Post
Old 02-23-2015, 03:53 AM   #745
guerrilla
Connoisseur
guerrilla began at the beginning.
 
Posts: 68
Karma: 10
Join Date: Dec 2014
Device: Kindle Paperwhite
Quote:
Originally Posted by guerrilla View Post
It seems that every time JSON.lua fails to decode the result string it's because sdcv added the substring "save to cache data/dict/test.idx" to it. Could that be the reason? (in which case, line 592 in sdcv/blob/master/src/lib/lib.cpp should be the one causing the issue).
So it's confirmed that sdcv is causing this issue by printing to stdout the string: "save to cache" and the path of the relevant idx file.
The string is then passed to JSON.decode which fails to decode it as it probably assumes that the first char of the input string should be [.
I worked around the issue with a wrapper for sdcv with this code:
Code:
#!/bin/sh
./sdcv "$@" | /bin/sed -e "s/^save to cache .*\.idx$//"
and I changed line 65 in readerdictionary.lua to run the wrapper instead of sdcv.

Turns out that the italian dictionary I already have is not that bad at all and I was under that impression because koreader was giving dummy results for a lot of queries due to this issue.
What I find odd is that nobody noticed this so far. It's maybe because sdcv usually does this cache thing only the first time you look for a term. Sometimes though it gets stuck caching the same term over and over and people probably assume that the term is not in the dictionary?

If this is confirmed as a bug, I guess that the ultimate solution would be to clean results_str with a string substitution before passing it to JSON.decode at line 72 of readerdictionary.lua.

Last edited by guerrilla; 02-24-2015 at 05:23 PM. Reason: A lot of typos... :(
guerrilla is offline   Reply With Quote