-
-
Save paigecm/08089d13f943184196fa81686d7961ea to your computer and use it in GitHub Desktop.
Edited script from @voyanttools Twitter for 2nd presidential debtate
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
<?php | |
# Thanks to the VoyantTools Twitter for the original script! https://twitter.com/VoyantTools/status/780760837472526338 | |
$dirname = dirname(__FILE__); | |
$filename = "2nd-pres-debate.txt"; #assumes you have https://gist.github.com/paigecm/c97f5cf12da37ae43e0895fb767c4d88 | |
$speaker = ""; $speeches = array(); | |
foreach(file("$dirname/$filename") as $line) { | |
$withoutname = preg_replace("/^(RADDATZ|COOPER|CLINTON|TRUMP):/","", $line); | |
if ($line!=$withoutname) { | |
$speaker = substr($line, 0, strpos($line, ":")); | |
} | |
if (trim($withoutname) && trim($withoutname)!="(APPLAUSE)") { | |
$speeches[$speaker] .= $withoutname; | |
} | |
} | |
foreach($speeches as $speaker => $speech) { | |
file_put_contents("$dirname/$speaker.txt", $speech); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment