From a9f9e17acf785a157dc6c5f9ca999ad25570ba5e Mon Sep 17 00:00:00 2001 From: Peter Kleiweg Date: Sat, 6 Jun 2026 21:05:00 +0200 Subject: [PATCH] gone gone --- .gitignore | 1 - Makefile | 4 ---- cmd/gone/gone.go | 41 ----------------------------------------- cmd/trends/trends.go | 22 +++++++++++++++++++++- 4 files changed, 21 insertions(+), 47 deletions(-) delete mode 100644 cmd/gone/gone.go diff --git a/.gitignore b/.gitignore index 289cd1a..89aa649 100644 --- a/.gitignore +++ b/.gitignore @@ -45,7 +45,6 @@ VRT/vrt bin/data2json bin/dates2json bin/flush -bin/gone bin/items2count bin/rang bin/top20 diff --git a/Makefile b/Makefile index 3cb08c4..fba5515 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,6 @@ all: make bin/data2json make bin/dates2json make bin/flush - make bin/gone make bin/items2count make bin/rang make bin/top20 @@ -37,9 +36,6 @@ bin/dates2json: cmd/dates2json/*.go bin/flush: cmd/flush/*.go go build -o $@ $^ -bin/gone: cmd/gone/*.go - go build -o $@ $^ - bin/items2count: cmd/items2count/*.go go build -o $@ $^ diff --git a/cmd/gone/gone.go b/cmd/gone/gone.go deleted file mode 100644 index aabc727..0000000 --- a/cmd/gone/gone.go +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import ( - e "codeberg.org/pebbe/errors" - - "bufio" - "fmt" - "os" - "strings" -) - -var ( - x = e.ExitErr -) - -func main() { - current := make(map[string]bool) - fp, err := os.Open(os.Args[2]) - x(err) - scanner := bufio.NewScanner(fp) - for scanner.Scan() { - current[strings.Split(scanner.Text(), "\t")[1]] = true - } - x(scanner.Err()) - fp.Close() - - var last string - fp, err = os.Open(os.Args[1]) - x(err) - scanner = bufio.NewScanner(fp) - for scanner.Scan() { - aa := strings.Split(scanner.Text(), "\t") - if !current[aa[1]] { - fmt.Printf("%s\t%s\n", aa[0], aa[1]) - } - last = aa[0] - } - x(scanner.Err()) - fp.Close() - fmt.Printf("%s\t\n", last) -} diff --git a/cmd/trends/trends.go b/cmd/trends/trends.go index 26bba5a..5e2fa52 100644 --- a/cmd/trends/trends.go +++ b/cmd/trends/trends.go @@ -14,6 +14,7 @@ import ( type Item struct { word string diff float64 + gone bool } var ( @@ -55,9 +56,11 @@ func main() { curmax++ items := make([]Item, 0) + seen := make(map[string]bool) for _, line := range lines { aa := strings.Split(line, "\t") + seen[aa[1]] = true n, err := strconv.Atoi(aa[0]) x(err) m, ok := refs[aa[1]] @@ -74,6 +77,19 @@ func main() { } } + for key, value := range refs { + if !seen[key] { + diff := float64(value)/float64(refmax) - 1.0 + if diff > 0.05 || diff < -0.05 { + items = append(items, Item{ + word: key, + diff: diff, + gone: true, + }) + } + } + } + sort.Slice(items, func(a, b int) bool { if items[a].diff == items[b].diff { return items[a].word < items[b].word @@ -82,7 +98,11 @@ func main() { }) for _, item := range items { - fmt.Printf("%f\t%s\n", item.diff, item.word) + var s string + if item.gone { + s = "X" + } + fmt.Printf("%f\t%s\t%s\n", item.diff, s, item.word) } }