Professional Documents
Culture Documents
● Software requirements:
Python Programming Language [Jupiter Notebook/Google Colab]
● Theory:
The cryptarithmetic problem is a constraint satisfaction problem where the goal
is to assign digits to letters satisfying an arithmetic equation. The solution involves
propagating constraints and making educated guesses, with heuristics like preferring
letters with fewer possible values. The output is (SEND, MORE, MONEY): (9567,
1085, 10652).
● Code (Handwritten):
def solve_cryptarithmetic():
# Define the letters and their possible values
letters = ['S', 'E', 'N', 'D', 'M', 'O', 'R', 'Y']
digits = range(10)
return None
# Print output
if solution:
print('(SEND, MORE, MONEY):', (solution['SEND'], solution['MORE'],
solution['MONEY']))
else:
print("No solution found.")
● Output (Screenshot)
● Software requirements:
Python Programming Language
● Theory:
Regular expressions, or regex, are crucial in Python for pattern matching and text
manipulation. They aid in tasks like text reading, analysis, pre-processing, classification,
and exploratory data analysis. The NLTK library in Python allows developers to
efficiently perform these tasks, enhancing the capabilities of NLTK and creating robust
NLP pipelines for various applications.
● Code (Handwritten):
text = "The quick brown fox jumps over the lazy dog, exploring the lush green forest
with curious eyes."
# Text Reading
print("Text Reading:")
print(text)
# Text Pre-processing
print("\nText Pre-processing:")
# Convert text to lowercase
# Tokenize text
tokens = word_tokenize(text_clean)
# Remove stopwords
stop_words = set(stopwords.words("english"))
filtered_tokens = [word for word in tokens if word not in stop_words]
# Sentence tokenization
sentences = nltk.sent_tokenize(text)
print("Number of sentences:", len(sentences))
# Stemming
print("\nStemming:")
porter = PorterStemmer()
stemmed_words = [porter.stem(word) for word in filtered_tokens]
print(stemmed_words)
# Lemmatization
print("\nLemmatization:")
lemmatizer = WordNetLemmatizer()
lemmatized_words = [lemmatizer.lemmatize(word) for word in filtered_tokens]
print(lemmatized_words)
● Output:
● Conclusion: Regular expressions are crucial for Python's Natural Language Processing
(NLTK) tasks, enabling efficient text reading, analysis, pre-processing, classification,
EDA, stemming, and lemmatization. They enable pattern identification, tokenization,
and linguistic feature identification, enhancing the efficiency and accuracy of text
processing workflows.