exit(1);
}
while (($line = fgets($file)) !== FALSE) {
    $documents[] = $line;
}
if (!feof($file)) {
    echo "Error: unexpected fgets() fail\n";
}
fclose($file);
$total_docs = count($documents);
// Initializes new session with the serializer object and the keys.
$session = new \Semantria\Session(CONSUMER_KEY, CONSUMER_SECRET, NULL, NULL, TRUE);
// Initialize session callback handler
$callback = new SessionCallbackHandler();
$session->setCallbackHandler($callback);
$configurations = $session->getConfigurations();
$primary_config = NULL;
$autoresponse_config = NULL;
foreach ($configurations as $configuration) {
    if ($configuration['is_primary']) {
        $primary_config = $configuration;
    } else {
        if ($configuration['name'] == 'AutoResponseTest') {
            $autoresponse_config = $configuration;
        }
    }
}
if ($autoresponse_config == NULL) {
    $session->addConfigurations(array(array('name' => 'AutoResponseTest', 'language' => 'English', 'is_primary' => TRUE, 'auto_response' => TRUE)));
} else {
    $autoresponse_config['is_primary'] = TRUE;