How to Generate a Word Cloud from Chat
-
I'm working on a project where I need to parse Zoom chat (which I do using ZoomOSC) and then create a word cloud in real tme based on the most-often mentioned words.
Currently, I'm thinking of using Javascript to do the parsing, but the tricky thing is creating a video output with it. My current method is to have the Javascript count words, and then output the following to a Text Draw actor for each word:
- A font size based on the number of times a word has been detected.
- A random x+y location (built off the center/starting word to ensure it groups like a wordcloud but making sure that the words don't overlap)
- A random rotation (either 0, 90, or 180 degrees)
- A color (sent as an hue value of 0-360 scaled from the least mentions (min) to most mentions (max) so there are more colors present depending on how many words are detected.)
I'm just a bit unsure about this solution because it means I'm limited to a pre-determined number of words (because there needs to be a Text Draw actor for each word).
I'm wondering if maybe there's a way to do it with a GLSL shader so that I'm not limited to the number of Text Draw actors that I pre-create, but I'm not well-enough versed in GLSL Shaders to know if it's an advisable solution.
Any thoughts?
-
@woland if we did not need to vary the sizes I could imagine a 26 layer image (one for each letter in the english alphabet) where words are formed by setting a spot in the checkerboard to display its letter or alpha, allowing you to only need 26 Text draws. you could get the rotation to work with this as well, but the size variations break the system down. Still, I wonder if there is a way to be character centric versus word centric.
-
Personally, I think you are on the right track by limiting the number of words that you use to generate the image.. It only adds a lot of chaos to the image if you decide to go higher than 30 words.. If you also add movement / make other words bigger then others / add color then I think you have plenty of elements to generate a stunning image.
-
You may also want to find a monospace font to use, this way you can calculate the space required for the word, since each letter will take up equal space. That should allow for a grid like layout to become possible. Rotation will be another monster.