Example #1
0
func init() {
	// Filters is the default set of global filters.
	revel.Filters = []revel.Filter{
		revel.PanicFilter,             // Recover from panics and display an error page instead.
		revel.RouterFilter,            // Use the routing table to select the right Action
		revel.FilterConfiguringFilter, // A hook for adding or removing per-Action filters.
		revel.ParamsFilter,            // Parse parameters into Controller.Params.
		revel.SessionFilter,           // Restore and write the session cookie.
		revel.FlashFilter,             // Restore and write the flash cookie.
		revel.ValidationFilter,        // Restore kept validation errors and save new ones from cookie.
		revel.I18nFilter,              // Resolve the requested language
		HeaderFilter,                  // Add some security based headers
		revel.InterceptorFilter,       // Run interceptors around the action.
		revel.CompressFilter,          // Compress the result.
		revel.ActionInvoker,           // Invoke the action.
	}

	// register startup functions with OnAppStart
	// ( order dependent )
	// revel.OnAppStart(InitDB)
	// revel.OnAppStart(FillCache)
	var err error
	Model, err = wordmodel.Load("your_binary_result_file") // the file may be called 'vector.bin'. you may need to put absolute path if relative path is not working
	if err != nil {
		log.Println(err)
	}
}
Example #2
0
func main() {
	model, err := wordmodel.Load(os.Args[1])
	if err != nil {
		fmt.Println(err)
		return
	}
	scanner := bufio.NewScanner(os.Stdin)
	sents := make([]string, 2)
	for {
		fmt.Println("input:")
		i := 0
		for scanner.Scan() && i <= 1 {
			fmt.Printf("sent%d:\n", i)
			line := scanner.Text()
			sents[i] = line
			i += 1
		}

		fmt.Printf("%s | %s\n", sents[0], sents[1])
		if sents[0] == "EXIT" || sents[1] == "EXIT" {
			break
		}
		fmt.Printf("distance: %f\n", edist(sents[0], sents[1], model))
	}

}