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 findKeywordWithDictionaryApp("rake", "ウィズダム英和辞典 / ウィズダム和英辞典") of me on findKeywordWithDictionaryApp(aKeyword, aDictName) set aDictionary to (current application’s TTTDictionary’s dictionaryNamed:aDictName) set hitEntryList to (aDictionary’s entriesForSearchTerm:aKeyword) 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 return aText end repeat return {} end if end findKeywordWithDictionaryApp 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 36 times, 1 visits today)