Hello!
Tumblr is where tens of millions of creative people around the world share and follow the things they love.
Sign up to find more cool stuff to followInternet Word Usage Frequency
wordcount.orgThis is interesting. A frequency list of Internet words. Don’t know their methodology, but the concept is interesting either way.
How often does a word occur in the Bible or the Quran?
pitchinteractive.comUse this interactive tool to search both holy books and find out.
![]()
The tool allows you to include or exclude various words related to your target term. You can also read the verses in which your words appear. (In fact, you can read all the verses of both books. Each tiny color-coded rectangle represents one verse. Dark rectangles are the verses that contain your search term; light rectangles are the verses that do not.)
The tool is called “The Holy Bible and the Holy Quran: A Comparison of Words” and was developed by Pitch Interactive. (@pitchinteractiv)
Word Frequency Using Python Dictionary (Dict)
The first time I did this, I couldn’t believe it was so simple. Surely, just this much? I’d have to write at least two pages in JAVA.
The Problem: I have to count the number of words in a file.
Let’s say this is my file:
$ cat > file.txt one two two three three three four four four four five five five five five ^C
I have to count the frequency of each word in this file. It’s simple! This is it:
def print_count(words):
for word,frequency in words.items():
print word, ":", frequency
def word_count():
word_frequency_map = {}
for line in open("file.txt","r"):
words = line.rstrip('\r\n').split(" ")
for word in words:
try:
word_frequency_map[word]+=1
except:
word_frequency_map[word]= 1
return word_frequency_map
print_count(word_count())
Note that the output is not necessarily sorted:
$ python wordcounter.py four : 4 three : 3 five : 5 two : 2 one : 1
Underscore JS and Word Frequency!
Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
I decided to put it to the test in a small example of counting the number of words in a passage of text. To demonstrate how easy this is with Underscore I put together this little jsfiddle.
Here’s the code :
//get the paragraph of text
var text = $("#text");
//remove any punctuation and replace with whitespace
var removePunctuation = text.text().replace(/[!,?.":;]/g, ' ');
//split the string by whitespace to create the word
// array
var split = removePunctuation.split(" ");
//_Underscore to chain a series of functions
//to reduce the word array to a {word,frequency}
var res =
_.chain(split).without('', ' ')
.groupBy(function(word) { return word;})
.sortBy( function(word) { return word.length;})
.value();