Giter Club home page Giter Club logo

cedict's Introduction

cedict Chinese-English Dictionary Go Package - 漢英詞典Go軟件包 - 汉英词典Go软件包

GoDoc Go Report Card Coveralls License

Overview

Golang library for the community maintained Chinese-English dictionary (CC-CEDICT), published by MDBG.

https://www.mdbg.net/chinese/dictionary?page=cedict

The basic format of a CEDICT entry is:

Traditional Simplified [pin1 yin1] /American English equivalent 1/equivalent 2/
漢字 汉字 [han4 zi4] /Chinese character/CL:個|个/

Install

First grab the latest version of the package,

go get -u github.com/Ecostack/cedict

Next, include it in your application:

import "github.com/Ecostack/cedict"

Getting Started

Hanzi to Pinyin

package main

import (
	"fmt"
	"log"
	"github.com/Ecostack/cedict" // replace with your module path
)

func main() {
	dict := cedict.New()

	pinyin := dict.HanziToPinyin("龙豆")
	fmt.Println("Pinyin for 龙豆 is:", pinyin)
}

Finding Entry by Hanzi

package main

import (
	"fmt"
	"log"
	"github.com/Ecostack/cedict" // replace with your module path
)

func main() {
	dict := cedict.New()
	
	entry := dict.GetByHanzi("龙")
	if entry != nil {
		fmt.Printf("Found entry for 龙: %+v\n", entry)
	} else {
		fmt.Println("Entry for 龙 not found.")
	}
}

Finding Entries by Hanzi

package main

import (
	"fmt"
	"log"
	"github.com/Ecostack/cedict" // replace with your module path
)

func main() {
	dict := cedict.New()

	entries := dict.GetAllByHanzi("龙")
	for _, entry := range entries {
        fmt.Printf("Found entry: %+v\n", entry)
    }
}

Searching by Pinyin

package main

import (
	"fmt"
	"log"
	"github.com/Ecostack/cedict" // replace with your module path
)

func main() {
	dict := cedict.New()

	entries := dict.GetByPinyin("long2")
	for _, entry := range entries {
		fmt.Printf("Found entry: %+v\n", entry)
	}
}

Contributing

  1. Fork the repo
  2. Clone your fork (git clone https://github.com/<username>/cedict && cd cedict)
  3. Create your own branch (git checkout -b my-patch)
  4. Make changes and add them (git add .)
  5. Commit your changes (git commit -m 'Fixed #123')
  6. Push to the branch (git push origin my-patch)
  7. Create new pull request

License

Copyright 2020 John Cramb. All rights reserved. Copyright 2024 Sebastian Scheibe. All rights reserved.

Licensed under the MIT License. See LICENSE in the project root for license information.

cedict's People

Contributors

ecostack avatar jcramb avatar hitochan777 avatar

Watchers

 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.