-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
45 lines (38 loc) · 926 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"bufio"
"fmt"
"os"
"strings"
"time"
"github.com/artmello/goschinke/schinke"
)
func main() {
start := time.Now()
var total, ok int
s := bufio.NewScanner(os.Stdin)
for s.Scan() {
fields := strings.Fields(s.Text())
if len(fields) != 3 {
continue
}
total++
word, noun, verb := fields[0], fields[1], fields[2]
actualNoun, actualVerb := schinke.Stem(word)
if actualNoun != noun {
fmt.Printf("[%v] ERROR [noun]: expected %v, actual %v\n", word, noun, actualNoun)
continue
}
if actualVerb != verb {
fmt.Printf("[%v] ERROR [verb]: expected %v, actual %v\n", word, verb, actualVerb)
continue
}
ok++
}
if err := s.Err(); err != nil {
fmt.Fprintf(os.Stderr, "goschinke: %v\n", os.Args[0], err)
return
}
fmt.Printf("Accuracy: %.2f%% [%d/%d]\n", float64(100*ok)/float64(total), ok, total)
fmt.Printf("goschinke took %gs\n", time.Since(start).Seconds())
}