#!/usr/local/bin/perl -wT # This is the script for fourth screen of the web-interface. use CGI; $CGI::DISABLE_UPLOADS = 0; $q=new CGI; # Create the URL for the form-action my $host = $ENV{'HTTP_HOST'}; print $q->header; print $q->start_html("SenseClusters"); $clustype=$q->param("clustype"); $usr_dir=$q->param("usr_dir"); if(!$usr_dir) { error("Error in receiving the user directory name from feature_process script."); } if($usr_dir =~ m/([\w\d\-_\\\/\: ]+)/) { $usr_dir=$1; } else { error($q,"Invalid user directory name!"); } #open the param_file and read the prefix open(PARAM,"<$usr_dir/param_file") || error($q, "Error in opening the PARAM file."); my $temp_delimiter = $/; $/ = undef; my $params = ; close PARAM; $/ = $temp_delimiter; $params=~/SPACE=(.+)/; $space = $1; if($params=~/BINARY=/) { $params=~/BINARY=(.+)/; $binary = $1; } $prefix=$q->param("prefix"); if(!$prefix) { $params=~/PREFIX=\"(.+?)\"/; $prefix = $1; } ####### # SVD # ####### $svd=$q->param("svd"); ##### # K # ##### $k=$q->param("k"); if($k) { if($k =~ m/^(\d+)$/) { $k=$1; } else { error($q,"Invalid K value!"); } } ###### # RF # ###### $rf=$q->param("rf"); if($rf) { if($rf =~ m/^(\d+)$/) { $rf=$1; } else { error($q,"Invalid RF value!"); } } ######## # Iter # ######## $iter=$q->param("iter"); if($iter) { if($iter =~ m/^(\d+)$/) { $iter=$1; } else { error($q,"Invalid SVD Iteration value!"); } } # ---------------------------------- # Getting Clustering Option Values # ---------------------------------- ############ # Clusters # ############ $cluststop = $q->param("cluststop"); if($cluststop eq "nclust") { $clusters=$q->param("clusters"); if($clusters) { if($clusters =~ m/^(\d+)$/) { $clusters=$1; } else { error($q,"Invalid Number of Clusters!"); } if($clusters < 1) { error($q, "#clusters can not be less than 1."); } } } else { $cs_measure = $q->param("cs_measure"); } ############ # Clmethod # ############ $clmethod=$q->param("clmethod"); ######################### # Writing to PARAM file # ######################### $param_file="$usr_dir/param_file"; open(PARAM,">>$param_file") || error($q, "Error in opening PARAM file."); if($svd) { print PARAM "SVD=ON\n"; if($k) { print PARAM "K=$k\n"; } if($rf) { print PARAM "RF=$rf\n"; } if($iter) { print PARAM "ITER=$iter\n"; } } if($cluststop eq "nclust") { print PARAM "CLUSTERS=$clusters\n"; } else { if($cs_measure eq "all") { print PARAM "CLUSTSTOP=all\n"; } elsif($cs_measure eq "pk") { print PARAM "CLUSTSTOP=pk\n"; } elsif($cs_measure eq "pk1") { print PARAM "CLUSTSTOP=pk1\n"; } elsif($cs_measure eq "pk2") { print PARAM "CLUSTSTOP=pk2\n"; } elsif($cs_measure eq "pk3") { print PARAM "CLUSTSTOP=pk3\n"; } elsif($cs_measure eq "gap") { print PARAM "CLUSTSTOP=gap\n"; } } print PARAM "CLMETHOD=$clmethod\n"; close PARAM; ################################### # Now the Clustering Options Form # ################################### print $q->start_form(-action=>'fifth.cgi', -method=>'post', -enctype=>'multipart/form-data'); print "

SenseClusters Web Interface

Clusters text instances based on their contextual similarity ...

