Giter Site home page Giter Site logo

go-cc-cedict's Introduction

go-cc-cedict

Build Status GoDoc

A parser for the wonderful Chinese <-> English CC-CEDICT project that returns structured entries including definitions, Pinyin, Simplified and Traditional variants, references and abbreviations.

The dictionary as written was not meant for machine consumption, but I'm doing my damndest to parse it for applications.

Usage

You can either use a convenience function to load up the whole dictionary given the raw data file or parse individual lines, as you please.

import (
    "fmt"
    "os"

    cedict "github.com/purohit/go-cc-cedict"
)

f, _ := os.Open("/home/data/cedict_1_0_ts_utf-8_mdbg.txt")
defer f.Close()
dict, _ := cedict.ParseDictionary(f)
for _, entry := range dict.Entries {
    fmt.Println(e)
    break
}

// Or, parse a line yourself:

entry, _ := cedict.ParseEntry("企投 企投 [qi4 tou2] /to have fun (Taiwanese, POJ pr. [chhit-thô])/")
fmt.Println(e.Simplified, e.Pinyin, e.EnglishDefinitions)

Contributing

I'd appreciate contributions that help make Entrys even more specific -- there are a lot of exceptions in the definitions since they're somewhat free-form. For example, adding a specific "Abbreviations" field to the struct where all abbreviations are parsed out instead of remaining in Definitions.

Please add your own tests and make sure the current ones pass! I'm okay with reasonable backwards-incompatibility (I expect this library to be low-usage) via modifications to Entry.

License

The license for this parsing software itself is MIT, however the actual dictionary data is licensed under a CC license (see the main project page for more info).

go-cc-cedict's People

Contributors

purohit 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.