Skip to content

Commit

Permalink
feat: support simple mode in asking
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan committed Oct 6, 2021
1 parent 8a0c758 commit 5db44e3
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions cli/ask/ask.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ import (
"github.com/kevwan/chatbot/bot/adapters/storage"
)

const tops = 5

var (
verbose = flag.Bool("v", false, "verbose mode")
storeFile = flag.String("c", "corpus.gob", "the file to store corpora")
tops = flag.Int("t", 5, "the number of answers to return")
)

func main() {
Expand All @@ -29,7 +28,7 @@ func main() {
}

chatbot := &bot.ChatBot{
LogicAdapter: logic.NewClosestMatch(store, tops),
LogicAdapter: logic.NewClosestMatch(store, *tops),
}
if *verbose {
chatbot.LogicAdapter.SetVerbose()
Expand All @@ -46,13 +45,17 @@ func main() {

startTime := time.Now()
answers := chatbot.GetResponse(question)
for i, answer := range answers {
fmt.Printf("%d: %s\n", i+1, answer.Content)
if *verbose {
fmt.Printf("%d: %s\tConfidence: %.3f\t%s\n", i+1, answer.Content,
answer.Confidence, time.Since(startTime))
if *tops == 1 {
fmt.Printf("A: %s\n", answers[0].Content)
} else {
for i, answer := range answers {
fmt.Printf("%d: %s\n", i+1, answer.Content)
if *verbose {
fmt.Printf("%d: %s\tConfidence: %.3f\t%s\n", i+1, answer.Content,
answer.Confidence, time.Since(startTime))
}
}
fmt.Println(time.Since(startTime))
}
fmt.Println(time.Since(startTime))
}
}

0 comments on commit 5db44e3

Please sign in to comment.