Created
June 12, 2022 10:53
-
-
Save kalisjoshua/ae0e493bd54ef7fea27a4520b5a7f583 to your computer and use it in GitHub Desktop.
Job Posting Keywords
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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