AppleScript名:ASOCでOS内蔵辞書を串刺し検索するじっけん3 |
— 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 –Japanese & English Dictionaries set dNameList to {"Apple用語辞典", "Oxford Thesaurus of English", "スーパー大辞林", "Oxford Dictionary of English", "Oxford American Writer’s Thesaurus", "Wikipedia", "New Oxford American Dictionary", "ウィズダム英和辞典 / ウィズダム和英辞典", "Wikipedia"} –English Dictionaries set dNameList to {"Oxford American Writer’s Thesaurus", "New Oxford American Dictionary"} –Wikipedia set dNameList to {"Wikipedia"} set aTerm to "set" 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 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 62 times, 1 visits today)