diff --git a/README.md b/README.md index 1d80fd9..d22836c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,15 @@ -# wordnet-to-json -WordNet in JSON format. +WordNet in JSON Format +====================== + +Such fun! + +Download +-------- + +[here](https://dl.dropboxusercontent.com/u/20957649/wordnet/wordnet.json.gz). + +Run +--- + +If you'd like to create you own json file, simply run the go file. + diff --git a/main.go b/main.go new file mode 100644 index 0000000..dc3eb7e --- /dev/null +++ b/main.go @@ -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) + } +} +