#!/usr/bin/awk # for each class, this script computes the constraint and the measures # that have to be given to music-dfs. we suppose that the class is in # the first column and that the instances are ordered by class. # Constraint : the growth rate. # for example, class=1 on iris : # 100/50*BCOUNT(X,{1--50})/BCOUNT(X,{51--150}) # measures : CAEP specifies that each pattern contributes to # $ rho / (1 + rho) * support_c $ (relative support in the class) # so the first measure we require is : # 100/50*BCOUNT(X,{1--50})/BCOUNT(X,{51--150})/(100/50*BCOUNT(X,{1--50})/BCOUNT(X,{51--150}) + 1)*BCOUNT(X,{1--50})/50 # the second measure is an alternate one, if the pattern is jumping, # and we require the relative support in the class. # BCOUNT(X,{1--50})/50 # an AWK script checks if the pattern is jumping, and substitute the # relative support. BEGIN{ class = ARGV[1]; ARGV[1] = ARGV[2]; ARGC--; } NR == 1{ back = $1; debut[1] = 1; nclass = 1; next; } { if ($1 != back){ taille[nclass] = NR - debut[nclass]; nclass ++; debut[nclass] = NR; back = $1; } } END{ taille[nclass] = NR - debut[nclass ] + 1; if (class == 1){ print growthRate1(taille[1], NR - taille[1], debut[1], debut[2] - 1, debut[2], NR); print mesure1(taille[1], NR - taille[1], debut[1], debut[2] - 1, debut[2], NR); print support(taille[1], debut[1], debut[2] - 1); } for (i = 2; i < nclass; i ++){ if (class == i){ print growthRate2(taille[i], NR - taille[i], debut[i] , debut[i + 1] - 1, debut[1], debut[i] - 1, debut[i + 1], NR); print mesure2(taille[i], NR - taille[i], debut[i] , debut[i + 1] - 1, debut[1], debut[i] - 1, debut[i + 1], NR); print support(taille[i], debut[i] , debut[i + 1] - 1); } } if (class == nclass){ print growthRate1(taille[nclass], NR - taille[nclass], debut[nclass], NR, debut[1], debut[nclass] - 1); print mesure1(taille[nclass], NR - taille[nclass], debut[nclass], NR, debut[1], debut[nclass] - 1); print support(taille[nclass], debut[nclass], NR); } } function growthRate1(d1, d2, start1, end1, start2, end2){ return d2 "/" d1 "*BCOUNT(X,{" start1 "--" end1 "})/BCOUNT(X,{" start2 "--" end2 "})"; } function growthRate2(d1, d2, start1, end1, start2, end2, start3, end3){ return d2 "/" d1 "*BCOUNT(X,{" start1 "--" end1 "})/BCOUNT(X,{" start2 "--" end2 ", " start3 "--" end3 "})"; } # cf. CAEP function mesure1(d1, d2, start1, end1, start2, end2){ gr = growthRate1(d1, d2, start1, end1, start2, end2); return gr "/(" gr " + 1)*BCOUNT(X,{" start1 "--" end1 "})/" d1; } function mesure2(d1, d2, start1, end1, start2, end2, start3, end3){ gr = growthRate2(d1, d2, start1, end1, start2, end2, start3, end3); return gr "/((" gr ") + 1)*BCOUNT(X,{" start1 "--" end1 "})/" d1; } # support dans la classe function support(d1, start1, end1){ return "BCOUNT(X,{" start1 "--" end1 "})/" d1; }