llmverify
Version:
AI Output Verification Toolkit — Local-first LLM safety, hallucination detection, PII redaction, prompt injection defense, and runtime monitoring. Zero telemetry. OWASP LLM Top 10 aligned.
54 lines (53 loc) • 1.47 kB
TypeScript
/**
* Classification Engine Utilities
*
* Shared helper functions for classification.
*
* @module engines/classification/utils
* @author Haiec
* @license MIT
*/
/**
* Clamps a value between min and max.
*/
export declare function clamp(value: number, min: number, max: number): number;
/**
* Computes Shannon entropy of text.
*/
export declare function computeEntropy(text: string): number;
/**
* Tokenizes text into words.
*/
export declare function tokenize(text: string): string[];
/**
* Counts sentences in text.
*/
export declare function countSentences(text: string): number;
/**
* Counts bullet points/list items in text.
*/
export declare function countBullets(text: string): number;
/**
* Common English stopwords.
*/
export declare const STOPWORDS: Set<string>;
/**
* Extracts capitalized tokens (potential entities).
*/
export declare function extractCapitalizedTokens(text: string): Set<string>;
/**
* Computes word frequency excluding stopwords.
*/
export declare function computeWordFrequency(text: string): Map<string, number>;
/**
* Gets the most frequent word count.
*/
export declare function getMaxWordFrequency(text: string): number;
/**
* Checks if text contains any of the patterns (case-insensitive).
*/
export declare function containsAny(text: string, patterns: string[]): boolean;
/**
* Counts how many patterns are found in text.
*/
export declare function countMatches(text: string, patterns: string[]): number;