vaderSentimentScores — Score tokenized documents with VADER-style sentiment rules.
vaderSentimentScores(documents) returns a compound sentiment score for each English tokenizedDocument. [compoundScores,positiveScores,negativeScores,neutralScores] = vaderSentimentScores(___) also returns positive, negative, and neutral proportions.
Syntax
compoundScores = vaderSentimentScores(documents)
compoundScores = vaderSentimentScores(documents,Name,Value)
[compoundScores,positiveScores,negativeScores,neutralScores] = vaderSentimentScores(___)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
documents | Any | Yes | — | tokenizedDocument object. |
NameValue | Any | Variadic | — | Name-value options: SentimentLexicon, Boosters, Dampeners, Negations. |
Returns
| Name | Type | Description |
|---|---|---|
compoundScores | NumericArray | Compound VADER-style sentiment score for each document. |
positiveScores | NumericArray | Positive sentiment proportions. |
negativeScores | NumericArray | Negative sentiment proportions. |
neutralScores | NumericArray | Neutral token proportions. |
Returned values from vaderSentimentScores depend on how many outputs the caller requests.
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:vaderSentimentScores:InvalidInput | Inputs do not match supported vaderSentimentScores forms. | vaderSentimentScores: invalid input |
How vaderSentimentScores works
documentsmust be a RunMattokenizedDocumentcompatibility object with English language metadata.- Compound scores are normalized to the range [-1, 1] from token sentiment values after applying booster, dampener, negation, capitalization, and punctuation modifiers.
SentimentLexiconaccepts a RunMat table with lowercase stringTokenvalues and numericSentimentScorevalues in the documented range [-4, 4].BoostersandDampenersaccept string, character, cell, or string-array inputs. Column vectors are treated as word lists; multi-column string arrays are treated as row-wise n-grams with empty padding ignored.Negationsaccepts string, character, cell, or string-array word lists.- RunMat ships a compact built-in English compatibility lexicon and modifier lists for common scripts and examples. For domain-specific or full-coverage scoring, pass an explicit
SentimentLexicontable. - The default lexicon is not yet the complete MATLAB/VADER lexicon, and exact MATLAB VADER scoring parity remains tracked by the broader Text Analytics compatibility issue.
GPU memory and residency
vaderSentimentScores operates on host tokenizedDocument objects and has no provider-resident kernel.
Examples
Score Tokenized Documents
documents = tokenizedDocument(["The book was VERY good!!!!"; "The book was not very good."]);
compoundScores = vaderSentimentScores(documents)Expected output:
`compoundScores` is a numeric column vector with one score per document.Return Sentiment Proportions
[compoundScores,positiveScores,negativeScores,neutralScores] = vaderSentimentScores(documents)Expected output:
Each output is a numeric column vector with one value per document.Use a Custom Lexicon
tbl = table(["innovative"; "risk"], [4; -3], "VariableNames", ["Token", "SentimentScore"]);
compoundScores = vaderSentimentScores(documents, "SentimentLexicon", tbl)Expected output:
The custom table replaces the built-in compact lexicon.Using vaderSentimentScores with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how vaderSentimentScores changes the result.
Run a small vaderSentimentScores example, explain the result, then change one input and compare the output.
FAQ
Does RunMat include MATLAB's full default VADER lexicon?⌄
Not yet. The builtin includes a compact default compatibility lexicon and fully supports custom lexicon tables.
Are booster, dampener, and negation options supported?⌄
Yes. Boosters, Dampeners, and Negations are parsed and applied to preceding sentiment-bearing tokens.
Does vaderSentimentScores execute on the GPU?⌄
No. It performs host text/object processing and returns host numeric score vectors.
Related Strings functions
Text Analytics
addDependencyDetails · addEntityDetails · addLemmaDetails · addPartOfSpeechDetails · addSentenceDetails · addTypeDetails · bagOfNgrams · bagOfWords · cosineSimilarity · doc2sequence · encode · extractFileText · extractHTMLText · fastTextWordEmbedding · findElement · getAttribute · htmlTree · ind2word · isVocabularyWord · normalizeWords · readWordEmbedding · removeLongWords · removeShortWords · removeStopWords · removeWords · stopWords · tokenDetails · tokenizedDocument · trainWordEmbedding · vec2word · word2ind · word2vec · wordEncoding · writeWordEmbedding
Transform
append · deblank · erase · eraseBetween · erasePunctuation · eraseURLs · extractAfter · extractBefore · extractBetween · insertAfter · insertBefore · join · lower · pad · replace · replaceBetween · reverse · split · splitlines · strcat · strip · strjoin · strjust · strrep · strsplit · strtrim · upper
Core
blanks · char · compose · convertCharsToStrings · convertContainedStringsToChars · convertStringsToChars · genvarname · int2str · isletter · isspace · isStringScalar · isstrprop · mat2str · native2unicode · newline · num2str · sprintf · sscanf · str2double · str2num · strcmp · strcmpi · string · string.empty · strings · strlength · strncmp · strncmpi · strtok · unicode2native
Search
contains · endsWith · matches · startsWith · strfind
Pattern
digitsPattern · lettersPattern · pattern · regexpPattern · textBoundary · wildcardPattern
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how vaderSentimentScores is executed, line by line, in Rust.
- View the source for vaderSentimentScores in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.