68 lines
987 B
Go
68 lines
987 B
Go
package main
|
|
|
|
import (
|
|
e "codeberg.org/pebbe/errors"
|
|
|
|
"bufio"
|
|
"fmt"
|
|
"os"
|
|
"sort"
|
|
"strings"
|
|
)
|
|
|
|
var (
|
|
x = e.ExitErr
|
|
)
|
|
|
|
type Item struct {
|
|
word string
|
|
count int
|
|
}
|
|
|
|
func main() {
|
|
|
|
counts := make(map[string]int)
|
|
|
|
scanner := bufio.NewScanner(os.Stdin)
|
|
for scanner.Scan() {
|
|
word := strings.Split(scanner.Text(), "\t")[0]
|
|
counts[word] = counts[word] + 1
|
|
}
|
|
x(scanner.Err())
|
|
|
|
items := make([]Item, 0)
|
|
for key, value := range counts {
|
|
items = append(items, Item{
|
|
word: key,
|
|
count: value,
|
|
})
|
|
}
|
|
|
|
sort.Slice(items, func(a, b int) bool {
|
|
if items[a].count == items[b].count {
|
|
return items[a].word < items[b].word
|
|
}
|
|
return items[a].count > items[b].count
|
|
})
|
|
|
|
rang := 0
|
|
prev := 0
|
|
for _, item := range items {
|
|
if item.count < 2 {
|
|
break
|
|
}
|
|
if item.count != prev {
|
|
rang++
|
|
prev = item.count
|
|
}
|
|
fmt.Printf("%d\t%s\n", rang, item.word)
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
alto 'fp://node[@pt="n"]' 'tt:%w\t%I' $files | sed -e 's/\.[0-9][0-9]*$//' | sort | uniq | rang
|
|
|
|
*/
|