initial commit
This commit is contained in:
1 parent
230bc4b894
commit
e75ff137d3
2 files changed
+57
-2
No files matched your search
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user