echo '<h1>Clustering documents from external source</h1>'; $source = "etools"; $query = "data mining"; $results = 20; $algorithm = "url"; // cluster by url to show how to handle subclusters echo "<strong>Source:</strong> " . $source . '<br />'; echo "<strong>Query:</strong> " . $query . '<br />'; echo "<strong>Number of results:</strong> " . $results . '<br />'; echo "<strong>Algorithm:</strong> " . $algorithm . '<br />'; // Carrot2Job defines data required for clustering. $job = new Carrot2Job(); $job->setSource($source); $job->setQuery($query); $job->setAlgorithm($algorithm); $job->setAttribute("results", $results); // Perform clustering try { $result = $processor->cluster($job); } catch (Carrot2Exception $e) { echo 'An error occurred during processing: ' . $e->getMessage(); exit(10); } // Display results $documents = $result->getDocuments(); $clusters = $result->getClusters(); echo "<h2>Clusters</h2>"; if (count($clusters) > 0) { echo "<ul>"; foreach ($clusters as $cluster) { displayCluster($cluster);