Skip to content

Instantly share code, notes, and snippets.

@zacharied
Created July 13, 2018 17:06
Show Gist options
  • Save zacharied/ddb779f6e5c32282f8c5eb0f1a648a6e to your computer and use it in GitHub Desktop.
Save zacharied/ddb779f6e5c32282f8c5eb0f1a648a6e to your computer and use it in GitHub Desktop.
const pos_map = {
"Transitive verb": ['#E03999', "Transitive"],
"Godan verb .*": ['#88F0F0', "Godan verb"],
"Adverb": ['#EEEEEE', "Adverb"]
};
const pos_div = document.getElementById("parts_of_speech");
document.getElementById("pos-temp").innerHTML.split(/\n/).forEach(function(e) {
const keysMatching = Object.keys(pos_map)
.filter(function(key) {
return new RegExp(key).test(e)
});
if (pos_map[keysMatching] !== undefined) {
pos_div.innerHTML += '<span class="pos_badge" style="background:' + pos_map[keysMatching][0] + '">' + pos_map[keysMatching][1] + '</span>';
} else {
pos_div.innerHTML += '<span class="pos_badge">' + e +'</span>';
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment