diff --git a/client/analysis.html b/client/analysis.html index e48afce..515ee25 100644 --- a/client/analysis.html +++ b/client/analysis.html @@ -41,11 +41,11 @@
In order to ensure the most accurate analysis while handling the minimum amount - of data, this tool takes 20 random comments from the Youtube API, aggregates them - into a single string of sentences, and runs the chunk through both the NLP and - Perspective APIs. Here is what each API is responsible for: + of data, this tool takes the 20 most relevant comments from the Youtube API, + weights each comment based off of the number of likes it receives, then creates + an overall score proportional to the number of likes. + Here is what each API is responsible for:
-NLP
diff --git a/client/js/analysis.js b/client/js/analysis.js
index c88c041..e88b8f5 100644
--- a/client/js/analysis.js
+++ b/client/js/analysis.js
@@ -9,7 +9,7 @@ const TEN_MINUTES_IN_SECONDS = 60 * 10;
* We only want to pull from the client-side cache if two requests
* are made within 10 mins of eachother.
*/
-var siteHeaders = new Headers();
+const siteHeaders = new Headers();
siteHeaders.set('Cache-control', `max-age=${TEN_MINUTES_IN_SECONDS}`);
/* global getData */
@@ -41,7 +41,8 @@ async function fetchResponse() {
if (response) {
if (response.status == 500) {
// This will hit when comments are disabled for the video.
- alert('The video you selected is incompatible with this tool. Please try again.');
+ alert(`The video you selected is incompatible with this tool.
+ Please try again.`);
return;
}
renderingHandler(response);
@@ -58,6 +59,8 @@ function renderingHandler(videoAnalysis) {
const charts = document.getElementById('charts');
const list = document.getElementById('list');
const card = document.getElementById('videocard-wrapper');
+ const featuredComments = document.getElementById('commentHeader');
+ featuredComments.classList.remove('hidden');
removeAllChildNodes(charts);
removeAllChildNodes(list);
@@ -138,8 +141,9 @@ function createCard(id, name, channel) {
*/
function renderComments(array) {
const totalComments = Math.min(COMMENT_TO_STOP_AT, array.length);
+
for (let i = 0; i < totalComments; i++) {
- const filteredValue = array[i].comment.replace('\n/g', ' -- ');
+ const filteredValue = array[i].text.replace('\n/g', ' -- ');
setTimeout(() => {
addListElement(filteredValue);
}, (i+1) * COMMENT_APPEARANCE_TIME);
@@ -341,11 +345,11 @@ function shakeSearchBar() {
/**
* Sets a cooldown period for the submit button
- */
- function buttonCoolDown() {
- buttonElement = document.getElementById('sendbutton');
- buttonElement.disabled = true;
- setTimeout(() => {
- buttonElement.disabled = false;
- }, COOLDOWN_TIME);
- }
+ */
+function buttonCoolDown() {
+ const buttonElement = document.getElementById('sendbutton');
+ buttonElement.disabled = true;
+ setTimeout(() => {
+ buttonElement.disabled = false;
+ }, COOLDOWN_TIME);
+}
diff --git a/server/src/main/java/com/google/musicanalysis/site/AnalysisServlet.java b/server/src/main/java/com/google/musicanalysis/site/AnalysisServlet.java
index 22213f2..c6a283a 100644
--- a/server/src/main/java/com/google/musicanalysis/site/AnalysisServlet.java
+++ b/server/src/main/java/com/google/musicanalysis/site/AnalysisServlet.java
@@ -41,6 +41,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse res)
commentArgs.put("part", "snippet");
commentArgs.put("videoId", userInput);
+ commentArgs.put("order", "relevance");
String commentsJson;
// Runs input through the cache first
@@ -78,13 +79,13 @@ protected void doGet(HttpServletRequest req, HttpServletResponse res)
HashMap