aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2025-07-14 23:36:11 +0700
committerShulhan <ms@kilabit.info>2025-07-14 23:36:11 +0700
commit6754efaefeec3290a690339df563890b85775458 (patch)
treebf5fbe14631ec81b9e71806e4e49939982dfe9b2
parentc51a2583a4f1c5103cfe139a2ca1981f95b11f20 (diff)
downloadkamusku-6754efaefeec3290a690339df563890b85775458.tar.xz
go.mod: upgrade package pakakeh.go to v0.60.1
Since v0.60.1 the lib/hunspell package has been removed due to inactivity. We replace it by copying the internal function MergeDictionaries directly.
-rw-r--r--go.mod12
-rw-r--r--go.sum22
-rw-r--r--internal/cmd/mergedic/main.go83
3 files changed, 105 insertions, 12 deletions
diff --git a/go.mod b/go.mod
index d0d4b8e..fdc1464 100644
--- a/go.mod
+++ b/go.mod
@@ -3,16 +3,20 @@
module git.sr.ht/~shulhan/kamusku
-go 1.23.3
+go 1.23.4
require (
git.sr.ht/~shulhan/kbbi v0.1.1-0.20241213050244-4be4e6c13760
- git.sr.ht/~shulhan/pakakeh.go v0.58.2-0.20241212161141-3361472cc3d4
+ git.sr.ht/~shulhan/pakakeh.go v0.60.1
)
require (
- golang.org/x/net v0.32.0 // indirect
- golang.org/x/sys v0.28.0 // indirect
+ golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
+ golang.org/x/mod v0.24.0 // indirect
+ golang.org/x/net v0.39.0 // indirect
+ golang.org/x/sync v0.13.0 // indirect
+ golang.org/x/sys v0.32.0 // indirect
+ golang.org/x/tools v0.32.0 // indirect
)
//replace git.sr.ht/~shulhan/kbbi => ../kbbi
diff --git a/go.sum b/go.sum
index 62e8b9a..4727a39 100644
--- a/go.sum
+++ b/go.sum
@@ -1,8 +1,18 @@
git.sr.ht/~shulhan/kbbi v0.1.1-0.20241213050244-4be4e6c13760 h1:DY1e0WBpqK69mpS4mlYABnUMukywfV6bzMxjPR8CNwE=
git.sr.ht/~shulhan/kbbi v0.1.1-0.20241213050244-4be4e6c13760/go.mod h1:+E+2vx4f1TkRtTxZD+95TCjCsm2/zaKIiDFePGQTAaA=
-git.sr.ht/~shulhan/pakakeh.go v0.58.2-0.20241212161141-3361472cc3d4 h1:GJuzSB1DntXGLZzhGhwMIuI66wsBIYXF5kfEvDh0qiQ=
-git.sr.ht/~shulhan/pakakeh.go v0.58.2-0.20241212161141-3361472cc3d4/go.mod h1:andCp7SiIOiomrITys+AuhviJn/o2ASLQNrQjTlRkS4=
-golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
-golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
-golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
-golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+git.sr.ht/~shulhan/pakakeh.go v0.60.1 h1:JGke3BIh40tK+d9eHg0jYi/W+GVixWcGwFkAcynSBSY=
+git.sr.ht/~shulhan/pakakeh.go v0.60.1/go.mod h1:8t/pEqWDrEcyr26qR5sXJkF1M5tFhrs3Jzr5aYoZdIo=
+github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
+github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
+golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 h1:R84qjqJb5nVJMxqWYb3np9L5ZsaDtB+a39EqjV0JSUM=
+golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8=
+golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
+golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
+golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY=
+golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E=
+golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
+golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
+golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
+golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
+golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU=
+golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s=
diff --git a/internal/cmd/mergedic/main.go b/internal/cmd/mergedic/main.go
index 7f6301b..d564dee 100644
--- a/internal/cmd/mergedic/main.go
+++ b/internal/cmd/mergedic/main.go
@@ -5,9 +5,15 @@
package main
import (
+ "fmt"
"log"
+ "os"
+ "sort"
+ "strings"
- "git.sr.ht/~shulhan/pakakeh.go/lib/hunspell"
+ "git.sr.ht/~shulhan/pakakeh.go/lib/ascii"
+ libos "git.sr.ht/~shulhan/pakakeh.go/lib/os"
+ libstrings "git.sr.ht/~shulhan/pakakeh.go/lib/strings"
)
func main() {
@@ -15,8 +21,81 @@ func main() {
in := "id_ID.dic"
daftarKata := "daftar_kata_dasar"
- _, err := hunspell.MergeDictionaries(out, in, daftarKata)
+ _, err := mergeDictionaries(out, in, daftarKata)
if err != nil {
log.Fatal(err)
}
}
+
+// mergeDictionaries merge two or more dictionaries into single file.
+// The outFile define the output of merged dictionaries.
+// If the outFile already exist it will be truncated, otherwise it will be
+// created.
+// The inFiles contains list of input dictionary files.
+//
+// On success it will return number of words merged into output file.
+func mergeDictionaries(outFile string, inFiles ...string) (n int, err error) {
+ if len(inFiles) == 0 {
+ return 0, nil
+ }
+
+ if len(inFiles) == 1 {
+ err = libos.Copy(outFile, inFiles[0])
+ return 0, err
+ }
+
+ var (
+ dict = make(map[string]string, 1024)
+
+ lines []string
+ )
+
+ for x := range len(inFiles) {
+ lines, err = libstrings.LinesOfFile(inFiles[x])
+ if err != nil {
+ return 0, err
+ }
+
+ // Skip the first line that may contains number of words.
+ y := 0
+ if ascii.IsDigit(lines[y][0]) {
+ y = 1
+ }
+
+ for ; y < len(lines); y++ {
+ ss := strings.Split(lines[y], "/")
+ key := ss[0]
+ attr := dict[key] + strings.Join(ss[1:], "")
+ dict[key] = attr
+ }
+ }
+
+ words := make([]string, 0, len(dict))
+
+ for word, attr := range dict {
+ if len(attr) == 0 {
+ words = append(words, word)
+ } else {
+ words = append(words, word+"/"+attr)
+ }
+ }
+
+ sort.Strings(words)
+
+ fout, err := os.OpenFile(outFile, os.O_WRONLY|os.O_CREATE, 0600)
+ if err != nil {
+ return 0, err
+ }
+
+ fmt.Fprintf(fout, "%d\n", len(words))
+ for x := range len(words) {
+ fmt.Fprintf(fout, "%s\n", words[x])
+ }
+
+ err = fout.Close()
+ if err != nil {
+ return 0, err
+ }
+
+ return len(words), nil
+}