`;
+ analysisDiv.appendChild(sentimentBar);
+}
+
+function analyzeSentiment(text) {
+ const positiveWords = ["happy", "joy", "excited", "love"];
+ const negativeWords = ["sad", "angry", "fear", "hate"];
+ let score = 0;
+ let positiveCount = 0;
+ let negativeCount = 0;
+
+ text.split(/\W+/).forEach(word => {
+ if (positiveWords.includes(word.toLowerCase())) {
+ score++;
+ positiveCount++;
+ }
+ if (negativeWords.includes(word.toLowerCase())) {
+ score--;
+ negativeCount++;
+ }
+ });
+
+ const total = positiveCount + negativeCount;
+ const positivePercentage = total ? (positiveCount / total) * 100 : 0;
+ const negativePercentage = total ? (negativeCount / total) * 100 : 0;
+
+ return {
+ text: score > 0 ? 'Positive' : score < 0 ? 'Negative' : 'Neutral',
+ positivePercentage,
+ negativePercentage
+ };
+}
+
+function categorizeDream(text) {
+ const keywords = {
+ "Adventure": ["explore", "travel", "journey"],
+ "Nightmare": ["chase", "fear", "dark"],
+ "Fantasy": ["magic", "fly", "unicorn"],
+ };
+
+ for (const [category, words] of Object.entries(keywords)) {
+ if (words.some(word => text.toLowerCase().includes(word))) {
+ return category;
+ }
+ }
+
+ return "Uncategorized";
+}
+
+function storeDream(dream) {
+ const dreams = JSON.parse(localStorage.getItem('dreams')) || [];
+ dreams.push(dream);
+ localStorage.setItem('dreams', JSON.stringify(dreams));
+}
+
+function displayPastDreams() {
+ const dreams = JSON.parse(localStorage.getItem('dreams')) || [];
+ const pastDreamsDiv = document.getElementById('pastDreams');
+ pastDreamsDiv.innerHTML = '';
+
+ dreams.forEach(dream => {
+ const dreamElement = document.createElement('div');
+ dreamElement.classList.add('dream');
+
+ const titleElement = document.createElement('h3');
+ titleElement.textContent = dream.title;
+ dreamElement.appendChild(titleElement);
+
+ const dateElement = document.createElement('p');
+ dateElement.textContent = `Date: ${dream.date}`;
+ dreamElement.appendChild(dateElement);
+
+ const entryElement = document.createElement('p');
+ entryElement.textContent = dream.entry;
+ dreamElement.appendChild(entryElement);
+
+ const emotionsElement = document.createElement('p');
+ emotionsElement.textContent = `Emotions: ${dream.emotions.join(', ')}`;
+ dreamElement.appendChild(emotionsElement);
+
+ pastDreamsDiv.appendChild(dreamElement);
+ });
}
+
+// Load past dreams on page load
+document.addEventListener('DOMContentLoaded', displayPastDreams);
From cdac407c933ff5f58fb8e9344fd2b2c2587fe909 Mon Sep 17 00:00:00 2001
From: Ananya Gupta <145869907+ananyag309@users.noreply.github.com>
Date: Fri, 28 Jun 2024 16:04:11 +0530
Subject: [PATCH 6/7] Update styles.css
---
Dream Journal Calculator/styles.css | 35 +++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/Dream Journal Calculator/styles.css b/Dream Journal Calculator/styles.css
index 0ad3b43e..d9d2446c 100644
--- a/Dream Journal Calculator/styles.css
+++ b/Dream Journal Calculator/styles.css
@@ -46,3 +46,38 @@ button:hover {
#wordCloud {
margin: 0 auto;
}
+
+.dream {
+ border-bottom: 1px solid #ccc;
+ padding: 10px 0;
+}
+
+.dream h3 {
+ margin: 0;
+}
+
+.dream p {
+ margin: 5px 0;
+}
+
+.sentiment-bar {
+ display: flex;
+ height: 20px;
+ margin-top: 10px;
+ position: relative;
+ background-color: #e0e0e0;
+}
+
+.sentiment-positive {
+ background-color: green;
+ text-align: center;
+ color: white;
+ line-height: 20px;
+}
+
+.sentiment-negative {
+ background-color: red;
+ text-align: center;
+ color: white;
+ line-height: 20px;
+}
From c705717b7667521d5d5160e71dc412652a55ec71 Mon Sep 17 00:00:00 2001
From: Ananya Gupta <145869907+ananyag309@users.noreply.github.com>
Date: Fri, 28 Jun 2024 16:04:48 +0530
Subject: [PATCH 7/7] Add files via upload
---
Dream Journal Calculator/README.md | 58 ++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
create mode 100644 Dream Journal Calculator/README.md
diff --git a/Dream Journal Calculator/README.md b/Dream Journal Calculator/README.md
new file mode 100644
index 00000000..1969c52b
--- /dev/null
+++ b/Dream Journal Calculator/README.md
@@ -0,0 +1,58 @@
+# Dream Journal Calculator
+
+The Dream Journal Calculator is a web application that allows users to record their dreams, analyze the content, and visualize the emotions associated with the dream. It also provides a sentiment analysis to determine whether the dream was positive or negative.
+
+## Features
+
+- Record dream entries with title, date, description, and emotions.
+- Generate a word cloud from the dream description.
+- Analyze and display recurring words and emotions.
+- Sentiment analysis to determine the positivity or negativity of the dream.
+- Categorize the dream based on specific keywords.
+- Store and display past dreams.
+- Reset button to clear the form and results.
+
+## Input Fields
+
+1. **Dream Title**: A short title for the dream.
+2. **Date**: The date when the dream occurred.
+3. **Dream Entry**: A detailed description of the dream.
+4. **Emotions**: Comma-separated list of emotions felt during the dream.
+
+## Output
+
+1. **Word Cloud**: Visual representation of the most frequently occurring words in the dream description.
+2. **Recurring Words**: List of words that appear multiple times in the dream description.
+3. **Emotions**: List of emotions associated with the dream.
+4. **Sentiment Analysis**: Displays whether the dream is positive, negative, or neutral.
+5. **Sentiment Bar**: Visual bar showing the percentage of positive and negative words in the dream.
+6. **Category**: Categorization of the dream based on specific keywords.
+7. **Past Dreams**: List of previously recorded dreams with details.
+
+## How to Use
+
+1. Fill in the form with your dream details:
+ - **Dream Title**: Enter a title for your dream.
+ - **Date**: Select the date of the dream.
+ - **Dream Entry**: Write a detailed description of your dream.
+ - **Emotions**: List the emotions you felt during the dream, separated by commas.
+
+2. Click the "Analyze Dream" button to analyze your dream.
+
+3. View the results:
+ - The word cloud will display the most frequently occurring words in your dream description.
+ - Recurring words and emotions will be listed below the word cloud.
+ - Sentiment analysis will show whether the dream is positive, negative, or neutral.
+ - A sentiment bar will visually represent the percentage of positive and negative words.
+ - The category of the dream will be displayed based on specific keywords.
+ - Past dreams will be listed below the analysis.
+
+4. Click the "Reset" button to clear the form and results.
+
+## Technologies Used
+
+- HTML
+- CSS
+- JavaScript
+- WordCloud2.js (for generating word clouds)
+