Coder Social home page Coder Social logo

macdict's Introduction

README

本程序封装了macOS的字典服务,实现枚举所有字典、查找单词并以文本或HTML的形式获取解释。

所有实现在 macdict.swift文件中。

示例

使用默认字典查找:

let text = DCSDictionary.lookUp(text: "word")

遍历所有字典

for (dictName, dict) in DCSDictionary.availableDictionaries {
    print(dictName)
}

查找单词

let dictName = "Oxford Dictionary of English"
let word = "hello"
if let dict = DCSDictionary.getDictionary(by: dictName), let entries = dict.lookUp(text: word) {
    for entry in entries {
        print("-----------headword---------")
        print(entry.headword)
        print("-----------text-------------")
        print(entry.text)
        print("-----------HTML-------------")
        print(entry.html)
        print("---------------------------")
    }
} else {
    print("can not find the definition of \"\(word)\"")
}

感谢

在实现时参考了 jakwings/macdict,和mattt/DictionaryKit

macdict's People

Contributors

chungchien avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.