Skip to content

Instantly share code, notes, and snippets.

@julienreszka
Last active May 6, 2022 08:36
Show Gist options
  • Select an option

  • Save julienreszka/8f2f747f6319d04e30f3dc3802971064 to your computer and use it in GitHub Desktop.

Select an option

Save julienreszka/8f2f747f6319d04e30f3dc3802971064 to your computer and use it in GitHub Desktop.
function wordFreq(string) {
var words = string.replace(/[.]/g, '').split(/\s/);
var freqMap = {};
words.forEach(function(w) {
if (!freqMap[w]) {
freqMap[w] = 0;
}
freqMap[w] += 1;
});
return Object.keys(freqMap).map(k=>{return {word: k,freq:freqMap[k]}})
.filter((w)=>w.freq > 1)
.sort((a,b)=>b.freq-a.freq);
}
wordFreq(document.body.innerText)
@julienreszka
Copy link
Author

var 100MostCommonWordsInEnglish =[
    "the",
    "be",
    "to",
    "of",
    "and",
    "a",
    "in",
    "that",
    "have",
    "I",
    "it",
    "for",
    "not",
    "on",
    "with",
    "he",
    "as",
    "you",
    "do",
    "at",
    "this",
    "but",
    "his",
    "by",
    "from",
    "they",
    "we",
    "say",
    "her",
    "she",
    "or",
    "an",
    "will",
    "my",
    "one",
    "all",
    "would",
    "there",
    "their",
    "what",
    "so",
    "up",
    "out",
    "if",
    "about",
    "who",
    "get",
    "which",
    "go",
    "me",
    "when",
    "make",
    "can",
    "like",
    "time",
    "no",
    "just",
    "him",
    "know",
    "take",
    "people",
    "into",
    "year",
    "your",
    "good",
    "some",
    "could",
    "them",
    "see",
    "other",
    "than",
    "then",
    "now",
    "look",
    "only",
    "come",
    "its",
    "over",
    "think",
    "also",
    "back",
    "after",
    "use",
    "two",
    "how",
    "our",
    "work",
    "first",
    "well",
    "way",
    "even",
    "new",
    "want",
    "because",
    "any",
    "these",
    "give",
    "day",
    "most",
    "us"
]

@julienreszka
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment