vaderSentimentScores — Score English tokenized documents with VADER-style rules.
vaderSentimentScores returns compound and optional positive, negative and neutral host scores for English tokenizedDocument inputs.
Syntax
compoundScores = vaderSentimentScores(documents)
compoundScores = vaderSentimentScores(documents,Name,Value)
[compoundScores,positiveScores,negativeScores,neutralScores] = vaderSentimentScores(___)Inputs
documents- Type
Any- Required
- Yes
- Description
- tokenizedDocument object.
NameValue- Type
Any- Required
- Variadic
- Description
- Name-value options: SentimentLexicon, Boosters, Dampeners, Negations.
Returns
compoundScores- Type
NumericArray- Description
- Compound VADER-style sentiment score for each document.
positiveScores- Type
NumericArray- Description
- Positive sentiment proportions.
negativeScores- Type
NumericArray- Description
- Negative sentiment proportions.
neutralScores- Type
NumericArray- Description
- Neutral token proportions.
Returned values from vaderSentimentScores depend on how many outputs the caller requests.
Errors
RunMat:vaderSentimentScores:InvalidInput- When
- Inputs do not match supported vaderSentimentScores forms.
- Message
vaderSentimentScores: invalid input
Supported forms
compoundScores = vaderSentimentScores(documents)
compoundScores = vaderSentimentScores(documents, Name, Value)
[compoundScores,positiveScores,negativeScores,neutralScores] = vaderSentimentScores(___)
Numeric column vectors with one score per input document.
SentimentLexicon must be a table with Token and SentimentScore variables.
Token entries in a custom lexicon must be nonempty lowercase strings.
SentimentScore entries must be finite single, double, or native integer values in [-4, 4].
Boosters, Dampeners, and Negations must contain at least one word or n-gram when supplied.
Only English tokenizedDocument inputs are accepted.
Inputs and sentiment rules
vaderSentimentScores accepts an English RunMat tokenizedDocument. One output is the compound score; four requested outputs additionally return positive, negative and neutral proportions. Each is a host double column vector with one entry per document.
Compound scores lie in [-1,1] and apply booster, dampener, negation, capitalization and punctuation modifiers to token sentiment. The compact default English lexicon covers common scripts; domain-specific or full-coverage scoring should pass a SentimentLexicon table. Exact MATLAB VADER scoring parity remains open.
SentimentLexicon requires Token and SentimentScore variables. Tokens are nonempty lowercase strings. Scores are finite single, double or any native integer in [-4,4]; integer scores are range-checked exactly before floating computation.
Boosters and Dampeners accept string, character, cell or string-array word lists. Column vectors are word lists; multi-column string arrays are row-wise n-grams with empty padding ignored. Negations accepts the same text forms as word lists. Supplied modifier lists must be nonempty.
Execution
Text and object processing is host-only. Supported resident payloads within the supplied objects may gather through their owner; there is no provider scoring kernel.
Examples
Score tokenized documents
documents = tokenizedDocument(["The book was VERY good!!!!"; "The book was not very good."]); compoundScores = vaderSentimentScores(documents)Expected output:
A double column vector with one score per document.Return sentiment proportions
documents = tokenizedDocument(["good"; "bad"]); [compoundScores,positiveScores,negativeScores,neutralScores] = vaderSentimentScores(documents)Expected output:
Four double column vectors.Use a custom lexicon
documents = tokenizedDocument("innovative risk"); tbl = table(["innovative"; "risk"], [4; -3], "VariableNames", ["Token", "SentimentScore"]); compoundScores = vaderSentimentScores(documents, "SentimentLexicon", tbl)Expected output:
The custom table replaces the compact default 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 VADER lexicon?⌄
Not yet. It includes a compact default lexicon and supports custom SentimentLexicon tables.
Can I provide modifier lists?⌄
Yes. Boosters, Dampeners and Negations are applied to sentiment-bearing tokens.
Does scoring execute on the GPU?⌄
No. Scoring processes host text/object data and returns host double 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
Source you can read
Every RunMat function's source is public. 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 a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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.