Created
February 1, 2017 14:58
-
-
Save m-mizutani/fb2de0c1585df78c53ce93c5c42d86d0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
db, db_err := OpenDatabase("net.db") | |
if db_err != nil { | |
log.Println("DB error:", db_err) | |
os.Exit(1) | |
} | |
// var mh codec.MsgpackHandle | |
mh := &codec.MsgpackHandle{RawToString: true} | |
dec := codec.NewDecoder(os.Stdin, mh) | |
var msg map[string]interface{} | |
for { | |
err := dec.Decode(&msg) | |
if err == nil { | |
priv_log, _ := msg["Private Work Log"].(string) | |
// fmt.Println(reflect.TypeOf(priv_log)) | |
for _, line := range strings.Split(priv_log, "\n") { | |
if strings.HasPrefix(line, "MSS| ") { | |
entities := ExtractEntities(line) | |
for _, entity := range entities { | |
insert_err := InsertNameRecord(db, msg, entity) | |
if insert_err != nil { | |
log.Println("Insert error:", err) | |
os.Exit(1) | |
} | |
} | |
} | |
} | |
} else if err == io.EOF { | |
break | |
} else { | |
log.Println(err) | |
os.Exit(1) | |
} | |
// fmt.Println(msg.count) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment