Skip to content

Instantly share code, notes, and snippets.

@kalisjoshua
Created June 12, 2022 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kalisjoshua/ae0e493bd54ef7fea27a4520b5a7f583 to your computer and use it in GitHub Desktop.
Save kalisjoshua/ae0e493bd54ef7fea27a4520b5a7f583 to your computer and use it in GitHub Desktop.
Job Posting Keywords
(function () {
console.clear()
let body = window.getSelection().toString()
const ignored = "able about across and for company more public team the that their they where with work world"
.split(" ")
if (!body) {
alert("You forgot to select the text to search.")
} else {
body = body
.toLowerCase()
.replace(/['’]s|\d+/g, "") // posessives including "smart" apostrophe
.replace(/[^\w]+/g, " ")
.trim()
const counts = body
.split(/\s+/g)
.reduce((a, w) => ({...a, [w]: 1 + (a[w] || 0)}), {})
const words = Array.from(Object.entries(counts))
.sort((a, b) => b[1] - a[1])
.filter(([word, count]) => true
&& word.length >= 3 // longer words
&& count > 1 // words used multiple times
&& !ignored.includes(word)
)
.map(([word]) => word)
console.log(words)
}
}())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment