Last active
October 2, 2016 17:03
-
-
Save audreyt/4648550 to your computer and use it in GitHub Desktop.
簡單的 ~/bin/moe 命令列搜尋器。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use constant MoeDatabase => "$ENV{HOME}/w/newdict/development.sqlite3"; | |
for my $arg (@ARGV) { | |
my $col = 'title'; | |
if ($arg =~ /%$/) { | |
$arg = "%$arg"; | |
$col = 'def'; | |
} | |
$arg .= '%' unless $arg =~ s/\$$//; | |
system sqlite3 => MoeDatabase, qq[ | |
SELECT '' || title || '\t' || heteronyms.bopomofo || '\n» ' || group_concat( | |
def, '\n» ' | |
) || '\n' | |
FROM entries | |
JOIN heteronyms ON entry_id = entries.id | |
JOIN definitions ON heteronym_id = heteronyms.id | |
WHERE $col LIKE '$arg' | |
GROUP BY title, heteronyms.bopomofo; | |
]; | |
} |
後綴 $ 表示單詞比對(而非預設的前綴比對):
$ moe 萌$
萌 ㄇㄥˊ
» 草木初生的芽。說文解字:「萌,艸芽也。」唐˙韓愈、劉師服、侯喜、軒轅彌明˙石鼎聯句:「秋瓜未落蒂,凍芋
強抽萌。」
» 事物發生的開端或徵兆。韓非子˙說林上:「聖人見微以知萌,見端以知末。」漢˙蔡邕˙對詔問灾異八事:「以
杜漸防萌,則其救也。」
» 人民。通「氓」。如:「萌黎」、「萌隸」。
» 姓。如五代時蜀有萌慮。
» 發芽。如:「萌芽」。楚辭˙王逸˙九思˙傷時:「明風習習兮龢暖,百草萌兮華榮。」
» 發生。如:「故態復萌」。管子˙牧民:「惟有道者,能備患於未形也,故禍不萌。」三國演義˙第一回:「若
萌異心,必獲惡報。」
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
後綴 % 可查定義: