@@ -10,8 +10,11 @@ import QCPAnalysis::QueryStringAnalysis;
1010
1111import lang ::php ::ast ::AbstractSyntax ;
1212import lang ::php ::util ::Corpus ;
13+ import lang ::php ::util ::Utils ;
1314
1415import IO ;
16+ import List ;
17+ import String ;
1518
1619loc lists = |project://QCPAnalysis/results/lists/| ;
1720loc counts = |project://QCPAnalysis/results/counts/| ;
@@ -51,4 +54,45 @@ public void writeQG(){
5154
5255public void writeQueryStrings (){
5356 iprintToFile (strings , {q | q <- buildAndClassifyQueryStrings (), q .flags .qcp5 == true });
57+ }
58+
59+ public str corpusAsLatexTable () {
60+ Corpus corpus = getCorpus ();
61+ corpusCounts = getSortedCountsCaseInsensitive ();
62+ pForSort = [ < toUpperCase (p ), p > | p <- corpus ];
63+ pForSort = sort (pForSort , bool (tuple [str ,str ] t1 , tuple [str ,str ] t2 ) { return t1 [0 ] < t2 [0 ]; });
64+
65+ str getLine (str p , str v ) = "<getSensibleName (p )> & <v > & <getOneFrom (corpusCounts [p ,v ]<1 > )> & <getOneFrom (corpusCounts [p ,v ]<0 > )>" ;
66+ str res =
67+ "\\ npaddmissingzero
68+ '\\ npfourdigitsep
69+ '\\ begin{table}
70+ '\\ centering
71+ '\\ caption{The Corpus.\\ label{tbl:php-corpus}}
72+ '\\ ra{1.2}
73+ '\\ begin{tabularx}{\\ columnwidth}{Xrrr} \\ toprule
74+ 'System & Version & File Count & SLOC \\\\ \\ midrule
75+ '<for (<_,p > <- pForSort , v := corpus [p ]){><getLine (p ,v )> \\\\
76+ '<}>
77+ '\\ bottomrule
78+ '\\ end{tabularx}
79+ '\\ end{table}
80+ '\\ npfourdigitnosep
81+ '\\ npnoaddmissingzero
82+ " ;
83+ return res ;
84+ }
85+
86+ public int totalCorpusFiles () {
87+ Corpus corpus = getCorpus ();
88+ corpusCounts = { < p , v , lc , fc > | < p , v , lc , fc > <- getSortedCounts (), p in corpus <0 >, v := corpus [p ] };
89+ corpusFileCounts = corpusCounts <3 >;
90+ return ( 0 | it + fc | fc <- corpusFileCounts );
91+ }
92+
93+ public int totalCorpusLines () {
94+ Corpus corpus = getCorpus ();
95+ corpusCounts = { < p , v , lc , fc > | < p , v , lc , fc > <- getSortedCounts (), p in corpus <0 >, v := corpus [p ] };
96+ corpusLineCounts = corpusCounts <2 >;
97+ return ( 0 | it + fc | fc <- corpusLineCounts );
5498}
0 commit comments