initial commit

This commit is contained in:
amitl committed 2016-03-17 08:43:09 +02:00
1 parent 230bc4b894
commit e75ff137d3
2 files changed
+57 -2

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
package main
import (
"compress/gzip"
"encoding/json"
"fmt"
"os"
"github.com/fluhus/gostuff/nlp/wordnet"
)
// Modify this path to your local WordNet root.
const input = "../wordnet/dict"
func main() {
fmt.Println("Parsing database...")
wn, err := wordnet.Parse(input)
checkError(err)
fmt.Println("Encoding in JSON...")
j, err := json.MarshalIndent(wn, "", " ")
checkError(err)
fmt.Println("Writing output...")
f, err := os.Open("wordnet.json.gz")
checkError(err)
z := gzip.NewWriter(f)
_, err = z.Write(j)
checkError(err)
z.Close()
f.Close()
fmt.Println("Done!")
}
func checkError(err error) {
if err != nil {
fmt.Println("ERROR:", err)
os.Exit(2)
}
}