0

I am making a little project for streamers of Twitch.tv. This program will basically measure the amount of times the word "Kappa" is used, per minute, on the website's chat box. Now I was wondering, what kind of formula could I use to measure the average and the current amount of times the string "Kappa" is used per minute, given that I could test it using console input?

1 Answers1

0

You are looking for a frequency formula : amount_of_occurrence / time_elapsed

Create a counter to register the number or occurrence of "Kappa" ('counter')
Register the current time when you start your program ('start_time')
Each time you want to display the average amount of times your string occurred compute
"counter / (current_time - start_time)"
then multiply the result to get a frequency by minutes (because most of System.time function give time in microseconds or nanoseconds)

A small pseudocode algorithm doing that :

//Initialize
Find your input stream source (chatbox feed)
Initialize the word counter
Create a regular expression matching your word

//Run this function in a loop or trigger it when you get a new message
Match the input with your regex
If you get a positive match
    Increase the counter value
Display counter/time (with time in minutes)
SkyDream
  • 382
  • 1
  • 10