z1dev / zkanji

Japanese language study suite and dictionary
GNU General Public License v3.0
59 stars 10 forks source link

ZKanji hangs when importing examples #33

Open mxmlnkn opened 4 years ago

mxmlnkn commented 4 years ago

Importing the dictionaries works OK except that 13 words from the JLPTN data file were not found in the imported dictionary and it asks me how to match them. But then, when importing examples, it just hangs after a very short while, no error window, no crash it, the window is still responsible and text can still be selected but the progress bar won't move.

Adding some debug output I could find out that it hangs on:

line 979 B: 真昼~ の 太陽 が テニスコート(#1080030) を 目(め) も 眩む~ 程{ほど} に 照らす{照らし} 上げる{あげた}

To be more exact it hangs after TextSearchTreeBase::findContainer throws an exception because the given length is 0 maybe because it couldn't find any romaji? In particular this parent call hangs: findKanjiKanaWord( "テニスコート" , "#1080030" , (nullptr) , 6 , 8 , -1 ). I didn't look further what happens to this thrown exception and why no error dialog pops up. In the first place, it shouldn't throw. There must be some other underlying problem with the examples file. I think it happens because the #1080030 reference isn't ignored. In another run it hang on line 324 B: 此処{ここ} の ソース(#1075270)[01] は 舐める[02]{舐めて}~ 見る{みる} と 一寸(ちょっと){ちょっと} 塩っぱい, which is the first line containing such a hashtag number, so it might be that. I guess it it's sometimes this line and at others because it is multi-threaded?

I don't really know what I'm doing here but removing the hashtag number with sed makes it importable in ZKanji:

sed -i -r 's|\(#[0-9]+\)||g' examples.utf

P.S.: IMHO, you should avoid != expressions in for loops and instead almost always opt for > or <. Those != expressions are all just infinite loop bugs waiting to happen. Also, your code base is littered with trailing whitespaces, which my editor automatically removes and therefore leads to large diffs in git. I don't know if you'd accept merge requests but a kind of simple style check or uncrustify might be helpful for other contributors.

z1dev commented 3 years ago

Hi! Sorry for not writing before, but GitHub forgot to notify me of issues posted here apparently for a while now. I haven't seen multiple issues until now.

I'm not working on this project anymore. I wanted to make a full release and maybe add some small adjustments years ago, but for a long time nobody tested zkanji or reported issues, and I didn't want to make a full release of a possibly buggy program, then I moved on. (I'm adding this text at the start of every answer today, it's not a sign I don't care.)

They have changed the examples file format. That's annoying, because I didn't prepare zkanji for issues like this (apparently!) I thought of my imports as a hack solution anyway, which is why I didn't make it future proof. (Beside being difficult to predict how formats of a file will change.)

Sorry about the trailing white spaces. I have all my editors set up to remove them, but they are not very effective it seems. :(