Word Frequency Counter

Hi guys,

I need to display dynamic data on a page and then have Bubble identify the top 10 keywords from that content and post those words in a list.

Basically I need a word frequency counter mechanism - where the top keywords are automatically detected and counted.

Any ideas how to do this?

Thank you!
P

1 Like

Blockspring has a word counter that would seem to do what you want.

Getting Blockspring to reliably work with Bubble is another matter. Plus it costs a lot for a fairly trivial service.

There are no doubt public APIs that do the same thing, and IMHO it would be better to try to get that working than rely on Blockspring.

2 Likes

I’ve used this bash script for a while (works with most Unices/Linux & Cygwin for Windows):

Save this as ‘wf’ it in your executable path (chmod a+x wf):


#!/bin/bash

# 2016-06-20 ABB Original version.

# Check that at least 1 argument is given
if [ $# -lt 1 ]
then
	echo "Word Frequency Counter"
	echo 
	echo "Usage : wf file-name"
	echo
	echo "-h --h --help -help    This help."
	echo
	exit
fi
cat "${1}" | tr '[:cntrl:]' ' ' | tr '[:punct:]' ' ' | tr '\r' ' ' | tr '[:upper:]' '[:lower:]' | tr ' ' '\n' | tr -s ' ' | sort -b | uniq -c | sort -k1,1rn -k2,2 

On this file:

Peter Piper picked a peck of pickled peppers.
If Peter Piper picked a peck of pickled peppers,
where’s the peck of pickled peppers Peter Piper picked?

Then:

wf peck
4
3 of
3 peck
3 peppers
3 peter
3 picked
3 pickled
3 piper
2 a
1 if
1 s
1 the
1 where