Skip to content

Instantly share code, notes, and snippets.

@MDFL64
Created March 14, 2024 19:33
Show Gist options
  • Save MDFL64/824cfd71d31ed126b29eccd33c1daea5 to your computer and use it in GitHub Desktop.
Save MDFL64/824cfd71d31ed126b29eccd33c1daea5 to your computer and use it in GitHub Desktop.
// Run on https://lexfridman.com/israel-palestine-debate-transcript
(function() {
// Exclude rambles shorter than this value. There are points in the transcript
// where norm speaks for a very short time, or speakers interrupt each-other.
const NORM_RAMBLE_THRESHOLD = 5;
let items = document.querySelectorAll(".ts-segment");
// Collect to (speaker,start) pairs first to make processing easier
let pairs = [];
let start=0;
let speaker;
for (let item of items) {
let new_speaker = item.querySelector(".ts-name").innerText;
if (new_speaker != "") {
if (speaker != null) {
pairs.push({speaker,start});
}
speaker = new_speaker;
let href = item.querySelector(".ts-timestamp a").href;
let time = +href.split("t=")[1];
start = time;
}
}
let results = [];
for (let i=0;i<pairs.length;i++) {
let pair = pairs[i];
switch (pair.speaker) {
case "Lex Fridman":
case "Benny Morris":
case "Steven Bonnell":
case "Mouin Rabbani":
continue;
case "Norman Finkelstein": {
// thankfully norm isn't near the end so our shit logic is sufficient
let start = pair.start;
let end = pairs[i+1].start;
if (end-start >= NORM_RAMBLE_THRESHOLD) {
results.push([start,end]);
}
break;
}
default: throw new Error("bad speaker: "+pair.speaker);
}
}
console.log(JSON.stringify(results));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment