Class: StatisticalUtilityAI
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:89
Interface
IUtilityAI Defines the contract for a comprehensive Utility AI service.
Implements
Constructors
Constructor
new StatisticalUtilityAI(
utilityId?):StatisticalUtilityAI
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:135
Parameters
utilityId?
string
Returns
StatisticalUtilityAI
Properties
utilityId
readonlyutilityId:string
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:90
Implementation of
Methods
analyzeSentiment()
analyzeSentiment(
text,options?):Promise<SentimentResult>
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:460
Parameters
text
string
options?
Returns
Promise<SentimentResult>
Implementation of
calculateReadability()
calculateReadability(
text,options):Promise<ReadabilityResult>
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:607
Parameters
text
string
options
Returns
Promise<ReadabilityResult>
Implementation of
IUtilityAI.calculateReadability
calculateSimilarity()
calculateSimilarity(
text1,text2,options?):Promise<number>
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:392
Parameters
text1
string
text2
string
options?
Returns
Promise<number>
Implementation of
IUtilityAI.calculateSimilarity
checkHealth()
checkHealth():
Promise<{dependencies?:object[];details?:any;isHealthy:boolean; }>
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:664
Returns
Promise<{ dependencies?: object[]; details?: any; isHealthy: boolean; }>
Implementation of
classifyText()
classifyText(
textToClassify,options):Promise<ClassificationResult>
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:290
Parameters
textToClassify
string
options
Returns
Promise<ClassificationResult>
Implementation of
detectLanguage()
detectLanguage(
text,options?):Promise<LanguageDetectionResult[]>
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:521
Detect the language of a text string using trigram frequency analysis.
Uses a Cavnar & Trenkle style algorithm that compares the input text's
trigram frequency profile against pre-computed reference profiles for 20+
languages. Accuracy improves with longer text; passages under 10
characters return 'und' (undetermined).
Parameters
text
string
The input text to analyse.
options?
maxCandidates controls how many ranked results to
return (default 3). The method field is accepted but
only 'n_gram' (the default) is supported by this
statistical implementation.
Returns
Promise<LanguageDetectionResult[]>
Ranked array of { language, confidence } where language is
an ISO 639-1 code (e.g. 'en', 'fr') and confidence is
in the range 0-1.
Implementation of
extractKeywords()
extractKeywords(
textToAnalyze,options?):Promise<string[]>
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:355
Parameters
textToAnalyze
string
options?
Returns
Promise<string[]>
Implementation of
generateNGrams()
generateNGrams(
tokens,options):Promise<Record<number,string[][]>>
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:586
Parameters
tokens
string[]
options
Returns
Promise<Record<number, string[][]>>
Implementation of
initialize()
initialize(
config):Promise<void>
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:147
Parameters
config
Returns
Promise<void>
Implementation of
loadTrainedModel()
loadTrainedModel(
modelId,modelType?,storagePath?):Promise<{message?:string;success:boolean; }>
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:744
Parameters
modelId
string
modelType?
string
storagePath?
string
Returns
Promise<{ message?: string; success: boolean; }>
Implementation of
normalizeText()
normalizeText(
text,options?):Promise<string>
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:542
Parameters
text
string
options?
Returns
Promise<string>
Implementation of
parseJsonSafe()
parseJsonSafe<
T>(jsonString,options?):Promise<T|null>
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:787
Safely parses a string that is expected to be JSON, potentially using an LLM to fix common issues.
Type Parameters
T
T = any
The expected type of the parsed JSON object.
Parameters
jsonString
string
The string to parse.
options?
Options for parsing and fixing.
Returns
Promise<T | null>
The parsed object, or null if parsing and fixing fail.
Implementation of
saveTrainedModel()
saveTrainedModel(
modelId,modelType?,storagePath?):Promise<{message?:string;pathOrStoreId?:string;success:boolean; }>
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:716
Parameters
modelId
string
modelType?
string
storagePath?
string
Returns
Promise<{ message?: string; pathOrStoreId?: string; success: boolean; }>
Implementation of
shutdown()
shutdown():
Promise<void>
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:803
Returns
Promise<void>
Implementation of
stemTokens()
stemTokens(
tokens,options?):Promise<string[]>
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:386
Parameters
tokens
string[]
options?
Returns
Promise<string[]>
Implementation of
summarize()
summarize(
textToSummarize,options?):Promise<string>
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:263
Parameters
textToSummarize
string
options?
Returns
Promise<string>
Implementation of
tokenize()
tokenize(
text,options?):Promise<string[]>
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:368
Parameters
text
string
options?
Returns
Promise<string[]>
Implementation of
trainModel()
trainModel(
trainingData,modelType,trainingOptions?):Promise<{message?:string;modelId?:string;success:boolean; }>
Defined in: packages/agentos/src/nlp/ai_utilities/StatisticalUtilityAI.ts:680
Parameters
trainingData
object[]
modelType
string
trainingOptions?
alpha?
number
modelId?
string
stemmer?
"porter" | "lancaster"
Returns
Promise<{ message?: string; modelId?: string; success: boolean; }>