Clear old sentiment and confidence values
Browse files- templates/upload.html +12 -88
templates/upload.html
CHANGED
|
@@ -150,10 +150,17 @@
|
|
| 150 |
// Handle Text Analysis
|
| 151 |
$("#text-form").submit(function(event) {
|
| 152 |
event.preventDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
$("#text-progress-bar").parent().show();
|
| 154 |
$("#text-progress-bar").css("width", "50%").text("Processing...");
|
| 155 |
$(".loading").show();
|
| 156 |
-
|
| 157 |
$.ajax({
|
| 158 |
url: "/analyze_text",
|
| 159 |
type: "POST",
|
|
@@ -169,16 +176,16 @@
|
|
| 169 |
}
|
| 170 |
});
|
| 171 |
});
|
| 172 |
-
|
| 173 |
// Handle File Upload
|
| 174 |
$("#upload-form").submit(function(event) {
|
| 175 |
event.preventDefault();
|
| 176 |
let formData = new FormData(this);
|
| 177 |
-
|
| 178 |
$("#upload-progress-bar").parent().show();
|
| 179 |
$("#upload-progress-bar").css("width", "50%").text("Uploading...");
|
| 180 |
$(".loading").show();
|
| 181 |
-
|
| 182 |
$.ajax({
|
| 183 |
url: "/uploader",
|
| 184 |
type: "POST",
|
|
@@ -198,17 +205,7 @@
|
|
| 198 |
});
|
| 199 |
});
|
| 200 |
});
|
| 201 |
-
|
| 202 |
-
window.onload = function() {
|
| 203 |
-
var sentimentElement = document.getElementById('sentiment');
|
| 204 |
-
var confidenceElement = document.getElementById('confidence');
|
| 205 |
-
if (sentimentElement && sentimentElement.textContent.trim() !== "") {
|
| 206 |
-
sentimentElement.classList.remove("hidden");
|
| 207 |
-
confidenceElement.classList.remove("hidden");
|
| 208 |
-
}
|
| 209 |
-
};
|
| 210 |
</script>
|
| 211 |
-
|
| 212 |
|
| 213 |
<!-- File Upload Specifications -->
|
| 214 |
<div class="file-upload-specifications">
|
|
@@ -226,82 +223,9 @@
|
|
| 226 |
<li><strong>Encoding:</strong> UTF-8 encoding is recommended for compatibility.</li>
|
| 227 |
<li><strong>Example:</strong> The first column should be named <code>'review'</code> and contain the review text. Additional columns are optional and will be ignored.</li>
|
| 228 |
</ul>
|
| 229 |
-
<p>If your file does not meet these specifications,
|
| 230 |
-
|
| 231 |
-
<a href="/download-sample">
|
| 232 |
-
<h3>📥 Download Sample Dataset</h3>
|
| 233 |
-
</a>
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
</div>
|
| 238 |
|
| 239 |
-
<script>
|
| 240 |
-
$(document).ready(function() {
|
| 241 |
-
// Handle Text Analysis
|
| 242 |
-
$("#text-form").submit(function(event) {
|
| 243 |
-
event.preventDefault();
|
| 244 |
-
$("#text-progress-bar").parent().show();
|
| 245 |
-
$("#text-progress-bar").css("width", "50%").text("Processing...");
|
| 246 |
-
$(".loading").show();
|
| 247 |
-
|
| 248 |
-
$.ajax({
|
| 249 |
-
url: "/analyze_text",
|
| 250 |
-
type: "POST",
|
| 251 |
-
data: { text: $("#text").val() },
|
| 252 |
-
success: function(response) {
|
| 253 |
-
$("#text-progress-bar").css("width", "100%").text("Done!");
|
| 254 |
-
$(".loading").hide();
|
| 255 |
-
$("#sentiment").text(response.sentiment).attr("class", response.sentiment.toLowerCase()).show();
|
| 256 |
-
},
|
| 257 |
-
error: function(xhr) {
|
| 258 |
-
$("#textError").text("Error: " + xhr.responseJSON.error);
|
| 259 |
-
}
|
| 260 |
-
});
|
| 261 |
-
});
|
| 262 |
-
|
| 263 |
-
// Handle File Upload
|
| 264 |
-
$("#upload-form").submit(function(event) {
|
| 265 |
-
event.preventDefault();
|
| 266 |
-
let formData = new FormData(this);
|
| 267 |
-
|
| 268 |
-
$("#upload-progress-bar").parent().show();
|
| 269 |
-
$("#upload-progress-bar").css("width", "50%").text("Uploading...");
|
| 270 |
-
$(".loading").show();
|
| 271 |
-
|
| 272 |
-
$.ajax({
|
| 273 |
-
url: "/uploader",
|
| 274 |
-
type: "POST",
|
| 275 |
-
data: formData,
|
| 276 |
-
processData: false,
|
| 277 |
-
contentType: false,
|
| 278 |
-
success: function(response) {
|
| 279 |
-
$("#upload-progress-bar").css("width", "100%").text("Done!");
|
| 280 |
-
$(".loading").hide();
|
| 281 |
-
document.open();
|
| 282 |
-
document.write(response);
|
| 283 |
-
document.close();
|
| 284 |
-
},
|
| 285 |
-
error: function() {
|
| 286 |
-
$("#fileError").text("Error: Could not upload file.");
|
| 287 |
-
}
|
| 288 |
-
});
|
| 289 |
-
});
|
| 290 |
-
});
|
| 291 |
-
|
| 292 |
-
window.onload = function() {
|
| 293 |
-
var sentimentElement = document.getElementById('sentiment');
|
| 294 |
-
if (sentimentElement) {
|
| 295 |
-
var sentiment = sentimentElement.textContent.trim().toLowerCase();
|
| 296 |
-
if (sentiment === 'positive') {
|
| 297 |
-
sentimentElement.className = 'positive';
|
| 298 |
-
} else if (sentiment === 'negative') {
|
| 299 |
-
sentimentElement.className = 'negative';
|
| 300 |
-
}
|
| 301 |
-
}
|
| 302 |
-
};
|
| 303 |
-
</script>
|
| 304 |
-
|
| 305 |
<div class="footer">
|
| 306 |
Project by Philip Obiorah & Supervised by: Prof. Hongbo Du<br>
|
| 307 |
Submitted to the University of Buckingham, in partial fulfilment of the requirements for the degree of Master of Science in Applied Data Science.<br>
|
|
|
|
| 150 |
// Handle Text Analysis
|
| 151 |
$("#text-form").submit(function(event) {
|
| 152 |
event.preventDefault();
|
| 153 |
+
|
| 154 |
+
// Clear old sentiment and confidence values
|
| 155 |
+
$("#sentiment").text("").hide();
|
| 156 |
+
$("#confidence").text("").hide();
|
| 157 |
+
$("#textError").text("");
|
| 158 |
+
|
| 159 |
+
// Show progress bar
|
| 160 |
$("#text-progress-bar").parent().show();
|
| 161 |
$("#text-progress-bar").css("width", "50%").text("Processing...");
|
| 162 |
$(".loading").show();
|
| 163 |
+
|
| 164 |
$.ajax({
|
| 165 |
url: "/analyze_text",
|
| 166 |
type: "POST",
|
|
|
|
| 176 |
}
|
| 177 |
});
|
| 178 |
});
|
| 179 |
+
|
| 180 |
// Handle File Upload
|
| 181 |
$("#upload-form").submit(function(event) {
|
| 182 |
event.preventDefault();
|
| 183 |
let formData = new FormData(this);
|
| 184 |
+
|
| 185 |
$("#upload-progress-bar").parent().show();
|
| 186 |
$("#upload-progress-bar").css("width", "50%").text("Uploading...");
|
| 187 |
$(".loading").show();
|
| 188 |
+
|
| 189 |
$.ajax({
|
| 190 |
url: "/uploader",
|
| 191 |
type: "POST",
|
|
|
|
| 205 |
});
|
| 206 |
});
|
| 207 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
</script>
|
|
|
|
| 209 |
|
| 210 |
<!-- File Upload Specifications -->
|
| 211 |
<div class="file-upload-specifications">
|
|
|
|
| 223 |
<li><strong>Encoding:</strong> UTF-8 encoding is recommended for compatibility.</li>
|
| 224 |
<li><strong>Example:</strong> The first column should be named <code>'review'</code> and contain the review text. Additional columns are optional and will be ignored.</li>
|
| 225 |
</ul>
|
| 226 |
+
<p>If your file does not meet these specifications, the analysis may not be performed correctly.</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
</div>
|
| 228 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
<div class="footer">
|
| 230 |
Project by Philip Obiorah & Supervised by: Prof. Hongbo Du<br>
|
| 231 |
Submitted to the University of Buckingham, in partial fulfilment of the requirements for the degree of Master of Science in Applied Data Science.<br>
|