Nodes/Bjornulf_custom_nodes/๐Ÿ“Š๐Ÿ” Text Analyzer
ComfyUI Node

๐Ÿ“Š๐Ÿ” Text Analyzer

Word counts, language, and sentiment out of one node

By justUmenยทCreated 2 years agoยทUpdated about a year agoยท 545
๐Ÿ“Š๐Ÿ” Text Analyzer
    • number_lines
    • number_words
    • number_characters
    • language
    • sentiment
    • sentiment_polarity
    • type
    • character
    • sentence
    • subject
    • action
    • target
    โ—„textโ€”โ–บ

    There are two very different reasons you'd reach for this node, and the README is upfront about both. The boring, practical one: recover the character count of a prompt so you can gate it before it triggers an out-of-memory error somewhere downstream. The more interesting one: run actual language and sentiment analysis on a block of text - say, dialogue you're about to feed to a text-to-speech node - so you can automatically route a happy line to one voice and an angry line to another instead of tagging everything by hand.

    How it works

    This node does real NLP, not just string counting, which is why the pack's requirements.txt pulls in langdetect, spacy, and textblob specifically for it. Feed it a block of text and it hands back basic counts (lines, words, characters) alongside a detected language, a sentiment label with a numeric sentiment_polarity score, and a set of fields that look like a lightweight sentence parse - type, character, sentence, subject, action, target. The README's own framing is that these later fields are aimed at dialogue: figuring out who's speaking, what they're doing, and to whom, which is the exact information you'd want if you're driving character voices or expressions automatically from a script rather than a single flat prompt.

    The inputs and outputs that matter

    • text (STRING, multiline) - the block of text to analyze. That's the only input.
    • Outputs: number_lines, number_words, number_characters (INT) - the counts most people reach for first, useful as a guardrail against overly long prompts. language (STRING) - auto-detected. sentiment (STRING) and sentiment_polarity (FLOAT) - a label plus the underlying numeric score, useful for routing text-to-speech voice selection by mood. type, character, sentence, subject, action, target (STRING) - a rough dialogue/sentence breakdown, most relevant when your input is a line of dialogue rather than a plain image prompt.

    How to install it

    Via ComfyUI Manager: search Bjornulf_custom_nodes, install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/justUmen/Bjornulf_custom_nodes
    cd Bjornulf_custom_nodes && pip install -r requirements.txt
    

    then restart ComfyUI. This is one of the few nodes in the pack where requirements.txt actually matters directly to you - langdetect, spacy, and textblob are what power the language and sentiment fields, so if this node errors out on those specific outputs right after install, that's the dependency to check first.

    Common issues & troubleshooting

    Language or sentiment fields error, but the counts work fine. That split is a good diagnostic: the count fields (number_lines/words/characters) are plain string math and need nothing extra, while language and sentiment depend on langdetect and textblob actually being installed and importable. If those two work but the NLP fields don't, re-run pip install -r requirements.txt inside the pack's folder and confirm it landed in the same Python environment ComfyUI is actually using.

    spacy needs a model, not just the library. A bare pip install spacy gives you the library but not a trained language model to parse with - some spacy-based features need a model downloaded separately (python -m spacy download en_core_web_sm or similar). If the subject/action/target fields come back empty or wrong on text that clearly has structure, this is the first thing to check.

    Sentiment polarity looks off on short or sarcastic text. textblob's sentiment scoring is a straightforward lexicon-based method, not a large language model - it does fine on plain, literal sentences and can misread sarcasm, very short fragments, or slang. Don't expect nuanced sentiment out of a single word or two.

    CategoryBjornulf

    Inputs (1)

    NameTypeDefaultDescription
    textSTRINGโ€”

    Outputs (12)

    NameTypeDescription
    number_linesINTโ€”
    number_wordsINTโ€”
    number_charactersINTโ€”
    languageSTRINGโ€”
    sentimentSTRINGโ€”
    sentiment_polarityFLOATโ€”
    typeSTRINGโ€”
    characterSTRINGโ€”
    sentenceSTRINGโ€”
    subjectSTRINGโ€”
    actionSTRINGโ€”
    targetSTRINGโ€”