Skip to content

Commit

Permalink
Descending word lengths
Browse files Browse the repository at this point in the history
  • Loading branch information
drdhaval2785 committed Nov 11, 2015
1 parent 696d100 commit 3eb8767
Show file tree
Hide file tree
Showing 11 changed files with 38,479 additions and 38,553 deletions.
12 changes: 12 additions & 0 deletions o_vs_O/composite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# php o_vs_O_sanhw2.php takes a lot of time.
# Therefore, use only o_vs_O2.txt preferrably.
# You would want to regenerate o_vs_O2.txt only if sanhw2.txt is altered.
#echo "Running o_vs_O_sanhw2.php and storing in o_vs_O2.txt."
#echo
#php o_vs_O_sanhw2.php
echo "Running dictsorting_single.php."
echo
php dictsorting_single.php
echo "Running sortlen.py."
echo
python sortlen.py
144 changes: 10 additions & 134 deletions o_vs_O/dictsorting_single.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@
$outtext1 = fopen("output3/composite1.txt","w+");
$outtext2 = fopen("output3/composite2.txt","w+");
$outtext3 = fopen("output3/composite3.txt","w+");
$outhtml1 = fopen("output3/composite1.html","w+");
$outhtml2 = fopen("output3/composite2.html","w+");
$outhtml3 = fopen("output3/composite3.html","w+");
fputs($outhtml1,"<h2>Highest probability (One dictionary in first word and more dictionaries in second word)</h2>\n");
fputs($outhtml2,"<h2>Medium probability (One dictionary in first word and one dictionary in second word)</h2>\n");
fputs($outhtml3,"<h2>Lowest probability (More than one dictionary in first word and it has dictionary under consideration)</h2>\n");

$counter = count($input);
$counter1 = 0;
Expand All @@ -67,47 +61,44 @@
//echo $word1[$j], count($dict1separate[$j]), count($dict2separate[$j]), arrinter($dict1sepwithoutlnum[$j],$dict2sepwithoutlnum[$j])."\n";
if (count($dict1separate[$j])===1 && count($dict2separate[$j])>1 && arrinter($dict1sepwithoutlnum[$j],$dict2sepwithoutlnum[$j])===0)
{
fputs($outtext1,convert($word1[$j])."->".convert($word2[$j])."\n");
fputs($outhtml1,$word1[$j].":".$word2[$j]."-".$dict1[$j].":".$dict2[$j]."<br>\n");
fputs($outtext1,$word1[$j].":".$word2[$j]."-".$dict1[$j].":".$dict2[$j]."\n");
$counter1++;
}
elseif (count($dict2separate[$j])===1 && count($dict1separate[$j])>1 && arrinter($dict1sepwithoutlnum[$j],$dict2sepwithoutlnum[$j])===0)
{
fputs($outtext1,convert($word2[$j])."->".convert($word1[$j])."\n");
fputs($outhtml1,$word2[$j].":".$word1[$j]."-".$dict2[$j].":".$dict1[$j]."<br>\n");
fputs($outtext1,$word2[$j].":".$word1[$j]."-".$dict2[$j].":".$dict1[$j]."\n");
$counter2++;
}
elseif (count($dict1separate[$j])===1 && count($dict2separate[$j])===1 && arrinter($dict1sepwithoutlnum[$j],$dict2sepwithoutlnum[$j])===0)
{
fputs($outtext2,convert($word1[$j])."->".convert($word2[$j])."\n");
fputs($outhtml2,$word1[$j].":".$word2[$j]."-".$dict1[$j].":".$dict2[$j]."<br>\n");
fputs($outtext2,$word1[$j].":".$word2[$j]."-".$dict1[$j].":".$dict2[$j]."\n");
$counter3++;
}
elseif ( count($dict1separate[$j])>1 && count($dict2separate[$j])>1 && arrinter($dict1sepwithoutlnum[$j],$dict2sepwithoutlnum[$j])===0)
{
fputs($outtext3,convert($word1[$j])."->".convert($word2[$j])."\n");
fputs($outhtml3,$word1[$j].":".$word2[$j]."-".$dict1[$j].":".$dict2[$j]."<br>\n");
fputs($outtext3,$word1[$j].":".$word2[$j]."-".$dict1[$j].":".$dict2[$j]."\n");
$counter4++;
}
elseif (arrinter($dict1sepwithoutlnum[$j],$dict2sepwithoutlnum[$j])>0)
{
fputs($outtext3,convert($word1[$j])."->".convert($word2[$j])."\n");
fputs($outhtml3,$word1[$j].":".$word2[$j]."-".$dict1[$j].":".$dict2[$j]."<br>\n");
fputs($outtext3,$word1[$j].":".$word2[$j]."-".$dict1[$j].":".$dict2[$j]."\n");
$counter5++;
}
else
{
echo $word1[$j]."\n";
}
if ($j%1000===0)
{
echo $j, " entries from o_vs_O2.txt handled.\n";
}
}
echo $counter1."+".$counter2."+".$counter3."+".$counter4."+".$counter5." / ".$counter." occurrences are handled.<br/>\n";
echo $counter1+$counter2+$counter3+$counter4+$counter5." / ".$counter." occurrences are handled.<br/>\n";
fclose($outtext1);
fclose($outhtml1);
fclose($outtext2);
fclose($outhtml2);
fclose($outtext3);
fclose($outhtml3);


