Documentation
¶
Overview ¶
Package lextoken provides the canonical query tokenizer and identifier splitter for go-code. It is a leaf package (stdlib-only, no internal imports) consumed by both internal/analyze and internal/embeddings.
Three previously divergent sites are collapsed here:
- splitIdentifier/splitCamelCase (analyze/context.go) → SplitIdentifier/SplitCamelCase
- extractQueryTerms (analyze/context.go) → Tokenize
- extractKeywordsForBoost (analyze/rank.go) and ExtractQueryKeywords (embeddings/store_keyword.go) — byte-identical logic → KeywordTokenize
Stopword decision: analyze/rank.go and embeddings/store_keyword.go had byte-identical stopword sets. They are unified into one canonical set here. coupling/symbols.go:stopTokens is a different domain (HTTP-literal dedup) and is NOT touched by this package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterStopwords ¶
FilterStopwords returns a copy of terms with stopwords removed. Returns nil when input is nil (preserves nil-vs-empty distinction).
func IsStopword ¶
IsStopword reports whether word is in the canonical stopword set.
func KeywordTokenize ¶
KeywordTokenize splits a natural-language query into meaningful search terms by:
- Lowercasing and splitting on non-alphanumeric characters.
- Keeping terms ≥ 3 characters.
- Filtering canonical stopwords (IsStopword).
- Deduplicating.
It does NOT perform identifier splitting (use Tokenize for that). Mirrors the byte-identical logic from analyze/rank.go:286 (extractKeywordsForBoost) and embeddings/store_keyword.go:76 (ExtractQueryKeywords).
func SplitCamelCase ¶
SplitCamelCase splits a camelCase or PascalCase identifier into lowercase subwords. Subwords shorter than 2 characters are dropped. Mirrors analyze/context.go:138 (splitCamelCase).
func SplitIdentifier ¶
SplitIdentifier splits an identifier on underscores, then splits each part by camelCase. Empty parts (from leading/trailing/double underscores) are skipped. Mirrors analyze/context.go:186 (splitIdentifier).
func Tokenize ¶
Tokenize splits a natural-language or identifier query into lowercase alphanumeric terms for symbol matching. It:
- Lowercases and strips non-alphanumeric characters from each word.
- Keeps terms ≥ 3 characters.
- Also runs identifier splitting (SplitIdentifier) on each word, adding the resulting subwords as additional terms.
- Deduplicates across both passes.
NOTE: Tokenize does NOT filter stopwords — it is used in analyze/context.go where stopwords are intentional query signals (e.g. "what", "are"). Use KeywordTokenize for stopword-filtered keyword extraction.
Mirrors analyze/context.go:202 (extractQueryTerms).
Types ¶
This section is empty.