Created
July 13, 2018 17:06
-
-
Save zacharied/ddb779f6e5c32282f8c5eb0f1a648a6e to your computer and use it in GitHub Desktop.
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
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