/**
 * estrae gli N atti più rilevanti per determinati argomenti (tag)
 */
function run_a0_get_main_acts_for_tags($task, $args, $options)
{
    static $loaded;
    // load application context
    if (!$loaded) {
        task_loader();
        $loaded = true;
    }
    echo "memory usage: " . memory_get_usage() . "\n";
    $msg = sprintf("start time: %s\n", date('H:i:s'));
    echo $msg;
    $n = 1;
    if (array_key_exists('nrecs', $options)) {
        $n = (int) $options['nrecs'];
    }
    if (!is_int($n) || $n < 1) {
        throw new Exception("il numero di atti deve essere un intero\n");
    }
    if (count($args) > 0) {
        $argomenti = array();
        foreach ($args as $cnt => $arg) {
            $id = TagPeer::getIdFromTagValue($arg);
            $xml_url = sprintf("http://parlamento.openpolis.it/xml/indici/tag/%d.xml", $id);
            $xsl_file = SF_ROOT_DIR . "/web/xml/indici/xslt/tagActsSorter.xslt";
            printf("Argomento %s:\n", $arg, $id);
            getImportantActs($xml_url, $xsl_file, $n);
            print "\n";
        }
    }
    $start_time = time();
    $msg = sprintf("end time: %s\n", date('H:i:s'));
    echo $msg;
    $msg = sprintf("memory usage: %10d\n", memory_get_usage());
    echo pakeColor::colorize($msg, array('fg' => 'red', 'bold' => false));
}