diff --git a/TODO b/TODO index 0cf388a..fe7e340 100644 --- a/TODO +++ b/TODO @@ -1,57 +1,51 @@ ## dictpopup -- Fix formating for JMDict and Jitendex +- Fix formating for JMDict (tags come after content) + - Just put content into separate variable and then concatenate at end +- Fix formatting for Jitendex (Prettier lists) - Write a "Yomichan search"-like window application - Include a small default dictionary (.mdb file) -- Add ながら deinflection Mid priority +- Right click on '+' button -> popup menu with: "add from clipboard", ... +- Right click on audio button -> popup menu with "copy file to clipboard", ... - Implement the reading label as a text view to allow for editing -> initiate new search on Enter press - Group terms by reading, allow for switching between different readings - Implement a small window to manually enter a search string instead of selecting - Kanjify the word in the copied sentence according to the dictionary entry - Remove trailing spaces from user settings +- Need some check when looking up a hiragana conversion to prevent things like 賢人会 -> 県人会 +- Don't show circle indicator if Anki is not running / on error +- Show a blue circle if existing cards are all new +- Search for audio of inflected selected word (e.g. 下がらない) (optionally) +- Switch to using GSettings - Write a gui config tool - Select dictionaries - Choose dictionary sort order - build database - change general config -- Need some check when looking up a hiragana conversion to prevent things like 賢人会 -> 県人会 -- Don't show circle indicator if Anki is not running / on error -- Search for audio of inflected selected word (e.g. 下がらない) (optionally) -- Merge dbreader.c and dbwriter.c Low priority +- Support pictures - Fix "Error obtaining window name" on recursive lookup - The problem is, that dictpopup creates a "child window" (?) with id one more which does not have a name - This affects all programs which create a child without own title name -- Deinflector should not check for verb stem when some (non 記号 and Japanese) characters where already truncated - Handle "Anki not running" more gracefully - Disable Anki support and reenable automatically if Anki starts - Allow configurable keybindings - Allow resizing the window and remember the size on close (write to config.ini) -- Support for pictures - Move all Japanese specific things into deinflector.c, choose more language agnostic function names in all other places - Adds tags to the Anki card, similiar to mpvacious -- Allow canceling selecting a sentence with Esc +- Allow canceling context selection with Esc - Allow changing AnkiConnect API address in config.ini -- Switch dictionary implementation to growable buffers (buf.h) -- Fix Makefile to only rebuild necessary parts -- Don't call jppron through the shell -- Refactor settings.c -- Refactor popup.c -- Add correct feature test macros -- Could split Mecab conversion and kata -> hira conversion into separate configuration options - Skip certain lines on definition add (without selection), e.g.: - しず か (しづ—) [1]【静か・▽閑か】 -(形動)〔文〕ナリ - Put length of longest entry into the database under LENGTH_OF_LONGEST_ENTRY. Then limit the lookup by that length + - Currently hard coded to 60 bytes - Only important for an auto scan implementation though -## dictpopup-create -- Process every dictionary in a different thread? - - Questionable if this makes sense, as it's already pretty fast and would make the code more complicated - ## Known problems: +- Can't pronounce 方方[かたがた] ### Misc - If there is a dictionary entry for 恭しく even though 恭しい is present in the collection, then a red dot will be shown ### Deinflection @@ -69,6 +63,8 @@ freq: - いじらしい not present in all Possible ideas: +- Add some way to lookup example sentences + - Maybe something like a menu button which opens a popup menu with: "settings", "lookup massif example sentences", ... - Implement a dbus service mode - Keep window in the background and just hide on close - This should allow for near instantaneous lookup (The bottleneck currently is all due to gtk + X11, i.e. starting the window) @@ -77,8 +73,6 @@ Possible ideas: - But I think this won't allow moving / resizing the window - Another approach might be using an invisible (transparent) fullscreen window with a popover / popup menu at the mouse pointer - Need to look into how goldendict's move() function is implemented (Probably using Qt) -- Show loading percentage in dictpopup-create -- Right click on audio button -> open some menu with "copy file to clipboard", ... - Write a browser addon which enables using dictpopup just by pressing Shift (like yomichan) - It simply needs to pass the next ~50 characters starting from the current mouse position as an argument to dictpopup - However I strongly doubt that an extension can execute some program, even if it's a local copy diff --git a/tests/ajt_audio_index_parser_tests.c b/tests/ajt_audio_index_parser_tests.c index 51b9f86..07002be 100644 --- a/tests/ajt_audio_index_parser_tests.c +++ b/tests/ajt_audio_index_parser_tests.c @@ -3,6 +3,8 @@ #include "ajt_audio_index_parser.c" +#define AUDIO_INDICES_DIR "../tests/files/audio_indices" + TestSuite *ajt_audio_index_parser_tests(void); Describe(AudioIndexParser); @@ -25,15 +27,15 @@ static void foreach_file(void *userdata, s8 fullpath, fileinfo fi) { } Ensure(AudioIndexParser, correctly_parses_nhk2016_entry) { - s8 curdir = S("../tests/files/testentries/audio_index_1"); - char *fn = "../tests/files/testentries/audio_index_1"; + s8 curdir = S(AUDIO_INDICES_DIR); + char *fn = AUDIO_INDICES_DIR "/audio_index_1"; expect(foreach_headword, when(headword.s, is_equal_to_string("静か")), - when(fullpath.s, is_equal_to_string("../tests/files/testentries/audio_index_1/media/20171018162916.ogg")) + when(fullpath.s, is_equal_to_string(AUDIO_INDICES_DIR "/media/20171018162916.ogg")) ); expect(foreach_file, - when(fullpath.s, is_equal_to_string("../tests/files/testentries/audio_index_1/media/20171018162916.ogg")), + when(fullpath.s, is_equal_to_string(AUDIO_INDICES_DIR "/media/20171018162916.ogg")), when(fi.origin.s, is_equal_to_string("NHK日本語発音アクセント新辞典")), when(fi.hira_reading.s, is_equal_to_string("しずか")), when(fi.pitch_number.s, is_equal_to_string("1")), diff --git a/tests/files/testentries/audio_index_1 b/tests/files/audio_indices/audio_index_1 similarity index 100% rename from tests/files/testentries/audio_index_1 rename to tests/files/audio_indices/audio_index_1 diff --git a/tests/files/testentries/1_entry b/tests/files/dictionary_entries/1_entry similarity index 100% rename from tests/files/testentries/1_entry rename to tests/files/dictionary_entries/1_entry diff --git a/tests/files/testentries/1_expected b/tests/files/dictionary_entries/1_expected similarity index 100% rename from tests/files/testentries/1_expected rename to tests/files/dictionary_entries/1_expected diff --git a/tests/files/testentries/2_entry b/tests/files/dictionary_entries/2_entry similarity index 100% rename from tests/files/testentries/2_entry rename to tests/files/dictionary_entries/2_entry diff --git a/tests/files/testentries/2_expected b/tests/files/dictionary_entries/2_expected similarity index 100% rename from tests/files/testentries/2_expected rename to tests/files/dictionary_entries/2_expected diff --git a/tests/files/testentries/3_entry b/tests/files/dictionary_entries/3_entry similarity index 100% rename from tests/files/testentries/3_entry rename to tests/files/dictionary_entries/3_entry diff --git a/tests/files/testentries/3_expected b/tests/files/dictionary_entries/3_expected similarity index 100% rename from tests/files/testentries/3_expected rename to tests/files/dictionary_entries/3_expected diff --git a/tests/files/testentries/4_entry b/tests/files/dictionary_entries/4_entry similarity index 100% rename from tests/files/testentries/4_entry rename to tests/files/dictionary_entries/4_entry diff --git a/tests/files/testentries/4_expected b/tests/files/dictionary_entries/4_expected similarity index 100% rename from tests/files/testentries/4_expected rename to tests/files/dictionary_entries/4_expected diff --git a/tests/files/testentries/5_entry b/tests/files/dictionary_entries/5_entry similarity index 100% rename from tests/files/testentries/5_entry rename to tests/files/dictionary_entries/5_entry diff --git a/tests/files/testentries/5_expected b/tests/files/dictionary_entries/5_expected similarity index 100% rename from tests/files/testentries/5_expected rename to tests/files/dictionary_entries/5_expected diff --git a/tests/files/testentries/6_entry b/tests/files/dictionary_entries/6_entry similarity index 100% rename from tests/files/testentries/6_entry rename to tests/files/dictionary_entries/6_entry diff --git a/tests/files/testentries/6_expected b/tests/files/dictionary_entries/6_expected similarity index 100% rename from tests/files/testentries/6_expected rename to tests/files/dictionary_entries/6_expected diff --git a/tests/files/testentries/7_entry b/tests/files/dictionary_entries/7_entry similarity index 100% rename from tests/files/testentries/7_entry rename to tests/files/dictionary_entries/7_entry diff --git a/tests/files/testentries/7_expected b/tests/files/dictionary_entries/7_expected similarity index 100% rename from tests/files/testentries/7_expected rename to tests/files/dictionary_entries/7_expected diff --git a/tests/full_cycle_test.sh b/tests/full_cycle_test.sh new file mode 100755 index 0000000..9ed6086 --- /dev/null +++ b/tests/full_cycle_test.sh @@ -0,0 +1,119 @@ +#!/bin/bash + +# TODO: +# - Store created files in tmp dir + +assert_equals() { + if [[ "$1" == "$2" ]]; then + echo "Test passed" + return 0 + else + echo "Test failed!" + vimdiff <(echo "$1") <(echo "$2") + return 1 + fi +} + +cd "${0%/*}"/.. +curdir="$(pwd)" +echo "Working directory: $curdir" + +trap "rm -f ./tests/files/testdict.zip ./tests/files/data.mdb" EXIT + +echo "Zipping test dictionary..." +zip -j -r ./tests/files/testdict.zip ./tests/files/testdictionary/* + +echo "Creating index..." +dictpopup-create -d ./tests/files/ -i ./tests/files/ + +output=$(DICTPOPUP_CONFIG_DIR="$curdir" ./dictpopup-cli -d ./tests/files/ "面白い") + +expected_output=$'dictname: Test dictionary +kanji: 面白い +reading: おもしろい +definition: おもしろ・い[4]【面白い】 +(形) +(ク)おもしろ・し +〔「面(おも)白し」で、目の前がぱっと明るくなる感じを表すのが原義といわれる〕 +①楽しい。愉快だ。 +「昨日見た映画は━・かった」 +「勉強が━・くて仕方がない」 +②興味をそそる。興味深い。 +「何か━・い話はないか」 +「最後にきて━・い展開を見せる」 +③こっけいだ。おかしい。 +「━・いしぐさで人を笑わせる」 +④(多く、打ち消しの語を伴う)心にかなう。好ましい。望ましい。 +「病状が━・くない」 +「━・くない結果に終わる」 +「私に━・からぬ感情を抱いている」 +⑤景色などが明るく広々とした感じで、気分がはればれとするようだ。明るく目が覚めるようだ。 +「十日あまりなれば、月━・し/土左日記」 +⑥心をひかれる。趣が深い。風流だ。 +「昔を思ひやりてみれば━・かりける所なり/土左日記」 +〔類義の語に「おかしい」があるが、「おかしい」は格好・表情・しぐさ・話し方などが普通と違っていて、笑いたくなる意を表す。それに対して「おもしろい」は対象が普通の基準から見ると新鮮・奇抜で変化に富んでいて、興味をそそる意を表す〕 +━が・る(動(ラ)五[四])・━げ(形動)・━さ(名)・━み(名) + +dictname: Test dictionary +kanji: 面白い +reading: おもしろい +definition: ① +\t• interesting +\t• fascinating +\t• intriguing +\t• enthralling +\t◦ 新聞には何も面白いことは載っていない。 +\t There is nothing interesting in the newspaper. +② +\t• amusing +\t• funny +\t• comical +\t◦ これは私が読んだ中で一番面白い本です。 +\t This is the funniest book in my reading. +\t◦ 彼女は子供たちに面白い話をしてあげた。 +\t She told her children an amusing story. +③ +\t• enjoyable +\t• fun +\t• entertaining +\t• pleasant +\t• agreeable +\t◦ この本は面白い読み物です。 +\t This book makes pleasant reading. +\t◦ 野鳥を観察するのはとても面白い。 +\t Watching wild birds is great fun. +④ +\t• good +\t• satisfactory +\t• favourable +\t• desirable +\t• encouraging +\t📝 usu. in the negative + +dictname: Test dictionary +kanji: 面白い +reading: おもしろい +definition: おも‐しろ・い【×面白い】(形)《カロ・カツ(ク)・イ・イ・ケレ・○》 +① 満足できる内容であり心ひかれる。愉快だ。楽しい。「あの人は―」 +② 発展が期待でき興味深い。「なかなか―意見だ」 +③ 笑い出したくなる。おかしい。こっけいだ。 +④ 好ましい。「どうも結果が―・くない」 +〔文〕おもしろ・し(ク) +「面(おも)」は目前の情景で、それが広々とひらける意から。 +④は、多くあとに打ち消しの語を伴う。 + +dictname: Test dictionary +kanji: 面白い +reading: おもしろい +definition: おもしろい【面白い】面白い/愉快/痛快 +心が楽しく、おかしく、気持ちが晴れるようなさま。 +📚使い方 +◦ 面白い 【形】 ▽面白いように魚が釣れた ▽その学説は面白い +◦ 愉快 【名・形動】 ▽毎日愉快に過ごしている ▽愉快な仲間 +◦ 痛快 【名・形動】 ▽彼の発言は痛快だった ▽逆転勝ちした痛快な試合 +🔄使い分け +1 「面白い」は、広い意味を持つ語。喜ばしく、心がひかれるさまをいう。おかしいの意味のときは「愉快」に重なり、胸がすくの意味では「痛快」に重なる。また、一風変わっていたり新鮮であったりして、興味をひかれるさまにもいうが、この意味では他の二語とは重ならない。 +2 「愉快」は、おかしくて笑いを誘うようなさまをいう。 +3 「痛快」は、楽しく、胸の晴れるさま、胸のつかえが取り払われてすっとするようなさまをいう。また、単に豪快で気分のよいさまなどにも用いる。「痛快な飲みっぷり」「痛快な男」' + +assert_equals "$output" "$expected_output" diff --git a/tests/test.sh b/tests/test.sh deleted file mode 100644 index ef298f7..0000000 --- a/tests/test.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# TODO: -# - Create tmp directory where files are stored - -cd "${0%/*}"/.. -cd ./testfiles - -echo "Zipping test dictionary..." -zip -j -r testdict.zip ./testdictionary/* - -echo "Creating index..." -dictpopup-create -d ./ - -DP_DEBUG=1 DICTPOPUP_CONFIG=$(pwd) ../cli -d "$(pwd)" "面白い" diff --git a/tests/yomichan_parser_tests.c b/tests/yomichan_parser_tests.c index f92e375..e0b6988 100644 --- a/tests/yomichan_parser_tests.c +++ b/tests/yomichan_parser_tests.c @@ -1,9 +1,10 @@ #include +#include #include #include "yomichan_parser.c" -#include +#define DICTENTRIES_DIR "../tests/files/dictionary_entries" TestSuite *yomichan_parser_tests(void); @@ -24,11 +25,11 @@ static _nonnull_ void foreach_dictentry(void *userdata, dictentry de) { #define CHECK_NR(n) \ do { \ s8 toparse = {0}; \ - g_file_get_contents("../tests/files/testentries/" #n "_entry", (char **)&toparse.s, \ + g_file_get_contents(DICTENTRIES_DIR "/" #n "_entry", (char **)&toparse.s, \ (gsize *)&toparse.len, NULL); \ \ s8 expected = {0}; \ - g_file_get_contents("../tests/files/testentries/" #n "_expected", (char **)&expected.s, \ + g_file_get_contents(DICTENTRIES_DIR "/" #n "_expected", (char **)&expected.s, \ (gsize *)&expected.len, NULL); \ g_strchomp((char *)expected.s); \ \