AppleScript名:指定辞書で指定キーワードを串刺し検索 |
— Created 2015-10-25 by Takaaki Naganoya — 2015 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "dictKit" –https://github.com/mattt/DictionaryKit set dRes to getWordDifinitionInDictionaries("青い", {"スーパー大辞林"}) of me on getWordDifinitionInDictionaries(aTerm as string, dNameList as list) set localNameList to getNameOfLocalDictionaries() of me –指定辞書がローカル環境に存在しているかどうかチェック set aSet to current application’s NSMutableSet’s setWithArray:localNameList set bSet to current application’s NSMutableSet’s setWithArray:dNameList aSet’s intersectSet:bSet set dList to aSet’s allObjects() as list if dList = {} then return false set aResList to {} repeat with i in dNameList set aDictionary to (current application’s TTTDictionary’s dictionaryNamed:i) set hitEntryList to (aDictionary’s entriesForSearchTerm:aTerm) 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 set the end of aResList to {dictName:(i as text), keywordName:headW, dictContents:aText} end repeat end if end repeat aResList end getWordDifinitionInDictionaries 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 on getNameOfLocalDictionaries() set dSet to current application’s TTTDictionary’s availableDictionaries() set dList to dSet’s allObjects() set dNameList to {} repeat with i in dList set the end of dNameList to (i’s |name|()) as text end repeat return dNameList end getNameOfLocalDictionaries |
More from my site
(Visited 67 times, 1 visits today)
辞書.appで指定の単語を検索する v3 – AppleScriptの穴 says:
[…] 、サードパーティのFramework経由でも串刺し検索できるようになっています。 […]