const STOPWORDS = /* @__PURE__ */ new Set([
  "the",
  "a",
  "an",
  "what",
  "is",
  "are",
  "was",
  "were",
  "how",
  "why",
  "when",
  "where",
  "who",
  "do",
  "does",
  "did",
  "for",
  "of",
  "to",
  "in",
  "on",
  "with",
  "and",
  "or",
  "but",
  "as",
  "at",
  "by",
  "from",
  "into",
  "about",
  "than",
  "this",
  "that",
  "these",
  "those",
  "it",
  "its",
  "be",
  "been",
  "has",
  "have",
  "had",
  "can",
  "could",
  "should",
  "would",
  "may",
  "might",
  "must",
  "will",
  "shall",
  "i",
  "you",
  "we",
  "they",
  "he",
  "she",
  "them",
  "my",
  "your",
  "our",
  "their",
  "latest",
  "current",
  "newest",
  "recent",
  "best",
  "top",
  "most"
]);
function tokenize(s) {
  return s.toLowerCase().replace(/[^a-z0-9]+/g, " ").split(/\s+/).filter((t) => t.length >= 2 && !STOPWORDS.has(t));
}
function lexicalAlignment(query, title, snippet) {
  const qTokens = new Set(tokenize(query));
  if (qTokens.size === 0) return 0;
  const docTokens = /* @__PURE__ */ new Set();
  for (const t of tokenize(title)) docTokens.add(t);
  for (const t of tokenize(snippet)) docTokens.add(t);
  if (docTokens.size === 0) return 0;
  let overlap = 0;
  for (const t of qTokens) {
    if (docTokens.has(t)) overlap++;
  }
  return overlap / qTokens.size;
}
export {
  lexicalAlignment
};
//# sourceMappingURL=lexical-alignment.js.map