|
@@ -47,10 +47,15 @@ func saveBayesToFile() {
|
|
|
tmpJSON = []byte(err.Error())
|
|
|
}
|
|
|
|
|
|
- statsJSON, err := json.MarshalIndent(Classifier.STATS, "", " ")
|
|
|
- if err != nil {
|
|
|
- statsJSON = []byte(err.Error())
|
|
|
- }
|
|
|
+ var statsREPORT string
|
|
|
+
|
|
|
+ statsREPORT = "\n"
|
|
|
+
|
|
|
+ Classifier.STATS.Range(func(key interface{}, value interface{}) bool {
|
|
|
+
|
|
|
+ statsREPORT += fmt.Sprintf("{\"%s\" : \"%d\"}\n", key.(string), value.(int64))
|
|
|
+ return true
|
|
|
+ })
|
|
|
|
|
|
dumpfile := os.Getenv("DUMPFILE")
|
|
|
if dumpfile == "" {
|
|
@@ -58,9 +63,9 @@ func saveBayesToFile() {
|
|
|
}
|
|
|
|
|
|
if DebugLog {
|
|
|
- log.Println("DUMP: ", string(tmpJSON))
|
|
|
+ log.Println("DUMP: ", string(tmpJSON)+statsREPORT)
|
|
|
} else {
|
|
|
- writeToFile(dumpfile, string(tmpJSON)+string(statsJSON))
|
|
|
+ writeToFile(dumpfile, string(tmpJSON)+statsREPORT)
|
|
|
|
|
|
log.Println("File saved: ", dumpfile)
|
|
|
}
|