MCPcopy
hub / github.com/dgraph-io/dgraph / BuildTokens

Function BuildTokens

tok/tok.go:110–120  ·  view source on GitHub ↗

BuildTokens tokenizes a value, creating strings that can be used to create index keys.

(val interface{}, t Tokenizer)

Source from the content-addressed store, hash-verified

108// BuildTokens tokenizes a value, creating strings that can be used to create
109// index keys.
110func BuildTokens(val interface{}, t Tokenizer) ([]string, error) {
111 tokens, err := t.Tokens(val)
112 if err != nil {
113 return nil, err
114 }
115 id := t.Identifier()
116 for i := range tokens {
117 tokens[i] = encodeToken(tokens[i], id)
118 }
119 return tokens, nil
120}
121
122func BuildNGramQueryTokens(val interface{}, t NGramTokenizer) ([]string, error) {
123 tokens, err := t.QueryTokens(val)

Callers 15

validateMutationFunction · 0.92
addIndexMapEntriesMethod · 0.92
conflictKeysForNQuadMethod · 0.92
tokenizeValueFunction · 0.92
parseSrcFnFunction · 0.92
getInequalityTokensFunction · 0.92
indexTokensFunction · 0.92
BenchmarkNGramTokenizerFunction · 0.85
TestFullTextTokenizerFunction · 0.85
TestHourTokenizerFunction · 0.85
TestDayTokenizerFunction · 0.85
TestMonthTokenizerFunction · 0.85

Calls 3

encodeTokenFunction · 0.85
TokensMethod · 0.65
IdentifierMethod · 0.65

Tested by 15

BenchmarkNGramTokenizerFunction · 0.68
TestFullTextTokenizerFunction · 0.68
TestHourTokenizerFunction · 0.68
TestDayTokenizerFunction · 0.68
TestMonthTokenizerFunction · 0.68
TestDateTimeTokenizerFunction · 0.68
TestTermTokenizerFunction · 0.68
TestTrigramTokenizerFunction · 0.68