In [ ]:
# Import libraries
import nltk
from collections import Counter
# Download required NLTK data
nltk.download('punkt')
nltk.download('averaged_perceptron_tagger')
nltk.download('averaged_perceptron_tagger_eng')
1. Text Selection and Cleaning¶
In [ ]:
# Original text from the scene
text = """The hobbits stood before the King and all the great assembly.
Aragorn rose from his throne and looked down at them with eyes full of love and pride.
The four hobbits had saved Middle-earth through their courage and friendship.
They had walked through fire and darkness, faced terrible dangers, and never wavered.
Now they stood in the great hall, small among the tall warriors and noble lords.
Aragorn spoke softly but his voice carried to every corner.
My friends, you bow to no one.
Then the King of Gondor knelt before the hobbits, and all the court followed,
bowing low to honor the brave halflings who had carried hope when all seemed lost."""
print("Original Text:")
print(text)
print(f"\nText length: {len(text)} characters")
In [ ]:
# Clean the text - remove extra spaces
import re
cleaned_text = re.sub(r'\s+', ' ', text).strip()
print("Cleaned Text:")
print(cleaned_text)
2. POS Tagging¶
In [ ]:
# Tokenize and perform POS tagging
tokens = nltk.word_tokenize(cleaned_text)
pos_tags = nltk.pos_tag(tokens)
print(f"Total tokens: {len(tokens)}\n")
print("Word\t\t\tPOS Tag")
print("="*50)
for word, tag in pos_tags:
print(f"{word:20} {tag}")
3. POS Frequency Analysis¶
In [ ]:
# Count POS tag frequencies
pos_counts = Counter([tag for word, tag in pos_tags])
print("POS Tag Frequencies:")
print("="*40)
for tag, count in pos_counts.most_common():
print(f"{tag:10} {count:3} times")
print(f"\nTotal unique POS tags: {len(pos_counts)}")
In [ ]:
# Group by major categories
nouns = [word for word, tag in pos_tags if tag.startswith('NN')]
verbs = [word for word, tag in pos_tags if tag.startswith('VB')]
adjectives = [word for word, tag in pos_tags if tag.startswith('JJ')]
adverbs = [word for word, tag in pos_tags if tag.startswith('RB')]
pronouns = [word for word, tag in pos_tags if tag.startswith('PRP')]
determiners = [word for word, tag in pos_tags if tag == 'DT']
prepositions = [word for word, tag in pos_tags if tag == 'IN']
conjunctions = [word for word, tag in pos_tags if tag == 'CC']
total_words = len(tokens)
print("Major POS Categories:")
print("="*50)
print(f"Nouns: {len(nouns):3} ({len(nouns)/total_words*100:5.1f}%)")
print(f"Verbs: {len(verbs):3} ({len(verbs)/total_words*100:5.1f}%)")
print(f"Adjectives: {len(adjectives):3} ({len(adjectives)/total_words*100:5.1f}%)")
print(f"Adverbs: {len(adverbs):3} ({len(adverbs)/total_words*100:5.1f}%)")
print(f"Pronouns: {len(pronouns):3} ({len(pronouns)/total_words*100:5.1f}%)")
print(f"Determiners: {len(determiners):3} ({len(determiners)/total_words*100:5.1f}%)")
print(f"Prepositions: {len(prepositions):3} ({len(prepositions)/total_words*100:5.1f}%)")
print(f"Conjunctions: {len(conjunctions):3} ({len(conjunctions)/total_words*100:5.1f}%)")
4. Analysis and Interpretation¶
In [ ]:
print("="*70)
print("ANALYSIS AND INTERPRETATION")
print("="*70)
print("\n1. DOMINANT POS TYPE:")
print(f" The paragraph is NOUN-HEAVY with {len(nouns)} nouns ({len(nouns)/total_words*100:.1f}%)")
print("\n EXPLANATION:")
print(" - This is typical of narrative prose")
print(" - Focuses on characters: hobbits, King, Aragorn, warriors, lords")
print(" - Emphasizes settings: throne, hall, court, Middle-earth")
print(" - Creates concrete imagery to establish the scene")
print(" - Descriptive storytelling rather than action-focused")
In [ ]:
print("\n2. OBSERVED PATTERNS:")
print("\n a) NOUNS (entities and concepts):")
print(f" {', '.join(nouns)}")
print("\n b) VERBS (actions):")
print(f" {', '.join(verbs)}")
print("\n c) ADJECTIVES (descriptions):")
if adjectives:
print(f" {', '.join(adjectives)}")
print(" - Creates emotional depth and vivid imagery")
print(" - Words like 'great', 'terrible', 'brave', 'noble' convey grandeur")
print(" - Contrasts: 'small' vs 'tall' emphasize the reversal of status")
else:
print(" None found")
print("\n d) ADVERBS (manner):")
if adverbs:
print(f" {', '.join(adverbs)}")
else:
print(" None found")
In [ ]:
# Verb tense analysis
past_verbs = [word for word, tag in pos_tags if tag == 'VBD']
present_verbs = [word for word, tag in pos_tags if tag in ['VBP', 'VBZ']]
past_participle = [word for word, tag in pos_tags if tag == 'VBN']
print("\n3. VERB TENSE DISTRIBUTION:")
print(f" - Past tense: {len(past_verbs)} verbs ({', '.join(set(past_verbs))})")
print(f" - Present tense: {len(present_verbs)} verbs")
print(f" - Past participle: {len(past_participle)} verbs ({', '.join(set(past_participle))})")
print("\n INTERPRETATION:")
print(" - Dominance of past tense indicates narrative storytelling")
print(" - Creates a classic storytelling voice")
print(" - Builds from description to action")
In [ ]:
# Proper nouns
proper_nouns = [word for word, tag in pos_tags if tag in ['NNP', 'NNPS']]
print("\n4. PROPER NOUNS:")
print(f" Found: {', '.join(set(proper_nouns))}")
print(" - Establishes specific characters and places in Tolkien's world")
print(" - Grounds the narrative in the fantasy setting")
In [ ]:
print("\n5. ADDITIONAL OBSERVATIONS:")
print("\n a) NARRATIVE STRUCTURE:")
print(" - Descriptive narrative prose")
print(" - Past tense creates storytelling atmosphere")
print(" - Action sequence: stood → rose → spoke → knelt")
print("\n b) EMOTIONAL TONE:")
print(" - Adjectives create reverence: 'great', 'brave', 'noble'")
print(" - Contrasting imagery: 'small' vs 'tall', 'darkness' vs 'hope'")
print(" - Emotional words: love, pride, courage, honor")
print("\n c) IMAGERY AND DESCRIPTION:")
print(" - Rich in concrete nouns (throne, hall, warriors, lords)")
print(" - Creates visual scene through noun-heavy descriptions")
print(" - Physical positioning emphasized (stood, knelt, bowing)")
print("\n d) THEMATIC ELEMENTS:")
print(" - Reversal of status (King bowing to hobbits)")
print(" - Recognition and honor as central themes")
print(" - Contrast between physical size and moral greatness")
sentences = nltk.sent_tokenize(cleaned_text)
print("\n e) SENTENCE COMPLEXITY:")
print(f" - Total sentences: {len(sentences)}")
print(f" - Average words per sentence: {total_words/len(sentences):.1f}")
print(" - Moderate complexity = accessible yet literary prose")
print("\n f) WRITING STYLE:")
print(" - Balanced nouns and verbs create dynamic description")
print(" - Coordinating conjunctions ('and') link related ideas")
print(" - Prepositions create spatial and relational context")
print(" - Epic, formal narrative style befitting fantasy literature")
Summary¶
Key Findings:¶
- POS Distribution: The passage is noun-heavy, typical of descriptive narrative prose
- Dominant Type: Nouns dominate, establishing characters, settings, and concrete imagery
- Verb Usage: Past tense verbs create storytelling atmosphere and sequential action
- Adjective Pattern: Selective but powerful adjectives create emotional depth and contrast
- Literary Style: Epic, formal narrative with balanced description and action
Interpretation:¶
This passage exemplifies Tolkien's epic fantasy style, using:
- Noun-heavy construction to build vivid scenes and establish characters
- Contrasting imagery (small/tall, darkness/hope) to emphasize themes
- Past tense narrative to create classic storytelling voice
- Selective adjectives that carry emotional and thematic weight
- Formal, elevated language appropriate to the climactic, ceremonial scene
The POS analysis reveals how grammatical structure supports the passage's themes of honor, recognition, and the reversal of expectations central to this iconic moment.