Skip to content

Commit

Permalink
add chinese English dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeApe committed Jul 26, 2024
1 parent be16df5 commit 1870ebf
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion dict_ce.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasmecdict
package wasmdict

import (
"archive/zip"
Expand Down
6 changes: 3 additions & 3 deletions dict_ce_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasmecdict
package wasmdict

import (
"testing"
Expand All @@ -9,7 +9,7 @@ func TestCeLookUp(t *testing.T) {
if entryCE == nil {
t.Error("not found")
} else {
t.Errorf("%v", entryCE)
t.Logf("%v", entryCE)
}

entryCE = CeLookUp("過", true)
Expand All @@ -21,7 +21,7 @@ func TestCeLookUp(t *testing.T) {
if entryCE == nil {
t.Error("not found")
} else {
t.Errorf("%v", entryCE)
t.Logf("%v", entryCE)
}

}
Expand Down
2 changes: 1 addition & 1 deletion dict_ec.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasmecdict
package wasmdict

import (
"bufio"
Expand Down
2 changes: 1 addition & 1 deletion dict_ec_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasmecdict
package wasmdict

import (
"testing"
Expand Down
12 changes: 6 additions & 6 deletions wasm_ce/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package main

import (
"github.com/mojocn/wasmecdict"
"github.com/mojocn/wasmdict"
"syscall/js"
)

Expand All @@ -12,7 +12,7 @@ const versionCe = "1.0.1"
func ceLookUpTw(_ js.Value, args []js.Value) any {
if len(args) > 0 {
text := args[0].String()
res := wasmecdict.CeLookUp(text, false)
res := wasmdict.CeLookUp(text, false)
if res != nil {
return js.ValueOf(res.Map())
}
Expand All @@ -22,7 +22,7 @@ func ceLookUpTw(_ js.Value, args []js.Value) any {
func ceLookUpCn(_ js.Value, args []js.Value) any {
if len(args) > 0 {
text := args[0].String()
res := wasmecdict.CeLookUp(text, true)
res := wasmdict.CeLookUp(text, true)
if res != nil {
return js.ValueOf(res.Map())
}
Expand All @@ -32,7 +32,7 @@ func ceLookUpCn(_ js.Value, args []js.Value) any {
func ceQueryLikeTw(_ js.Value, args []js.Value) any {
if len(args) > 0 {
text := args[0].String()
words := wasmecdict.CeQueryLike(text, false, 10)
words := wasmdict.CeQueryLike(text, false, 10)
results := make([]map[string]interface{}, 0, len(words))
for _, word := range words {
results = append(results, word.Map())
Expand All @@ -44,7 +44,7 @@ func ceQueryLikeTw(_ js.Value, args []js.Value) any {
func ceQueryLikeCn(_ js.Value, args []js.Value) any {
if len(args) > 0 {
text := args[0].String()
words := wasmecdict.CeQueryLike(text, true, 10)
words := wasmdict.CeQueryLike(text, true, 10)
results := make([]map[string]interface{}, 0, len(words))
for _, word := range words {
results = append(results, word.Map())
Expand All @@ -65,7 +65,7 @@ func ceDictInfo(_ js.Value, _ []js.Value) any {
}

func main() {
wasmecdict.PreLoadCeDict()
wasmdict.PreLoadCeDict()
js.Global().Set("ceLookUpTw", js.FuncOf(ceLookUpTw)) //export window.ceLookUpTw to lookUp Traditional Chinese word
js.Global().Set("ceLookUpCn", js.FuncOf(ceLookUpCn)) //export window.ceLookUpCn to lookUp Simplified Chinese word
js.Global().Set("ceQueryLikeCn", js.FuncOf(ceQueryLikeCn)) //export window.ceQueryLikeCn to query Simplified Chinese word
Expand Down
6 changes: 3 additions & 3 deletions wasm_ec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package main

import (
"github.com/mojocn/wasmecdict"
"github.com/mojocn/wasmdict"

Check failure on line 6 in wasm_ec/main.go

View workflow job for this annotation

GitHub Actions / build

no required module provides package github.com/mojocn/wasmdict; to add it:
"syscall/js"
)

Expand All @@ -12,7 +12,7 @@ const versionEc = "1.0.1"
func lookUp(_ js.Value, args []js.Value) any {
if len(args) > 0 {
text := args[0].String()
res := wasmecdict.EcLookUp(text)
res := wasmdict.EcLookUp(text)
if res != nil {
return js.ValueOf(res.Map())
}
Expand All @@ -31,7 +31,7 @@ func ecDictInfo(_ js.Value, _ []js.Value) any {
}

func main() {
wasmecdict.PreLoadEcDict()
wasmdict.PreLoadEcDict()
js.Global().Set("ecLookUp", js.FuncOf(lookUp)) //use window.ecLookUp("word") to look up a word
js.Global().Set("ecDictInfo", js.FuncOf(ecDictInfo)) //use window.ecDictInfo() to get dictionary info
done := make(chan struct{})
Expand Down

0 comments on commit 1870ebf

Please sign in to comment.