DS17
Q. 1) Write a Java Script Program to show Hello Good Morning message onload event using alert box
and display the Student registration from. [Marks 15]
function showRegistrationForm() {
document.getElementById("registrationForm").style.display = "block";
}
</script>
<button onclick="showRegistrationForm()">Show Registration Form</button>
</body> </html>Q. 2)Consider text paragraph.So, keep working. Keep striving. Never give up. Fall down seven times, get
up eight. Ease is a greater threat to progress than hardship. Ease is a greater threat to progress than
hardship. So, keep moving, keep growing, keep learning. See you at work.Preprocess the text to remove
any special characters and digits. Generate the summary using extractive summarization process
import re
from nltk.tokenize import sent_tokenize
from nltk.corpus import stopwords
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.metrics.pairwise import cosine_similarity
Text paragraph
text = """
So, keep working. Keep striving. Never give up. Fall down seven times, get up eight.
Ease is a greater threat to progress than hardship. Ease is a greater threat to progress than hardship.
So, keep moving, keep growing, keep learning. See you at work.
"""
Preprocess the text to remove special characters and digits
processed_text = re.sub(r'\W+', ' ', text) # Remove special characters
processed_text = re.sub(r'\d+', ' ', processed_text) # Remove digits
Tokenize the text into sentences
sentences = sent_tokenize(processed_text)
Remove stopwords
stop_words = set(stopwords.words("english"))
filtered_sentences = [sentence for sentence in sentences if sentence.lower() not in stop_words]
Calculate importance score for each sentence using CountVectorizer and cosine similarity
vectorizer = CountVectorizer().fit_transform(filtered_sentences)
cosine_matrix = cosine_similarity(vectorizer, vectorizer)
Generate summary by selecting top-ranked sentences
summary_length = 2 # Number of sentences in the summary
summary_indices = cosine_matrix.argsort()[::-1][:summary_length] # Indices of top-ranked sentences
summary = [filtered_sentences[i] for i in sorted(summary_indices)]
Print the summary
print("\n".join(summary))