From e53049e62f2b0f45afcc76039f2b33ed6b4927da Mon Sep 17 00:00:00 2001 From: Peter Kleiweg Date: Thu, 28 May 2026 02:36:55 +0200 Subject: [PATCH] top20.go: aangepast aan grote reorganisatie --- cmd/top20/top20.go | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/cmd/top20/top20.go b/cmd/top20/top20.go index 8e6c51e..47de59b 100644 --- a/cmd/top20/top20.go +++ b/cmd/top20/top20.go @@ -11,7 +11,7 @@ import ( var ( x = e.ExitErr - reFile = regexp.MustCompile(`(.*)(2[0-9][0-9][0-9]-[0-5][0-9])(.*)`) + reFile = regexp.MustCompile(`(.*)(2[0-9][0-9][0-9]\.[0-5][0-9])(.*)`) seen = make(map[string]bool) ) @@ -23,21 +23,30 @@ func main() { suffix := m[3] + ".t20" target := infile + ".t20" - x(os.Chdir("/net/corpora/nlnieuws/data")) - - files, err := os.ReadDir(".") + dirs, err := os.ReadDir("..") x(err) - for _, file := range files { - name := file.Name() - if strings.HasPrefix(name, prefix) && strings.HasSuffix(name, suffix) && name < target { - fp, err := os.Open(name) - x(err) - scanner := bufio.NewScanner(fp) - for scanner.Scan() { - seen[strings.Split(scanner.Text(), "\t")[1]] = true + for _, dir := range dirs { + if !dir.IsDir() { + continue + } + dirname := dir.Name() + if dirname[0] != '2' { + continue + } + files, err := os.ReadDir("../" + dirname) + x(err) + for _, file := range files { + name := file.Name() + if strings.HasPrefix(name, prefix) && strings.HasSuffix(name, suffix) && name < target { + fp, err := os.Open("../" + dirname + "/" + name) + x(err) + scanner := bufio.NewScanner(fp) + for scanner.Scan() { + seen[strings.Split(scanner.Text(), "\t")[1]] = true + } + x(scanner.Err()) + x(fp.Close()) } - x(scanner.Err()) - x(fp.Close()) } }