v2026.6.4
All Bundles
Bundle Natural language processing toolkit. Provides tokenization, text preprocessing, TF-IDF vectorization, cosine similarity, and sentiment analysis. Works with plain strings — no external model required. Compile with -lib nlp.

SentimentAnalyzer

Basic lexicon-based sentiment analysis

Example

text := "This is absolutely wonderful and amazing!";
score := System.NLP.SentimentAnalyzer->Analyze(text);
classification := System.NLP.SentimentAnalyzer->Classify(text);
result := System.NLP.SentimentAnalyzer->AnalyzeDetailed(text);
result->ToString()->PrintLine();

Operations

Analyze # function

Analyzes sentiment of text and returns a sentiment score

function : Analyze(text:String) ~ Int

Parameters

NameTypeDescription
textStringinput text to analyze

Return

TypeDescription
Intsentiment score (positive = positive sentiment, negative = negative sentiment, 0 = neutral)

Example

score := SentimentAnalyzer->Analyze("This product is absolutely wonderful!");
"Score: {$score}"->PrintLine();

AnalyzeDetailed # function

Gets detailed sentiment analysis with scores

function : AnalyzeDetailed(text:String) ~ SentimentResult

Parameters

NameTypeDescription
textStringinput text to analyze

Return

TypeDescription
SentimentResultsentiment result with score and classification

Example

result := SentimentAnalyzer->AnalyzeDetailed("Amazing and wonderful experience!");
result->ToString()->PrintLine();

Classify # function

Classifies text sentiment as positive, negative, or neutral

function : Classify(text:String) ~ String

Parameters

NameTypeDescription
textStringinput text to classify

Return

TypeDescription
Stringsentiment label: "positive", "negative", or "neutral"

Example

label := SentimentAnalyzer->Classify("This is terrible and horrible.");
label->PrintLine();

Init # function

Initializes sentiment lexicons with common positive and negative words

function : Init() ~ Nil