Last active
April 26, 2021 07:09
-
-
Save codeas/5c853ff0424cc6d76e273df561cf1fde to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SPREADSHEET_ID = "xxxxx"; // <-- Google Spreadsheet ID | |
var settings = { | |
nomadland : "xxxxxx" // <--- subtitles fileId | |
} | |
function RUN() { | |
var movie = "nomadland" | |
var fileId = settings[movie]; | |
var output = subitlesParser(fileId); | |
var table = []; | |
table.push(["time", "score", "magnitude", "text"]); | |
output.forEach(function (line) { | |
var position = line[0]; | |
var content = line[1]; | |
var nlp = getSentiment(content); | |
nlp = JSON.parse(nlp); | |
table.push([position, nlp.documentSentiment.score, nlp.documentSentiment.magnitude, content]); | |
Utilities.sleep(200); | |
}); | |
var ss = SpreadsheetApp.openById(SPREADSHEET_ID) | |
if (ss.getSheetByName(movie) === null) { | |
var sheet = ss.insertSheet(movie) | |
} else { | |
var sheet = ss.getSheetByName(movie) | |
} | |
sheet.getRange(2,1,table.length,table[0].length).setValues(table); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment