// SCRIPTS FOR USE WITH THE GOOGLE SHEETS APP SCRIPT // Adds a unix timestamp to each word on creation for unique id keeping function onEdit(e) { var sheet = e.source.getActiveSheet(); if (sheet.getName() === "Dictionary") { var actRng = sheet.getActiveRange(); var editColumn = actRng.getColumn(); var rowIndex = actRng.getRowIndex(); var dateCol = 1; var orderCol = 3; if (editColumn == orderCol) { sheet.getRange(rowIndex, dateCol).setValue(new Date().getTime()); } } } function onOpen() { var menuEntries = [ {name: "Go to Cell", functionName: "goToCell"}, {name: "Go to Row", functionName: "goToRow"}, {name: "Go to 1st empty Row", functionName: "selectFirstEmptyRow"}, {name: "Expand Part of Speech Abbreviations", functionName: "expandPartsOfSpeech"}, {name: "Standardize Pashto", functionName: "standardizePashtoColumns"}, {name: "Standardize Phonetics", functionName: "standardizePhonetics"}, {name: "Find Unlinked Compound Verb", functionName: "selectUnlinkedCompound"}, ]; SpreadsheetApp.getActiveSpreadsheet().addMenu("MyUtils", menuEntries); } function standardizePashtoText(input) { return input.trim().replace(/\u0649/g, "\u06cc") // Arabic ك replace with ک .replace(/\u0643/g, "\u06a9") // Farsi گ replaced with ګ .replace(/گ/g, "ګ") // Replace ي s in the middle of words to ی .replace(/ي(?=[\u0600-\u060b\u060d-\u06ff])/g, "ی") // Replace آ two character version with combined آ character .replace(/آ/g, "آ"); } var pashtoColumns = ["J", "L", "O", "Q", "S", "U", "W", "Y", "AA"]; var phoneticsColumns = ["K","M", "P", "R", "T", "V", "X", "Z", "AB"]; function standardizePashtoColumns() { for(var h=0;h-1) { // check if there is a link to another word on the compound word var linkToWord = values[row][5]; if (!linkToWord) break; // check if the link is valid if (!linkExists(linkToWord)) return row+1; }; } return row+1; } function getFirstEmptyRowWholeRow() { var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getDataRange(); var values = range.getValues(); var row = 0; for (var row=0; row