This commit is contained in:
jdl
2024-11-11 06:36:55 +01:00
parent d0587cc585
commit c5419d662e
102 changed files with 4181 additions and 0 deletions

31
tagengine/ngram_test.go Normal file
View File

@@ -0,0 +1,31 @@
package tagengine
import (
"log"
"testing"
)
func TestNGramLength(t *testing.T) {
type Case struct {
Input string
Length int
}
cases := []Case{
{"a b c", 3},
{" xyz\nlkj dflaj a", 4},
{"a", 1},
{" a", 1},
{"a", 1},
{" a\n", 1},
{" a ", 1},
{"\tx\ny\nz q ", 4},
}
for _, tc := range cases {
length := ngramLength(tc.Input)
if length != tc.Length {
log.Fatalf("%s: %d != %d", tc.Input, length, tc.Length)
}
}
}