Golang library for the community maintained Chinese-English dictionary (CC-CEDICT), published by MDBG.
The basic format of a CEDICT entry is:
Traditional Simplified [pin1 yin1] /American English equivalent 1/equivalent 2/
漢字 汉字 [han4 zi4] /Chinese character/CL:個|个/
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"
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)
}
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.")
}
}
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)
}
}
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)
}
}
- Fork the repo
- Clone your fork (
git clone https://github.com/<username>/cedict && cd cedict
) - Create your own branch (
git checkout -b my-patch
) - Make changes and add them (
git add .
) - Commit your changes (
git commit -m 'Fixed #123'
) - Push to the branch (
git push origin my-patch
) - Create new pull request
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.