-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (37 loc) · 1011 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
package main
import (
"flag"
"fmt"
"github.com/PaluMacil/flesch-index/analysis"
"github.com/PaluMacil/flesch-index/flesch"
"os"
)
func main() {
flagAnalysis := flag.Bool("analysis", false, "do extended analysis")
flag.Parse()
if len(flag.Args()) < 1 {
fmt.Println("No file given for analysis")
os.Exit(1)
}
document, err := flesch.ParseFile(flag.Arg(0))
if err != nil {
fmt.Println("cannot parse file:", err)
os.Exit(1)
}
fmt.Println("Document:", document.Name())
fmt.Println()
fmt.Printf("Flesch Reading Ease Score: %.2f\n", document.Score())
fmt.Println("Readability:", document.ReadableScore())
fmt.Printf("Flesch–Kincaid Grade Level: %.2f\n", document.Kincaid())
if *flagAnalysis {
fmt.Println()
fmt.Println("Detailed Analysis Follows:")
report, err := analysis.Build(document)
if err != nil {
fmt.Println("cannot build analysis:", err)
os.Exit(1)
}
fmt.Println(report.SyllableAnalysis.ChartPath)
fmt.Println(report.SyllableRatioAnalysis.ChartPath)
}
}