辞書.app内の辞書「スーパー大辞林」を対象に、慣用句のキーワード検索(部分一致検索)を行うAppleScriptです。
–> dictKit.framework (To ~/Library/Frameworks/)
掲載時はmacOS 10.12上で作成、検証を行っていましたが、その後macOS 10.14でホームディレクトリ下のFrameworkへのアクセスが禁止されたため、実行にはScript Debugger上、およびScript Debuggerから書き出したEnhanced AppleScript Applet上で書き出して実行する必要があります。
# あるいは、SIPを解除すればスクリプトエディタ上でも実行可能です
AppleScript名:日本語の慣用句を検索する |
— Created 2017-12-30 by Takaaki Naganoya — 2017 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "dictKit" –https://github.com/mattt/DictionaryKit set aRes to retJapaneseIdionFromKanjiChar("血") of me –> {"血が通う", "血が騒ぐ", "血が繫がる", "血が上る", "血が引く", "血で血を洗う", "血と汗", "血となり肉となる", "血に飢える", "血の出るよう", "血の滲むよう", "血は争えない", "血は水よりも濃い", "血も涙もない", "血湧き肉躍る", "血を受ける", "血を歃る", "血を吐く思い", "血を引く", "血を見る", "血を分ける"} set aRes to retJapaneseIdionFromKanjiChar("家") of me –> {"家給し人足る", "家高し", "家に杖つく", "家貧しくして孝子顕わる", "家をあける", "家を出ず", "家を外にする"} set aRes to retJapaneseIdionFromKanjiChar("水") of me –> {"水到りて渠成る", "水が合わない", "水が漬く", "水が入る", "水が引く", "水涸る", "水清ければ魚棲まず", "水澄む", "水で割る", "水と油", "水にする", "水に流す", "水になる", "水に馴れる", "水温む", "水の滴るよう", "水の流れと身のゆくえ", "水の低きに就く如し", "水は方円の器に随う", "水も漏らさぬ", "水をあける", "水を打ったよう", "水を得た魚のよう", "水を掛ける", "水をさす", "水を向ける"} set aRes to retJapaneseIdionFromKanjiChar("木") of me –> {"木から落ちた猿", "樹静かならんと欲すれども風止まず", "木で鼻を括る", "木に竹を接ぐ", "木にも草にも心を置く", "木に餅がなる", "木に縁りて魚を求む", "木の股から生まれる", "木六竹八塀十郎", "木を見て森を見ず"} on retJapaneseIdionFromKanjiChar(aKanji) set aDictionary to (current application’s TTTDictionary’s dictionaryNamed:"スーパー大辞林") set hitEntryList to (aDictionary’s entriesForSearchTerm:aKanji) as list if hitEntryList is not equal to {missing value} then repeat with ii in hitEntryList set j to contents of ii set headW to (j’s headword) set headW to headW as text try set aText to (j’s |text|) set aText to aText as text on error set aText to (j’s HTML) set aText to decodeCharacterReference(aText) of me end try if aText contains "〈句項目〉" then set aCount to 1 set tmpList to paragraphs of aText set aLen to length of tmpList repeat with i in tmpList set j to contents of i if j contains "〈句項目〉" then set outList to items (aCount + 1) thru -1 of tmpList exit repeat end if set aCount to aCount + 1 end repeat repeat with ii from (aCount + 1) to aLen set jj to contents of ii if jj = "" then exit repeat end repeat set outList to contents of items (aCount + 1) thru (ii – 1) of tmpList return outList end if end repeat return {} end if end retJapaneseIdionFromKanjiChar on decodeCharacterReference(aStr) set anNSString to current application’s NSString’s stringWithString:aStr set theData to anNSString’s dataUsingEncoding:(current application’s NSUTF16StringEncoding) set styledString to current application’s NSAttributedString’s alloc()’s initWithHTML:theData documentAttributes:(missing value) set plainText to (styledString’s |string|()) as string return plainText end decodeCharacterReference |
More from my site
(Visited 38 times, 1 visits today)