speaking as $speaking) { //// create new Record object $record = new Record(); $record->congress = $congress['congress']; $record->chamber = $chamber; $record->sequence = $sequence; $record->occurred = $occurred; $record->speaker_rep_id = (int) $speaking['speaker']; $record->topic = (string) $speaking['topic']; $speech = ''; $bill_id = 0; if ((count($speaking->paragraph) == 1) && (substr_count((string) $speaking->paragraph[0], '.') == 1)) { //// skip this one-line speech continue; } foreach ($speaking->paragraph as $paragraph) { if (($bill_id == 0) && isset($paragraph->bill)) { foreach ($paragraph->bill as $billref) { $bill = Bill::get_by_congress_type_number($congress['congress'], $billref['type'], $billref['number']); if ($bill != null) { $bill_id = $bill->id; break; } } } $speech = $speech . $paragraph->asXML(); } $record->bill_id = $bill_id; $record->speech = $speech; $record->save(); } echo "{$doc['where']} {$doc['when']} {$doc['ordinal']}\n"; } if (isset($_SERVER['argv'])) { if ($_SERVER['argv'][0] != 'cr.php') { return; } if (count($_SERVER['argv']) > 1) { //// parse arguments parseRecord($_SERVER['argv'][1]); } else { //// process all current congressional records in the data dir $current = get_current_congress_session(); $records_dir = $data_dir ."/us/{$current['congress']}/cr"; $listing = scandir($records_dir); foreach ($listing as $filename) { $path ="{$records_dir}/{$filename}"; if (is_file($path)) { parseRecord($path); } } } } ?>