Skip to content

Commit

Permalink
fix panic bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan committed Oct 7, 2021
1 parent 09d685a commit ec32a14
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
22 changes: 14 additions & 8 deletions cli/ask/ask.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,23 @@ func main() {

startTime := time.Now()
answers := chatbot.GetResponse(question)
if len(answers) == 0 {
fmt.Println("No answer!")
continue
}

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))
}
continue
}

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))
}
}
9 changes: 6 additions & 3 deletions cli/train/train.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ func main() {
var corporaFiles string
if len(files) > 0 {
corporaFiles = strings.Join(files, ",")
if len(*corpora) > 0 {
corporaFiles = strings.Join([]string{corporaFiles, *corpora}, ",")
}
} else {
corporaFiles = *corpora
}
if len(*corpora) > 0 {
corporaFiles = strings.Join([]string{corporaFiles, *corpora}, ",")
}

if len(corporaFiles) == 0 {
flag.Usage()
return
Expand Down

0 comments on commit ec32a14

Please sign in to comment.