# MW;1254 -> MW
function removelnum1($dictwithlnum)
Expand All @@ -118,119 +109,4 @@ function arrinter($one,$two)
{
return count(array_intersect($one,$two));
}
/*
foreach ($dictionaryname as $value)
{
echo "$value dictionary is being treated<br/>\n";
$counter1=0;
$counter2=0;
$counter3=0;
$counter4=0;
$counter5=0;
$counter6=0;
$counter7=0;
$countervalue=0;
//$value = "MW";
for ($j=0;$j<count($input);$j++)
{
if ( (indict_with_lnum($value,$dict1separate[$j]) || indict_with_lnum($value,$dict2separate[$j])) && !(indict_with_lnum($value,$dict1separate[$j]) && indict_with_lnum($value,$dict2separate[$j])) )
{
$countervalue++;
}
}
$outtext = fopen("output2/$value.txt","w+");
$outhtml = fopen("output2/$value.html","w+");
fputs($outhtml,"<h2>Highest probability (One dictionary in first word and more dictionaries in second word)</h2>\n");
for ($j=0;$j<count($input);$j++)
{
if (count($dict1separate[$j])===1 && count($dict2separate[$j])>1 && indict_with_lnum($value,$dict1separate[$j]) && !indict_with_lnum($value,$dict2separate[$j]))
{
fputs($outtext,convert($word1[$j])."->".convert($word2[$j])."\n");
fputs($outhtml,$word1[$j].":".$word2[$j]."-".$dict1[$j].":".$dict2[$j]."<br>\n");
$counter1++;
}
}
//fputs($outhtml,"<h2>One dictionary in second word and more dictionaries in first word</h2>\n");
for ($j=0;$j<count($input);$j++)
{
if (count($dict2separate[$j])===1 && count($dict1separate[$j])>1 && indict_with_lnum($value,$dict2separate[$j]) && !indict_with_lnum($value,$dict1separate[$j]))
{
fputs($outtext,convert($word2[$j])."->".convert($word1[$j])."\n");
fputs($outhtml,$word2[$j].":".$word1[$j]."-".$dict2[$j].":".$dict1[$j]."<br>\n");
$counter2++;
}
}
fputs($outhtml,"<h2>Medium probability (One dictionary in first word and one dictionary in second word)</h2>\n");
for ($j=0;$j<count($input);$j++)
{
if (count($dict1separate[$j])===1 && count($dict2separate[$j])===1 && indict_with_lnum($value,$dict1separate[$j]) && !indict_with_lnum($value,$dict2separate[$j]))
{
fputs($outtext,convert($word1[$j])."->".convert($word2[$j])."\n");
fputs($outhtml,$word1[$j].":".$word2[$j]."-".$dict1[$j].":".$dict2[$j]."<br>\n");
$counter3++;
}
}
//fputs($outhtml,"<h2>One dictionary in second word and one dictionary in first word</h2>\n");
for ($j=0;$j<count($input);$j++)
{
if (count($dict1separate[$j])===1 && count($dict2separate[$j])===1 && indict_with_lnum($value,$dict2separate[$j]) && !indict_with_lnum($value,$dict1separate[$j]))
{
fputs($outtext,convert($word2[$j])."->".convert($word1[$j])."\n");
fputs($outhtml,$word2[$j].":".$word1[$j]."-".$dict2[$j].":".$dict1[$j]."<br>\n");
$counter4++;
}
}
fputs($outhtml,"<h2>Lowest probability (More than one dictionary in first word and it has dictionary under consideration)</h2>\n");
for ($j=0;$j<count($input);$j++)
{
if ( count($dict1separate[$j])>1 && indict_with_lnum($value,$dict1separate[$j]) && !indict_with_lnum($value,$dict2separate[$j]) )
{
fputs($outtext,convert($word1[$j])."->".convert($word2[$j])."\n");
fputs($outhtml,$word1[$j].":".$word2[$j]."-".$dict1[$j].":".$dict2[$j]."<br>\n");
$counter5++;
}
}
//fputs($outhtml,"<h2>More than one dictionary in second word and it has dictionary under consideration</h2>\n");
for ($j=0;$j<count($input);$j++)
{
if (count($dict2separate[$j])>1 && indict_with_lnum($value,$dict2separate[$j]) && !indict_with_lnum($value,$dict1separate[$j]) )
{
fputs($outtext,convert($word2[$j])."->".convert($word1[$j])."\n");
fputs($outhtml,$word2[$j].":".$word1[$j]."-".$dict2[$j].":".$dict1[$j]."<br>\n");
$counter6++;
}
}
//This testing shows that all the cases are covered.
echo $counter1."+".$counter2."+".$counter3."+".$counter4."+".$counter5."+".$counter6." / ".$countervalue." occurrences are handled.<br/>\n";
echo $counter1+$counter2+$counter3+$counter4+$counter5+$counter6." / ".$countervalue." occurrences are handled.<br/>\n";
fclose($outtext);
fclose($outhtml);
}
foreach ($dictionaryname as $value)
{
echo "$value is printing.<br/>\n";
$in = file("output2/".$value.".html");
$outfile = fopen("output2/$value.html","w+");
fputs($outfile,$header);
fputs($outfile,"<h1>$value - list of possible errors found by o_vs_O method</h1>");
fputs($outfile,'<table class="fixed">');
$count=1;
foreach($in as $value1)
{
if (strpos($value1,"<h2>")===false)
{
$val =givelinktoo_vs_Otext3($value1);
$count++;
}
else
{
$val = "</table>".$value1.'<table class="fixed">';
}
fputs($outfile,$val);
}
fputs($outfile,"</table>");
fclose($outfile);
}
*/
?>
Loading

0 comments on commit 3eb8767

Please sign in to comment.