130 lines
2.9 KiB
PHP
Executable File
130 lines
2.9 KiB
PHP
Executable File
<?php
|
|
|
|
$arqcl="arquivosclustering/confclustering.conf";
|
|
$dirindexacao="indexados/";
|
|
|
|
$configuracoes=file($arqcl);
|
|
|
|
function gerarmakefile($diretorioI, $confs, $nfeatures)
|
|
{
|
|
// Esta função recebe como entrada o diretorio de indexacao e o as configurações de clustering
|
|
|
|
// Diretorio com algoritmo de clustering
|
|
|
|
$diretoriocluto="cluto-2.1.2/Linux-i686/";
|
|
|
|
// Obter número de clusters
|
|
|
|
$nclusters=trim($confs[0]);
|
|
|
|
unset($confs[0]);
|
|
|
|
// Redefine os indices
|
|
|
|
$confs=array_values($confs);
|
|
|
|
|
|
|
|
$amakefile = $diretoriocluto."makefile";
|
|
|
|
$fi= fopen($amakefile,'w');
|
|
|
|
// Grava primeira linha do arquivo makefile
|
|
|
|
fwrite($fi,"all:\n");
|
|
|
|
// Cria linha de comando para clusterizar a partir do arquivo de configuracoes de clustering
|
|
|
|
|
|
$linhacomando="";
|
|
|
|
foreach($confs as $linha)
|
|
{
|
|
|
|
$cadalinha= rtrim($linha);
|
|
|
|
$linhacomando= $linhacomando.$cadalinha." ";
|
|
|
|
}
|
|
// Para cada diretorio de tarefas
|
|
|
|
|
|
|
|
$ponteiro1 = opendir($diretorioI);
|
|
|
|
|
|
if ((file_exists($diretorioI)))
|
|
{
|
|
|
|
// Para cada diretorio de tarefa
|
|
|
|
while (($nometarefa = readdir($ponteiro1)))
|
|
{
|
|
|
|
if (($nometarefa<>".") && ($nometarefa<>"..") )
|
|
{
|
|
$mi = $diretorioI.$nometarefa."/"."matrizindexada_$nometarefa".".txt";
|
|
|
|
// Se existe a matriz indexada no diretorio
|
|
|
|
if (file_exists($mi))
|
|
{
|
|
$matriz = file($mi);
|
|
|
|
$cont= count($matriz) - 1; // Retirando primeira linha
|
|
|
|
|
|
unset($matriz);
|
|
//--------------------------------------------------------------
|
|
|
|
|
|
$ncl = $nclusters;
|
|
|
|
//if ($ncl>$cont)
|
|
//{
|
|
|
|
// $ncl = $cont;
|
|
//}
|
|
|
|
// Endereço destino em relacao ao endereco onde esta algoritmo de clustering
|
|
|
|
$enddestino = "../../$diretorioI"."$nometarefa/";
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
// Gera Linha de comando completa
|
|
|
|
if ($ncl>0 && $cont > 1)
|
|
{
|
|
|
|
$linhadecomandof= "\t".$linhacomando." -rlabelfile=$enddestino"."$nometarefa".".rlabel "."-plotmatrix=".$enddestino."grafico.eps -clustfile=$enddestino"."clusters.txt"." ../../$mi"." -nfeatures=$nfeatures -showfeatures $ncl > $enddestino"."resultados.txt"."\n";
|
|
|
|
// Grava linha de comando
|
|
|
|
fwrite($fi,$linhadecomandof);
|
|
|
|
}
|
|
|
|
} // do if
|
|
|
|
} // do if
|
|
} // do while
|
|
} // do if
|
|
|
|
|
|
fclose($fi);
|
|
|
|
}// Fim da funcao
|
|
|
|
$arqcaracteristicas="arquivosindexacao/tokens.csv";
|
|
$arqc = file($arqcaracteristicas);
|
|
$numcaracteristicas=count($arqc);
|
|
unset($arqc);
|
|
|
|
// Chama a função que gera o makefile das tarefas
|
|
|
|
gerarmakefile($dirindexacao, $configuracoes, $numcaracteristicas);
|
|
|
|
unset($configuracoes);
|
|
?>
|