import { stemmer } from "stemmer";
// Domain terms that should NOT be stemmed
export const DOMAIN_TERMS = new Set([
    "fmea", "bom", "api", "uuid", "id", "url", "uri", "json", "xml", "html", "css", "js", "ts"
]);
/**
 * Intelligent Stemming Helper with Domain Protection
 * 1. Checks if token is a protected domain term (returns as-is)
 * 2. Checks length (skips short words <= 2 chars)
 * 3. Applies Porter Stemmer
 */
export function stemToken(token) {
    const lower = token.toLowerCase();
    // Rule 1: Protected Domain Terms
    if (DOMAIN_TERMS.has(lower)) {
        return lower;
    }
    // Rule 2: Skip very short words
    if (lower.length <= 2) {
        return lower;
    }
    // Rule 3: Apply Stemmer
    return stemmer(lower);
}
