i make a text preprocess on text mining with large database,, i want make a camus data from all article on database into array, but it take to long process.
$multiMem = memory_get_usage();
$xstart = microtime(TRUE);
$word = "";
$sql = mysql_query("SELECT * FROM tbl_content");
while($data = mysql_fetch_assoc($sql)){
$word = $word."".$data['article'];
}
$preprocess = new preprocess($word);
$word= $preprocess->preprocess($word);
print_r($kata);
$xfinish = microtime(TRUE);
here is my class preprocess
class preprocess {
var $teks;
function preprocess($teks){
/*start process segmentation*/
$teks = trim($teks);
//menghapus tanda baca
$teks = str_replace("'", "", $teks);
$teks = str_replace("-", "", $teks);
$teks = str_replace(")", "", $teks);
$teks = str_replace("(", "", $teks);
$teks = str_replace("=", "", $teks);
$teks = str_replace(".", "", $teks);
$teks = str_replace(",", "", $teks);
$teks = str_replace(":", "", $teks);
$teks = str_replace(";", "", $teks);
$teks = str_replace("!", "", $teks);
$teks = str_replace("?", "", $teks);
//remove HTML tags
$teks = strip_tags($teks);
$teks = preg_replace('@<(\w+)\b.*?>.*?</\1>@si', '', $teks);
/*end proses segmentation*/
/*start case folding*/
$teks = strtolower($teks);
$teks = preg_replace('/[0-9]+/', '', $teks);
/*end case folding*/
/*start of tokenizing*/
$teks = explode(" ", $teks);
/*end of tokenizing*/
/*start of filtering*/
//stopword
$file = file_get_contents('stopword.txt', FILE_USE_INCLUDE_PATH);
$stopword = explode("
", $file);
//remove stopword
$teks = preg_replace('/\b('.implode('|',$stopword).')\b/','',$teks);
/*end of filtering*/
/*start of stemming*/
require_once('stemming.php');
foreach($teks as $t => $value){
$teks[$t] = stemming($value);
}
/*end of stemming*/
$teks = array_filter($teks);
$teks = array_values($teks);
return $teks;
}
}
anyone have any idea to make fast process on my program? pls help
thanks for advance