DS19
Q. 1) Write a Java Script Program to validate user name and password on onSubmit event.
[Marks 15]
// Check if username and password are empty
if (username == "" || password == "") {
alert("Username and password are required!");
return false;
}
// Check if username contains only alphanumeric characters
var alphanumeric = /^[a-zA-Z0-9]+$/;
if (!username.match(alphanumeric)) {
alert("Username must contain only alphanumeric characters!");
return false;
}
// Check if password length is between 6 and 20 characters
if (password.length < 6 || password.length > 20) {
alert("Password must be between 6 and 20 characters long!");
return false;
}
return true;
}
</script>
Q. 2)Download the movie_review.csv dataset from Kaggle by using the following link
to perform
sentiment analysis on above dataset and create a wordcloud
import pandas as pd
from wordcloud import WordCloud
import matplotlib.pyplot as plt
Read the dataset
df = pd.read_csv("movie_review.csv")
Perform sentiment analysis (example: assume positive if rating > 5)
df['Sentiment'] = df['Rating'].apply(lambda x: 'positive' if x > 5 else 'negative')
Concatenate all reviews
all_reviews = ' '.join(df['Review'])
Generate wordcloud
wordcloud = WordCloud(width=800, height=400, background_color='white').generate(all_reviews)
Plot wordcloud
plt.figure(figsize=(10, 5))
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis('off')
plt.show()