Hello everyone. Here’s a little introduction to this poetry series.
First off, I’m trying to dedicate each poem to a person and write to that person as I formulate my thoughts.
Secondly, HTML is a great way to embed the dedications for an added treat (the popup).
Third, poetry is freeing and therapeutic. It is my hope that these words exist on the internet for any future eyes to see and ponder.
Today’s poem/post connects with our school, my work, and a new system of reading English, or any other language for that matter.
In the English language, there are nine parts of speech.
Noun,
Verb,
Adjective,
Adverb,
Pronoun,
Conjuntion,
Preposition,
Articles,
and
Interjections (AHHHHH!)
The Color Legend
I hope to create a program/extension/plugin that can scan any text in any language, and color code it accurately based on the language’s parts of speech (syntax mechanics).
However, I am almost 40 years old and trying to learn how to code amidst, well life. 😀
Some help would be greatly appreciated.
The following snippets are my forays into what I’ve produced thus far.
HTML Code without Color
<html>
<body>
<p><span class=”preposition”>Beyond</span> <span class=”article”>the</span> <span class=”noun”>forest</span><span class=”comma”>,</span> <span class=”article”>the</span> <span class=”noun”>troll</span> <span class=”adverb”>menacingly</span> <span class=”verb”>hid</span> <span class=”preposition”>under</span> <span class=”article”>the</span> <span class=”adjective”>rickety</span> <span class=”noun”>bridge</span><span class=”period”>.</span></p>
</body>
</html>
The Output:
Beyond the forest, the troll menacingly hid under the rickety bridge.
HTML Code with Color
<html>
<head>
</head>
<body>
<style>
.App {
width:500px;
border:2px solid black;
border-radius:20px;
background: linear-gradient(#fff 10%, #f1f1f1 98%, #ccc);
padding:0 20px 20px;
font-family: monospace;
}
body {
background:rgb(242, 242, 245);
}
p{color: yellow;
}
span{color: green;
}
span.noun{color: red;
}
span.verb{color: blue;
}
span.adjective{color:orange;
}
span.pronoun{color:yellow;
background:black;
}
span.adverb{color:lightblue;
}
span.conjunction{color:green;
}
span.article{color:black;
}
span.interjection{color: gold;
}
span.period{color:black;
}
span.comma{color:black;
}
</style>
<p><span class="preposition">Beyond</span> <span class="article">the</span> <span class="noun">forest</span><span class="comma">,</span> <span class="article">the</span> <span class="noun">troll</span> <span class="adverb">menacingly</span> <span class="verb">hid</span> <span class="preposition">under</span> <span class="article">the</span> <span class="adjective">rickety</span> <span class="noun">bridge</span><span class="period">.</span></p>
</body>
</html>
The Output with Color
The Next Phase/Improvement (I Think)
// Get a reference to the span elements const prepositionSpan = document.querySelector('.preposition'); const articleSpan = document.querySelector('.article');
const nounSpan = document.querySelector('.noun');
const commaSpan = document.querySelector('.comma');
const adverbSpan = document.querySelector('.adverb');
const verbSpan = document.querySelector('.verb');
const adjectiveSpan = document.querySelector('.adjective');
const periodSpan = document.querySelector('.period');
// Set the innerHTML of each span to the appropriate text
prepositionSpan.innerHTML = 'Beyond';
articleSpan.innerHTML = 'the';
nounSpan.innerHTML = 'forest';
commaSpan.innerHTML = ',';
adverbSpan.innerHTML = 'menacingly';
verbSpan.innerHTML = 'hid';
adjectiveSpan.innerHTML = 'rickety';
periodSpan.innerHTML = '.';
The Homework Poem for ____.
*The Student must use 14 pronouns: subjective and objective forms.
Subjective Pronouns | Objective Pronouns |
I | me |
We | us |
They | them |
He | him |
She | her |
It | it |
You | you |
**For efficiency’s sake and a challenge, I’m going to try to limit the word count as well.
***Please note that objective pronouns have not been capitalized as they are generally not.
****I’m also going to try and use the parts of speech mnemonic for a familiar sentence structure conducive to future patterns.
The Original Mnemonic
Beyond the forest, the troll hid menacingly under the rickety bridge.
Modified
Beyond the city, the Russian man strode confidently through the busy streets.The Poem Based on the above
I was in it (the city).
He was in it.
We saw him.
She went with him.
He learns from her.
They became “us”.
It was nice.
You can join.
I invite you.
Who are the pronouns?
What are the subjects?
What are the objects?
Python
def print_colored_text(text, color):
colors = {
"red": "\033[1;31m",
"blue": "\033[1;34m",
"orange": "\033[1;33m",
"lightblue": "\033[1;36m",
"yellow": "\033[1;32m",
"green": "\033[1;32m",
"brown": "\033[0;33m",
"black": "\033[0;30m",
"purple": "\033[1;35m"
}
print(colors[color] + text + "\033[0m")
text = "Beyond the forest, the troll menacingly hid under the rickety bridge."
parts_of_speech_and_colors = [
("Preposition:", "brown", "Beyond"),
("Article:", "black", "the"),
("Noun:", "red", "forest"),
("Comma:", "not applicable", ","),
("Article:", "black", "the"),
("Noun:", "red", "troll"),
("Adverb:", "lightblue", "menacingly"),
("Verb:", "blue", "hid"),
("Preposition:", "brown", "under"),
("Article:", "black", "the"),
("Adjective:", "orange", "rickety"),
("Noun:", "red", "bridge")
]
for part_of_speech, color, word in parts_of_speech_and_colors:
print_colored_text(part_of_speech, "purple")
print_colored_text(word, color)
print()