![]() |
#736 | |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 84
Karma: 1142796
Join Date: Jul 2009
Device: Sony PRS 350, Kobo mini, PB mini
|
Quote:
|
|
![]() |
![]() |
![]() |
#737 |
Connoisseur
![]() Posts: 68
Karma: 10
Join Date: Dec 2014
Device: Kindle Paperwhite
|
Calibre viewer and kindle stock reader show the top margin if the item is wrapped inside a div tag.
Unfortunately it turns out it's a known bug in CREngine ![]() http://sourceforge.net/p/crengine/bugs/157/ |
![]() |
![]() |
Advert | |
|
![]() |
#738 |
Connoisseur
![]() Posts: 68
Karma: 10
Join Date: Dec 2014
Device: Kindle Paperwhite
|
Ok, now I'm fighting with dictionary. As I can't find a decent italian dictionary for stardict, I figured it would be nice to take a wiktionary.org dump and convert it to stardict format.
Yet it seems I can't produce a working (in koreader) dictionary. Well, at a certain point it seems I produced a working dictionary, but I can't figure out what went right that time and what is going constantly wrong since then. I tried everything: utf-8 with dom, utf-8 without dom, not using dos CR, using dos CR, tab format, babylon source format. I'm compiling the source file with stardict editor for windows. The dictionary is always fine with stardict for pc, but it doesn't work in koreader (both stable and nightly build). Koreader's log says: Code:
# lookup word: test # stripped word: test # JSON data cannot be decoded frontend/JSON.lua:525: frontend/JSON.lua:240: can't parse JSON at char 1 of: save to cache data/dict/test.idx [{ "dict": "test", "word": "test", "definition": "\ndictionary works" }] # dummy result table: test { [1] = { ["dict"] = "", ["word"] = "test", ["definition"] = "Nessuna definizione trovata." } } # showing quick lookup window # show widget # close widget UPDATE I uncommented in readerdictionary.lua the line that gives you log info about results_str from sdcv and I compared the log with those from a working entry. 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). Below is the log from the not working entry in the enclosed dictionary. Logs from the working dictionary I mentioned above don't show the string "save to cache data/dict/test.idx" in the results. Code:
# result str: test save to cache data/dict/test.idx [{ "dict": "test", "word": "test", "definition": "\ndictionary works" }] Last edited by guerrilla; 02-22-2015 at 08:12 AM. |
![]() |
![]() |
![]() |
#739 |
Going Viral
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
Where is the pathname fragment: data/dict/test.idx being written to on the PC and on the Kindle?
(I.E: what is the full pathname in each case, working and non-working?) Also check for differences in the permissions on both. - - - - - - Have you inspected the lines in the JSON.lua error report? Code:
# JSON data cannot be decoded frontend/JSON.lua:525: frontend/JSON.lua:240: can't parse JSON at char 1 of: save to cache data/dict/test.idx Ah... Are you using the same JSON.lua on the Kindle as on the PC? |
![]() |
![]() |
![]() |
#740 |
Connoisseur
![]() Posts: 68
Karma: 10
Join Date: Dec 2014
Device: Kindle Paperwhite
|
No wait knc1, when I wrote that the dictionary is working on the pc I meant with stardict for windows, not koreader for pc. I haven't access to a linux install at the moment, so I can't compile a pc build of koreader.
As for JSON.lua, as far as I can tell, it actually doesn't manage that "save to cache" output. But is JSON.lua used to parse only output from stcv? Otherwise I would catch that string in readerdictionary.lua or just comment line 592 in lib.cpp; is it of any use for sdcv to print that to stout? But maybe I'm getting everything wrong, I only know some very basic stuff of procedural programming and absolutely nothing specific to lua or cpp... Last edited by guerrilla; 02-22-2015 at 08:56 AM. |
![]() |
![]() |
Advert | |
|
![]() |
#741 | |
Going Viral
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
Quote:
Ah, *.lua files are plain text, just read those two lines referenced in the error report, in context. (It is Lua or LuaJIT that does the compiling, at run-time.) |
|
![]() |
![]() |
![]() |
#742 | ||
Connoisseur
![]() Posts: 68
Karma: 10
Join Date: Dec 2014
Device: Kindle Paperwhite
|
Quote:
Quote:
Those two lines, as far as I can tell, don't add much to the conclusions I came to, but again I'm no real programmer. They basically write the message you see in the logs I posted, when encountering a decode error. |
||
![]() |
![]() |
![]() |
#743 |
Going Viral
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
So try editing your dictionary file(s) to remove the lines the JSON decoder claims it can not parse.
![]() All you **might** lose is look-up caching -- which if we can believe the messages, you don't have anyway. ![]() |
![]() |
![]() |
![]() |
#744 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 76
Karma: 25460
Join Date: Feb 2015
Device: kobo h2o
|
hi
sorry it may be long story but be patient please as it said here koreader can be customized by stardict glossaries but, I have a problem with dictionary in Persian language when I try to create stardict glossaries from other formats ( bgl,... ) and copy them to .kobo/koreader/data/dict they don't work and nothing is seen. I tried different input glossary and now have BGL bgl xml csv html dict dic ifo idx epub prc ... glossary and when convert them to stardict format no one work in koreader I tried penelope, Marisa and Pyglossary ( GUI and command propmt method ) in Windows and even dictconv in Ubuntu and no one make a change in my problem and still no ifo work and nothing is seen. finaly I found stardict glossary of my language online by chance and when I copy it to device it shows some square shape then I change my strategy to add some font to koreader I add every UTF font I found ( include Noto Arabic ) in Fonts folder in root and font folder in koreader directory and then change font defaults in fonts.lua file. change cfont tfont and fallback font and replace my noto font with the name of original one on kobo and replace them finally I get here : its left to right ( wrong orientation ) and seprate character can anybody help me with one of these: make a good ifo glossary make this working by chance glossary to show well Last edited by barobach_so; 02-22-2015 at 02:32 PM. |
![]() |
![]() |
![]() |
#745 | |
Connoisseur
![]() Posts: 68
Karma: 10
Join Date: Dec 2014
Device: Kindle Paperwhite
|
Quote:
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$//" 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... :( |
|
![]() |
![]() |
![]() |
#746 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,727
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
(If you test your dictionary with the desktop versions of StarDict or GoldenDict, it'll most likely work.) |
|
![]() |
![]() |
![]() |
#747 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,379
Karma: 2155307
Join Date: Nov 2010
Location: Goettingen, Germany
Device: Kindle Paperwhite, Kobo Mini
|
For the dictionary, we even render ourselves in a most basic fashion - which is not aware of RTL (besides other things it is not aware of). Once I planned to use CoolReader for rendering the dictionary output (in order to render HTML tags in there), but as Doitsu wrote, that wouldn't bring RTL support either.
@guerrilla: Very good find. Care to do a report an issue on github if you haven't yet? Though I think that fixing sdcv would be the way to go - instead of hacking around the issue. Arguably, that (diagnostics) output should go to stderr instead of stdout. |
![]() |
![]() |
![]() |
#748 |
Connoisseur
![]() Posts: 68
Karma: 10
Join Date: Dec 2014
Device: Kindle Paperwhite
|
@hawhill: That would be even better and was actually my first guess, but I was unsure if you were willing to fork sdcv (or maybe it's already forked?).
The patch would be very simple, as far as I can tell it's just about changing line 592 of sdcv/src/lib.cpp from: Code:
printf("save to cache %s\n", url.c_str()); Code:
fprintf(stderr,"save to cache %s\n", url.c_str()); I'm still unsure about how I got stuck in this though. At a closer look it seems that that message is printed only when sdcv creates the cache file (.oft extension) and this should be the first time you search for a term. That's why this issue got unnoticed so far: you install your dictionary and search for a term, sdcv gives the "save to cache" message, json.decode fails to decode, koreader returns the dummy table, you think: "uh, word not present in the dictionary" and make another search which, from now on, goes smoothly. For some reason I was getting that warning again and again. Anyway, I will gladly do a report to github, I'm very happy to help ![]() Last edited by guerrilla; 02-24-2015 at 05:23 PM. Reason: as usual... |
![]() |
![]() |
![]() |
#749 | |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 76
Karma: 25460
Join Date: Feb 2015
Device: kobo h2o
|
Quote:
but how koreader has a RTL and LTR option in reflow engine ? when I read a pdf with koreader I can change this option and other question: there is a glossary.BGL that say it is graphical and no need font ( I don't know really waht is it ), can it be somehow helpful ? and the last Question: u know anything about ArabShaping ( or here ) ? can it solve RTL problem? there is some patch for android for RTL problem in xda-developers I'm thinking of change bgl to html (babylontohtml program ) and have a html glossary ( already have ) then revers the characters somehow and maybe connect them to each other ( arabic is a cursive font ) there is a prc glossary for kindle with the method I say and build by mobipocket Last edited by barobach_so; 02-23-2015 at 07:04 AM. |
|
![]() |
![]() |
![]() |
#750 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,379
Karma: 2155307
Join Date: Nov 2010
Location: Goettingen, Germany
Device: Kindle Paperwhite, Kobo Mini
|
@guerrilla: we already forked sdcv anyway :-) Thank you very much for the report!
@barobach_so: The PDF reflow engine isn't based on text rendering of any kind: It takes a visual approach and works on a rendered image of a page in the PDF, reordering what it finds in there. As in: There's a bunch of pixels that constitute a word (with some probability), and a few words in a row are a line. The dictionary doesn't do HTML. I planned to implement it at some point, but simply do not have any spare time for the coming months. This is not android software. Also, it doesn't use libICU. There is no sophisticated text layout engine. Given the amount of work it takes to implement one or even integrate an existing one, don't expect this problem to be solved soon. There aren't that many developers and there time is, unfortunately, scarce. A friendly invitation goes to anyone who wants to help, though. But mainly, this means writing code. |
![]() |
![]() |
![]() |
Tags |
application, k5 tools, kindle, koreader, launcher add-ons, lua, reader, touch |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
KPV: a PDF reader for Kindle, based on muPDF, GPLv3 | hawhill | Kindle Developer's Corner | 1056 | 11-11-2017 03:07 AM |
Hacked Up Reader for epub/fb2/txt/rtf/html/pdb/etc | bhaak | Kindle Developer's Corner | 296 | 10-01-2016 01:11 PM |
html to fb2 or epub | rulet | Conversion | 7 | 06-24-2012 05:54 PM |
Raccoon Reader - reads ePub, fb2, fb2.zip, txt on WP7 for free | Andrei_Shvydryk | Reading and Management | 0 | 10-31-2011 03:17 PM |
A real PDF to epub/djvu/rtf/html software?. | DsOft | ePub | 35 | 01-02-2011 03:57 PM |