Skip to content

Commit

Permalink
Fix #11 (#12)
Browse files Browse the repository at this point in the history
fix(mspy_udl): 过滤掉含有非汉字的词条
  • Loading branch information
nopdan authored May 10, 2024
1 parent 0cecf25 commit 97ac8e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# 上传到 Artifact
- name: Upload windows
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: rose
path: ./bin/
10 changes: 10 additions & 0 deletions pkg/pinyin/mspy_udl.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"slices"
"time"
"unicode"

"github.com/nopdan/rose/pkg/util"
)
Expand Down Expand Up @@ -488,6 +489,15 @@ func (f *MspyUDL) Unmarshal(r *bytes.Reader) []*Entry {
}

func (f *MspyUDL) Marshal(di []*Entry) []byte {
di = slices.DeleteFunc(di, func(v *Entry) bool {
for _, r := range v.Word {
if !unicode.Is(unicode.Han, r) {
return true
}
}
return false
})

var buf bytes.Buffer
buf.Grow(0x2400 + 60*len(di))

Expand Down

0 comments on commit 97ac8e6

Please sign in to comment.