Expose CC-CEDICT bytes as a Go module

This commit is contained in:
Rodolfo Carvalho committed 2022-09-09 03:36:53 +02:00
1 parent dd13cd3b86
commit f7d959e0ab
4 files changed
+51 -1

No files matched your search

+23 -1
View File
@@ -7,7 +7,29 @@ characters.
<a href="https://www.mdbg.net/chinese/dictionary"><img src="https://www.mdbg.net/logos/mdbg_dictionary_128x32.png" alt="MDBG Chinese-English dictionary" title="MDBG Chinese-English dictionary" style="border: solid 1px #c0c0c0" border="0" /></a> <a href="https://www.mdbg.net/chinese/dictionary"><img src="https://www.mdbg.net/logos/mdbg_dictionary_128x32.png" alt="MDBG Chinese-English dictionary" title="MDBG Chinese-English dictionary" style="border: solid 1px #c0c0c0" border="0" /></a>
The original dictionary is available as a plain text file. The original dictionary is available as a plain text file. In addition to that,
this repository is a Go module, which allows for easy consumption of the
dictionary bytes from a Go program.
```go
package main
import (
"os"
"github.com/rhcarvalho/cedict"
)
func main() {
os.Stdout.Write(append(cedict.Bytes[:200], []byte("...\n")...))
}
```
<!--
| CC-CEDICT Release Date | Number of Entries |
|------------------------|-------------------|
| 2013-03-19T13:58:14Z | 105565 |
-->
# License # License
+16
View File
@@ -0,0 +1,16 @@
// Package cedict provides an embedded copy of the [CC-CEDICT] Chinese to
// English word dictionary.
//
// [CC-CEDICT]: https://www.mdbg.net/chinese/dictionary?page=cc-cedict
package cedict
import _ "embed"
// Bytes are the raw bytes of the dictionary.
//
// The format is described on the [CC-CEDICT Wiki].
//
// [CC-CEDICT Wiki]: https://cc-cedict.org/wiki/format:syntax
//
//go:embed cedict_1_0_ts_utf-8_mdbg.txt
var Bytes []byte
+9
View File
@@ -0,0 +1,9 @@
package cedict
import "testing"
func TestBytes(t *testing.T) {
if len(Bytes) < 1000 {
t.Error("too few bytes")
}
}
+3
View File
@@ -0,0 +1,3 @@
module github.com/rhcarvalho/cedict
go 1.19