Talk:革命

Ruby failure
Ruby fails in one of the usage examples. It seems the kana for the word is missing. Strangely, the ruby works if the example is shortened:
 * failure:
 * &darr;

Not sure what's going on there, but thought I'd note it for future reference. — Eru·tuon 08:54, 28 November 2017 (UTC)


 * Test:
 * Wyang (talk) 09:06, 28 November 2017 (UTC)
 * The example just needs the pronunciation of 力 to be added. If I add random kana between な and に, the error disappears. — Eru·tuon 09:51, 28 November 2017 (UTC)
 * The example just needs the pronunciation of 力 to be added. If I add random kana between な and に, the error disappears. — Eru·tuon 09:51, 28 November 2017 (UTC)


 * Test:
 * (A)
 * (B)
 * The code on line 654 of Module:ja uses two steps to extract the ruby for kanjis. (1) compare pattern and spaced kana; (2) compare pattern and unspaced kana. Only when both steps fail will it report an error. Applied to the two examples:
 * (A)
 * pattern: ^(..-)%%(..-)な(..-)に(..-)ち(..-)かう(..-) いを (..-)わすために(..-)%%(..-)した(..-)%%(..-). (..-)%%(..-)の(..-)は(..-)い. $
 * spaced kana: きょう%だい な に たちむかう ちか い を かわす ため に しゅう%けつ した ひと%びと. かく%めい の ひは ちかい.
 * Thus step (1) fails (for a different reason - the different spacing patterns in parameters 1 and 2, not the lack of kana for 力).
 * unspaced kana: きょう%だいなにたちむかうちかいをかわすためにしゅう%けつしたひと%びと. かく%めいのひはちかい.
 * And step (2) fails because of the lack of kana for 力.
 * (B)
 * pattern: ^(..-)%%(..-)な (..-) に(..-)ち(..-)かう(..-)い$
 * spaced kana: きょう%だい な に たちむかう ちかい
 * Thus step (1) passes despite the lack of kana, since parameter 1 is unspaced and the spacing in parameter 2 is counted as kana. And indeed, giving parameter 1 the same spaces makes this case fail:
 * unspaced kana: きょう%だいなにたちむかうちかい
 * Step (2) fails as expected since there is no kana for 力.
 * It seems there are many ways of fixing this:
 * Return an error if any of the captured 'rubies' contains only spaces after the check;
 * Capture only Kanji kana -containing strings in the error check on line 654 (not sure if this could lead to side effects);
 * Make parameter 1 of the template compulsorily spaced (this is the basis of the first step of this match-check function anyway).
 * Wyang (talk) 10:02, 28 November 2017 (UTC)
 * Thanks for this analysis. It's very helpful. It is easy to determine if a capture contains only spaces; I've added code that checks for that, and the log entry can be changed to an error message. First the tracking category should be given a few days to fill up, and the existing cases be corrected, so that there aren't a bunch of module errors to be corrected all at once. Or maybe the function should be made to return lua, and Module:ja-usex and Module:ja-link should have fallback behavior in case ruby generation fails.
 * It would be possible to capture only kana (I corrected your message because the pattern operates on kana, not kanji). At the moment, the pattern-matching can even be done with the basic string functions. We would just have to replace lua with a kana pattern. It might have to contain characters besides kana, though.
 * Making the kana argument compulsively spaced would work, but it would require a lot of template input to be modified. — Eru·tuon 21:39, 28 November 2017 (UTC)
 * Wyang (talk) 10:02, 28 November 2017 (UTC)
 * Thanks for this analysis. It's very helpful. It is easy to determine if a capture contains only spaces; I've added code that checks for that, and the log entry can be changed to an error message. First the tracking category should be given a few days to fill up, and the existing cases be corrected, so that there aren't a bunch of module errors to be corrected all at once. Or maybe the function should be made to return lua, and Module:ja-usex and Module:ja-link should have fallback behavior in case ruby generation fails.
 * It would be possible to capture only kana (I corrected your message because the pattern operates on kana, not kanji). At the moment, the pattern-matching can even be done with the basic string functions. We would just have to replace lua with a kana pattern. It might have to contain characters besides kana, though.
 * Making the kana argument compulsively spaced would work, but it would require a lot of template input to be modified. — Eru·tuon 21:39, 28 November 2017 (UTC)