Skip to content

Instantly share code, notes, and snippets.

@codeas
Last active April 26, 2021 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeas/5c853ff0424cc6d76e273df561cf1fde to your computer and use it in GitHub Desktop.
Save codeas/5c853ff0424cc6d76e273df561cf1fde to your computer and use it in GitHub Desktop.
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