From f0b1196365b299d09aaa651bfe22367ad4cf8f88 Mon Sep 17 00:00:00 2001 From: William Apollo <4895865+Spaceenter@users.noreply.github.com> Date: Fri, 16 Jun 2023 16:34:21 -0700 Subject: [PATCH] Fix a bug for tokenize for place recognize. (#1165) --- internal/server/recon/recognize.go | 3 +++ internal/server/recon/recognize_test.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/internal/server/recon/recognize.go b/internal/server/recon/recognize.go index 385494fa7..02944efb3 100644 --- a/internal/server/recon/recognize.go +++ b/internal/server/recon/recognize.go @@ -76,6 +76,9 @@ func tokenize(query string) []string { if string(partBySpace[0]) == "," { tokens = append(tokens, ",") partBySpace = partBySpace[1:] + if partBySpace == "" { + continue + } } // Check suffix. diff --git a/internal/server/recon/recognize_test.go b/internal/server/recon/recognize_test.go index 9301d2a2b..27b127177 100644 --- a/internal/server/recon/recognize_test.go +++ b/internal/server/recon/recognize_test.go @@ -67,6 +67,10 @@ func TestTokenize(t *testing.T) { " alpha ,beta,Gamma, delta eta", []string{"alpha", ",", "beta", ",", "Gamma", ",", "delta", "eta"}, }, + { + "alpha , beta,Gamma", + []string{"alpha", ",", "beta", ",", "Gamma"}, + }, } { got := tokenize(c.query) if diff := cmp.Diff(got, c.want); diff != "" {