"; print $q->h3("Step 4: (Last Step)"); print ""; if($clmethod eq 'agglo') { print ""; } else { print ""; } if($space eq 'vector' && $clmethod eq 'graph') { print ""; } elsif($space eq 'vector') { print ""; } elsif($space eq 'similarity' && defined $binary) { print ""; } elsif($space eq 'similarity' && !defined $binary) { print ""; } print ""; # evaluation and clustering labeling not applicable for word-clustering if($clustype ne "wclust" && $clustype ne "lsa-fclust") { print ""; print ""; print ""; print ""; print ""; print ""; print ""; } print "
Clustering ", $q->a({-href=>"http://$host/SC-htdocs/help.html#crfun_cr"}, "Criteria Function"), " ", $q->popup_menu(-name=>'crfun', -values=>['i1', 'i2', 'e1', 'g1', 'g1p', 'h1', 'h2', 'slink', 'wslink', 'clink', 'wclink', 'upgma'], -default=>'i2', -labels=>{i1=>'I1 Criterion function',i2=>'I2 Criterion function',e1=>'E1 Criterion function',g1=>'G1 Criterion function',g1p=>'G1\' Criterion function',h1=>'H1 Criterion function',h2=>'H2 Criterion function',slink=>'slink: Single link merging scheme',wslink=>'wslink: Weighted Single link merging scheme',clink=>'clink: Complete link merging scheme',wclink=>'wclink: Weighted Complete link merging scheme',upgma=>'upgma: Group average merging scheme'}), "
Clustering ", $q->a({-href=>"http://$host/SC-htdocs/help.html#crfun_cr"}, "Criteria Function"), " ", $q->popup_menu(-name=>'crfun', -values=>['i1', 'i2', 'e1', 'g1', 'g1p', 'h1', 'h2'], -default=>'i2', -labels=>{i1=>'I1 Criterion function',i2=>'I2 Criterion function',e1=>'E1 Criterion function',g1=>'G1 Criterion function',g1p=>'G1\' Criterion function',h1=>'H1 Criterion function',h2=>'H2 Criterion function'}), "
", $q->a({-href=>"http://$host/SC-htdocs/help.html#sim_sim"}, "Similarity Measure"), "", $q->popup_menu(-name=>'vsim', -values=>['cos', 'corr', 'dist', 'jacc'], -default=>'cos', -labels=>{cos=>'Cosine', corr=>'Pearson\'s Correlation', dist=>'Euclidean Distance', jacc=>'Jaccard'}), "
", $q->a({-href=>"http://$host/SC-htdocs/help.html#sim_sim"}, "Similarity Measure"), "", $q->popup_menu(-name=>'vsim', -values=>['cos', 'corr'], -default=>'cos', -labels=>{cos=>'Cosine', corr=>'Pearson\'s Correlation'}), "
", $q->a({-href=>"http://$host/SC-htdocs/help.html#sim_sim"}, "Similarity Measure"), "", $q->popup_menu(-name=>'ssim', -values=>['cos', 'match', 'jacc', 'over', 'dice'], -labels=>{cos=>'Cosine', match=>'Match', jacc=>'Jaccard', over=>'Overlap', dice=>'Dice'}, -default=>'cos'), "
", $q->a({-href=>"http://$host/SC-htdocs/help.html#sim_sim"}, "Similarity Measure"), "", $q->popup_menu(-name=>'ssim', -values=>['cos'], -labels=>{cos=>'Cosine'}, -default=>'cos'), "

", $q->a({-href=>"http://$host/SC-htdocs/help.html#eval"}," Evaluate performance of the method"), "", $q->checkbox(-name=>'eval', -label=>''), "

Labeling Options:
Load the ", $q->a({-href=>"http://$host/SC-htdocs/help.html#label_stop_label_stopfile"},"STOP file"), " (Perl Regex Format) ", $q->filefield(-name=>'stop_label', -size=>30); print ""; print $q->checkbox(-name=>'default_stop',-label=>''), " Use ", $q->a({-href=>"http://$host/SC-htdocs/stopfile"}, "Default"),"
Lower ", $q->a({-href=>"http://$host/SC-htdocs/help.html#label_remove_label_n"},"Frequency Cutoff"), " (Integer) ", $q->textfield(-name=>'remove', -size=>5,-value=>5, -maxlength=>7), " [Use 0 to disable this option]
", $q->a({-href=>"http://$host/SC-htdocs/help.html#label_window_label_w"},"Window"), " (Integer) " , $q->textfield(-name=>'window', -size=>5, -value=>2, -maxlength=>7), " [Use 0 to disable this option]
", $q->a({-href=>"http://$host/SC-htdocs/help.html#label_stat_label_stat"},"Statistical Test"), " of Association ", $q->popup_menu(-name=>'stat', -labels=>{ll=>"Log-Likelihood", x2=>"Chi-Square", dice=>"Dice", phi=>"Phi", odds=>"Odds Ratio", pmi=>"Point-wise Mutual Information", tmi=>"True Mutual Information", tscore=>"T-Score", leftFisher=>"Left Fishers", rightFisher=>"Right Fishers"}, -values=>['ll', 'x2', 'dice', 'phi', 'odds', 'pmi', 'tmi', 'tscore', 'leftFisher', 'rightFisher'], -default=>'ll'), "
", $q->a({-href=>"http://$host/SC-htdocs/help.html#label_rank_label_r"},"Statistical Rank"), " Cutoff (Integer) ", $q->textfield(-name=>'stat_rank', size=>5,-value=>10, -maxlength=>7), "
"; print $q->hidden(-name=>'usr_dir',-value=>$usr_dir); print $q->hidden(-name=>'prefix', -value=>$prefix); print $q->hidden(-name=>'clustype', -value=>$clustype); print "
"; print $q->p; print $q->end_form; print $q->a({-href=>"http://$host/SC-htdocs/help.html"}, "Help"); print $q->end_html; sub error { my ($q,$reason) = @_; print $q->h1("Error"), $q->p($q->i($reason)), $q->end_html; exit; }