PK z:META-INF/MANIFEST.MFMLK-. K-*ϳR03rI,. H,ɰR(ONJ, NMIMR()*MPKsk?=PK w:e~#raykernel/config/DocinfConfig.class1raykernel/config/DocinfConfigjava/lang/Object MAX_DEPTHIMAX_EXNS_PER_METHODMAX_PATHS_PER_DOC MAX_TO_VISIT ConstantValued()VCode      LineNumberTableLocalVariableTable   thisLraykernel/config/DocinfConfig; SourceFileDocinfConfig.java!       :    /* PK t: 2RM"raykernel/config/DocinfConfig.javapackage raykernel.config; public class DocinfConfig { public static int MAX_DEPTH = 10; public static int MAX_EXNS_PER_METHOD = 5; public static int MAX_PATHS_PER_DOC = 5; public static final int MAX_TO_VISIT = 100; } PK w:zjI} raykernel/config/Config.class1raykernel/config/Configjava/lang/ObjectconfLraykernel/util/TagFile;()VCode raykernel/util/TagFile  java/io/Fileraykernel.conf  (Ljava/lang/String;)V  (Ljava/io/File;)V  LineNumberTableLocalVariableTable  thisLraykernel/config/Config; debugMode()Z" debug_output $ %& getBoolean(Ljava/lang/String;)Zget&(Ljava/lang/String;)Ljava/lang/String; * +, getValues$(Ljava/lang/String;)Ljava/util/List; .0/java/util/List 1 isEmpty .3 '4(I)Ljava/lang/Object;6java/lang/StringkeyLjava/lang/String;valuesLjava/util/List;LocalVariableTypeTable$Ljava/util/List;getAll Signature8(Ljava/lang/String;)Ljava/util/List;getBenchDirectory()Ljava/io/File;C benchmarkdir E '( GIHraykernel/util/Tools JKmakeDir"(Ljava/lang/String;)Ljava/io/File;taggetClassPathDelimiter()Ljava/lang/String; PRQraykernel/util/Env S runningWindowsU;W:getDefaultClassifier()Lweka/classifiers/Classifier;[ classifier]bayes 5_ `aequals(Ljava/lang/Object;)Zc!weka/classifiers/bayes/NaiveBayes bfrandomh"raykernel/ml/core/RandomClassifier gk#weka/classifiers/functions/Logistic jtypegetWorkingDirectorypjava/lang/StringBuilderrbasedir 5t uvvalueOf&(Ljava/lang/Object;)Ljava/lang/String; oy/work o{ |}append-(Ljava/lang/String;)Ljava/lang/StringBuilder; o NtoString SourceFile Config.java!   8 Y Y   /*     ) !# '( t"*)L+ +-+25"789:; 9< =,>? 2*)" 78 @A ) BDF' %& 2*#, L8 MN 4 OTV12 3 XY n0ZDK*\^ bYd*e^ gYijYl9;<= >(@ *m8 nA ;oYqDswxz~FEPK yn:FVraykernel/config/Config.javapackage raykernel.config; import java.io.File; import java.util.List; import raykernel.ml.core.RandomClassifier; import raykernel.util.TagFile; import raykernel.util.Tools; import weka.classifiers.Classifier; import weka.classifiers.bayes.NaiveBayes; import weka.classifiers.functions.Logistic; public class Config { private static TagFile conf = new TagFile(new File("raykernel.conf")); public static boolean debugMode() { return conf.getBoolean("debug_output"); } public static String get(String key) { List values = conf.getValues(key); if (values == null || values.isEmpty()) return null; return values.get(0); } public static List getAll(String key) { return conf.getValues(key); } public static File getBenchDirectory() { return Tools.makeDir(Config.get("benchmarkdir")); } public static boolean getBoolean(String tag) { return conf.getBoolean(tag); } public static String getClassPathDelimiter() { if (raykernel.util.Env.runningWindows()) return ";"; return ":"; } public static Classifier getDefaultClassifier() { String type = Config.get("classifier"); if (type.equals("bayes")) return new NaiveBayes(); else if (type.equals("random")) return new RandomClassifier(); else return new Logistic(); } public static File getWorkingDirectory() { return Tools.makeDir(Config.get("basedir") + "/work"); } } PK w:ɴ!raykernel/config/SootConfig.class19raykernel/config/SootConfigjava/lang/Object()VCode  LineNumberTableLocalVariableTablethisLraykernel/config/SootConfig; setClasspath#(Lraykernel/experiment/Benchmark;)V raykernel/experiment/Benchmark  getClasspath()Ljava/lang/String;  soot/Scene v()Lsoot/Scene;  setSootClassPath(Ljava/lang/String;)V!java/lang/StringBuilder#set soot classpath to: %  ' ()append-(Ljava/lang/String;)Ljava/lang/StringBuilder; + ,toString .0/raykernel/io/Out 12println(Ljava/lang/Object;)Vb Lraykernel/experiment/Benchmark;cpLjava/lang/String; SourceFileSootConfig.java!/*   ` *L+ Y"$+&*-     345678PK t:w- raykernel/config/SootConfig.javapackage raykernel.config; import raykernel.experiment.Benchmark; import soot.Scene; public class SootConfig { public static void setClasspath(Benchmark b) { //String cp = Scene.v().getSootClassPath() + Config.getClassPathDelimiter() + b.getClasspath(); String cp = b.getClasspath(); Scene.v().setSootClassPath(cp); raykernel.io.Out.println("set soot classpath to: " + cp); } } PK y:'Be33"raykernel/config/GlobalStats.class1Jraykernel/config/GlobalStatsjava/lang/ObjectbugCountI classifyModeZmax_class_per_src max_src_files min_scoreF newVersions PATH_DIFFLjava/lang/String;startJ()VCode        8ѷ  ! #("C:\Program Files\GnuWin32\bin\diff.exe" %  ) LineNumberTableLocalVariableTable . ,thisLraykernel/config/GlobalStats;endTimer()J4java/lang/IllegalStateException6&Tried to end timer before starting it! 38 ,9(Ljava/lang/String;)V;java/util/Date :. :> ?2getTimedLjava/util/Date;finishtotal minimiseScore(F)Fscore startTimer SourceFileGlobalStats.java!       g'ȳ "$&(*&    &+,/*-*+ /0 12-( 3Y57:Y " "*'( )+  F GB:Y()VCode   version_bug  LineNumberTableLocalVariableTablethis ?@append-(Ljava/lang/String;)Ljava/lang/StringBuilder; "B CDgetFile()Ljava/io/File; FHG java/io/File IJgetAbsolutePath()Ljava/lang/String;L" " "N OD getNewVersionQ" +S TJtoString VXWjava/lang/Runtime YZ getRuntime()Ljava/lang/Runtime; V\ ]^exec'(Ljava/lang/String;)Ljava/lang/Process; `bajava/lang/Exception c printStackTraceejava/io/BufferedReadergjava/io/InputStreamReader ikjjava/lang/Process lmgetInputStream()Ljava/io/InputStream; fo p(Ljava/io/InputStream;)V dr s(Ljava/io/Reader;)Vu- 3w xy startsWith(Ljava/lang/String;)Z{<}> 3 indexOf(I)I 3  substring(II)Ljava/lang/String;, 3 split java/lang/Integer parseInt(Ljava/lang/String;)I " getLine-(I)Lraykernel/apps/readability/code/CodeLine;)raykernel/ml/feature/StandardValueFeature (Ljava/lang/String;Z)V (raykernel/apps/readability/code/CodeLine  setFeature!(Lraykernel/ml/feature/Feature;)V " setBug(Z)V . bugCountIvb bug + ?(I)Ljava/lang/StringBuilder; raykernel/io/Out println(Ljava/lang/Object;)V "couldnt figure: d JreadLine d closejava/lang/NumberFormatExceptionblock Lraykernel/ml/feature/Trainable;codefile*Lraykernel/apps/readability/code/CodeFile;sprocLjava/lang/Process;eLjava/lang/Exception;brLjava/io/BufferedReader;lineanumsnumarray[Ljava/lang/String;elementline_numnfe!Ljava/lang/NumberFormatException; SourceFileVersionBugDetector.java!  = * *     0  ! +" $Y&+"M,'+Y-28;=,AE=K=,ME=P=RN:U-[: :_dYfYhnq:tvzv|va~6 d~6 c~6::  Y: 6 6 [  2:  6,Y*,`+Y8R,Y*   : +Y8=RY::S\_`RU{~`)"=#L"P%S)_,a/f2k3l5<?ADFHKMPSVX\^_ac#e8hH\UkWmk<vq~sxmP1S.as  N GW PK ;v:(~f f ?raykernel/apps/readability/bugdetectors/VersionBugDetector.javapackage raykernel.apps.readability.bugdetectors; import java.io.BufferedReader; import java.io.InputStreamReader; import raykernel.apps.readability.code.CodeFile; import raykernel.config.GlobalStats; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; public class VersionBugDetector implements FeatureDetector { String name = "version_bug"; public String[] featureNames() { return Common.makeSingletonArray("simple_bug"); } public void runDetector(Trainable block) { if (!(block instanceof CodeFile)) throw new IllegalArgumentException(); CodeFile codefile = (CodeFile) block; if (!codefile.hasNewVersion()) return; //diff new and ond version String s = GlobalStats.PATH_DIFF + " \"" + codefile.getFile().getAbsolutePath() + "\" \"" + codefile.getNewVersion().getAbsolutePath() + "\""; Process proc = null;; try { proc = Runtime.getRuntime().exec(s); //proc.waitFor(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } if (proc == null) return; BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream())); String line; try { while ((line = br.readLine()) != null) { if (line.startsWith("-") || line.startsWith("<") || line.startsWith(">")) { continue; } int a = line.indexOf('a'); if (a < 0) { a = line.indexOf('d'); } if (a < 0) { a = line.indexOf('c'); } if (a < 0) { //io.Out.println("diff not working as expected for : " + line); continue; } String nums = line.substring(0, a); String[] numarray = nums.split(","); try { for (String element : numarray) { int line_num = Integer.parseInt(element); codefile.getLine(line_num).setFeature(new StandardValueFeature(name, true)); codefile.setBug(true); GlobalStats.bugCount++; raykernel.io.Out.println("vb bug " + GlobalStats.bugCount); ; codefile.setFeature(new StandardValueFeature(name, true)); } } catch (java.lang.NumberFormatException nfe) { raykernel.io.Out.println("couldnt figure: " + line); } } br.close(); } catch (Exception e) { //io.Out.println("error reading files: " + e); } } } PK w:' - - <raykernel/apps/readability/bugdetectors/WesBugDetector.class16raykernel/apps/readability/bugdetectors/WesBugDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetector path_to_jilLjava/lang/String;name()VCode./home/rlb7g/workspace/FeatureBugFinder/bin/jil  LineNumberTableLocalVariableTable   jil  this8Lraykernel/apps/readability/bugdetectors/WesBugDetector; featureNames()[Ljava/lang/String; simple_bug !#"raykernel/util/Common $%makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)V)(raykernel/apps/readability/code/CodeFile+"java/lang/IllegalArgumentException * (. /0getFile()Ljava/io/File;2java/lang/StringBuilder 465java/lang/String 78valueOf&(Ljava/lang/Object;)Ljava/lang/String; 1: ;(Ljava/lang/String;)V= 1? @Aappend-(Ljava/lang/String;)Ljava/lang/StringBuilder; CED java/io/File FGgetAbsolutePath()Ljava/lang/String; 1I JGtoString LNMjava/lang/Runtime OP getRuntime()Ljava/lang/Runtime; LR STexec'(Ljava/lang/String;)Ljava/lang/Process;Vjava/io/BufferedReaderXjava/io/InputStreamReader Z\[java/lang/Process ]^getInputStream()Ljava/io/InputStream; W` a(Ljava/io/InputStream;)V Uc d(Ljava/io/Reader;)VfRAYBUSE 4h ij startsWith(Ljava/lang/String;)Z 4l m%split oqpjava/lang/Integer rsparseInt(Ljava/lang/String;)I (u vwgetLine-(I)Lraykernel/apps/readability/code/CodeLine;y)raykernel/ml/feature/StandardValueFeature x{ |(Ljava/lang/String;Z)V ~(raykernel/apps/readability/code/CodeLine  setFeature!(Lraykernel/ml/feature/Feature;)V raykernel/config/GlobalStats bugCountI U GreadLine U closejava/lang/NumberFormatExceptionjava/io/IOExceptionblock Lraykernel/ml/feature/Trainable;codefile*Lraykernel/apps/readability/code/CodeFile;fLjava/io/File;sprocLjava/lang/Process;brLjava/io/BufferedReader;lineline_s[Ljava/lang/String;line_num SourceFileWesBugDetector.java!    *    = **    0  &'  +( *Y,+(M,-N1Y39<>-B>H:KQ:UYWYY_b:Aeg7<k:2n6 , txY*z}`: Y::lJ!#(7*A,V0Y2c4l8u9;=0EHLp 7sAiVTY> l+u PK ;v:&i  ;raykernel/apps/readability/bugdetectors/WesBugDetector.javapackage raykernel.apps.readability.bugdetectors; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import raykernel.apps.readability.code.CodeFile; import raykernel.config.GlobalStats; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; public class WesBugDetector implements FeatureDetector { public static String path_to_jil = "/home/rlb7g/workspace/FeatureBugFinder/bin/jil"; String name = "jil"; public String[] featureNames() { return Common.makeSingletonArray("simple_bug"); } public void runDetector(Trainable block) { if (!(block instanceof CodeFile)) throw new IllegalArgumentException(); CodeFile codefile = (CodeFile) block; File f = codefile.getFile(); try { String s = path_to_jil + " " + f.getAbsolutePath(); Process proc = Runtime.getRuntime().exec(s); BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream())); String line; while ((line = br.readLine()) != null) { if (line.startsWith("RAYBUSE")) { String[] line_s = line.split(" "); try { int line_num = Integer.parseInt(line_s[2]); codefile.getLine(line_num).setFeature(new StandardValueFeature(name, true)); GlobalStats.bugCount++; } catch (java.lang.NumberFormatException nfe) { } } } br.close(); } catch (IOException e) { } } } PK w:sjl@@?raykernel/apps/readability/bugdetectors/SimpleBugDetector.class1P9raykernel/apps/readability/bugdetectors/SimpleBugDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetectornameLjava/lang/String;()VCode   simple_bug  LineNumberTableLocalVariableTablethis;Lraykernel/apps/readability/bugdetectors/SimpleBugDetector; featureNames()[Ljava/lang/String; raykernel/util/Common makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)V!2raykernel/apps/readability/code/TrainableCodeBlock # $%iterator()Ljava/util/Iterator; ')(java/util/Iterator *+next()Ljava/lang/Object;-(raykernel/apps/readability/code/CodeLine ,/ 01toString()Ljava/lang/String;3bug 576java/lang/String 89contains(Ljava/lang/CharSequence;)Z;)raykernel/ml/feature/StandardValueFeature := >(Ljava/lang/String;Z)V ,@ AB setFeature!(Lraykernel/ml/feature/Feature;)V 'D EFhasNext()Zb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;l*Lraykernel/apps/readability/code/CodeLine;Z SourceFileSimpleBugDetector.java!  = * *    0  W+ M,":A&,N-.246-:Y*<?-:Y*<?C"!$")$<(LV-4WWGHRIJ3KL$(3MNOPK t: >raykernel/apps/readability/bugdetectors/SimpleBugDetector.javapackage raykernel.apps.readability.bugdetectors; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; /** * Simply detects the presence of the string 'bug' * * @author rlb7g * */ public class SimpleBugDetector implements FeatureDetector { String name = "simple_bug"; public String[] featureNames() { return Common.makeSingletonArray("simple_bug"); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; for (CodeLine l : block) { boolean bug = l.toString().contains("bug"); if (bug) { l.setFeature(new StandardValueFeature(name, true)); } else { l.setFeature(new StandardValueFeature(name, false)); } } } } PK w:1ڽ>raykernel/apps/readability/bugdetectors/FindBugsDetector.class18raykernel/apps/readability/bugdetectors/FindBugsDetector'edu/umd/cs/findbugs/AbstractBugReporter$raykernel/ml/feature/FeatureDetector currBlock*Lraykernel/apps/readability/code/CodeFile;finder%Ledu/umd/cs/findbugs/IFindBugsEngine;()VCode   setPriorityThreshold(I)V findbugs.home findbugs_home raykernel/config/Config get&(Ljava/lang/String;)Ljava/lang/String; ! java/lang/System "# setProperty8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;% findbugs.jaws'true)edu/umd/cs/findbugs/FindBugs2 ( , .0/#edu/umd/cs/findbugs/IFindBugsEngine 12setBugReporter$(Ledu/umd/cs/findbugs/BugReporter;)V 465-edu/umd/cs/findbugs/DetectorFactoryCollection 78instance1()Ledu/umd/cs/findbugs/DetectorFactoryCollection; 4: ;  ensureLoaded .= >?setDetectorFactoryCollection2(Ledu/umd/cs/findbugs/DetectorFactoryCollection;)V ACB*edu/umd/cs/findbugs/config/UserPreferences DEcreateDefaultUserPreferences.()Ledu/umd/cs/findbugs/config/UserPreferences; .G HIsetUserPreferences/(Ledu/umd/cs/findbugs/config/UserPreferences;)VLineNumberTableLocalVariableTablethis:Lraykernel/apps/readability/bugdetectors/FindBugsDetector;up,Ledu/umd/cs/findbugs/config/UserPreferences; doReportBug$(Ledu/umd/cs/findbugs/BugInstance;)V SUTedu/umd/cs/findbugs/BugInstance VWgetPrimarySourceLineAnnotation,()Ledu/umd/cs/findbugs/SourceLineAnnotation; Y[Z(edu/umd/cs/findbugs/SourceLineAnnotation \] getSourceFile()Ljava/lang/String; _  acb(raykernel/apps/readability/code/CodeFile degetFile()Ljava/io/File; gih java/io/File j]getName lnmjava/lang/String opequals(Ljava/lang/Object;)Z Yr st isUnknown()Z Yv wx getStartLine()I Yz {x getEndLine a} ~getLines(II)Ljava/util/Iterator; java/util/Iterator next()Ljava/lang/Object;(raykernel/apps/readability/code/CodeLine)raykernel/ml/feature/StandardValueFeature  ] featureName (Ljava/lang/String;Z)V  setFeature!(Lraykernel/ml/feature/Feature;)V thasNext a raykernel/config/GlobalStats bugCountIjava/lang/StringBuilderfb bug (Ljava/lang/String;)V append(I)Ljava/lang/StringBuilder; ]toString raykernel/io/Out println(Ljava/lang/Object;)VfoundBug!Ledu/umd/cs/findbugs/BugInstance;startenditerLjava/util/Iterator;l*Lraykernel/apps/readability/code/CodeLine;LocalVariableTypeTable@Ljava/util/Iterator;findbugs featureNames()[Ljava/lang/String; raykernel/util/Common makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String;finish  gcgetRealBugReporter#()Ledu/umd/cs/findbugs/BugReporter; observeClass2(Ledu/umd/cs/findbugs/classfile/ClassDescriptor;)Varg0/Ledu/umd/cs/findbugs/classfile/ClassDescriptor;reportAnalysisError&(Ledu/umd/cs/findbugs/AnalysisError;)V#Ledu/umd/cs/findbugs/AnalysisError;reportMissingClassLjava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)V"java/lang/IllegalArgumentException  a t hasClassFileno class file for: -(Ljava/lang/String;)Ljava/lang/StringBuilder;. Cannot run FindBugs.edu/umd/cs/findbugs/Project  a  getClassFiles()Ljava/util/Iterator; g addFile(Ljava/lang/String;)Z .  setProject (Ledu/umd/cs/findbugs/Project;)V . execute java/lang/Exception printStackTraceblock Lraykernel/ml/feature/Trainable;codefilepLedu/umd/cs/findbugs/Project;maxcounteLjava/lang/Exception;$Ljava/util/Iterator; SourceFileFindBugsDetector.java!   R**W$&W*(Y*+*+*-39*+3<@L*++FJ. " $&(')1,7/C2G4Q5KRLMG NOPQ A+RX*^`fk+Rq+Ru=+Ry>*^d|: :Y**^Y*`YJ>9<>"?#A+B3G@ICKOL`IjQ}STUK>LM+p3h@[O @[] -JYK LM 0J^K LM  2DZJ cdK LM ,*JhK LM 5JnKLM 5JsKLM 5JxKLM p+a Yٿ+aM*,^,ښ"Yݷ,`f߶YN,:66-gW *+-*+ :JR}~ >?GMPSVhk|KRLMGSMMPJSG MMPK 4v:gѩ=raykernel/apps/readability/bugdetectors/FindBugsDetector.javapackage raykernel.apps.readability.bugdetectors; import java.io.File; import java.util.Iterator; import raykernel.apps.readability.code.CodeFile; import raykernel.apps.readability.code.CodeLine; import raykernel.config.Config; import raykernel.config.GlobalStats; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; import edu.umd.cs.findbugs.AbstractBugReporter; import edu.umd.cs.findbugs.AnalysisError; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.DetectorFactoryCollection; import edu.umd.cs.findbugs.FindBugs2; import edu.umd.cs.findbugs.IFindBugsEngine; import edu.umd.cs.findbugs.Priorities; import edu.umd.cs.findbugs.Project; import edu.umd.cs.findbugs.classfile.ClassDescriptor; import edu.umd.cs.findbugs.config.UserPreferences; public class FindBugsDetector extends AbstractBugReporter implements FeatureDetector { CodeFile currBlock; IFindBugsEngine finder; public FindBugsDetector() { this.setPriorityThreshold(Priorities.IGNORE_PRIORITY); System.setProperty("findbugs.home", Config.get("findbugs_home")); System.setProperty("findbugs.jaws", "true"); finder = new FindBugs2(); finder.setBugReporter(this); // Load plugins DetectorFactoryCollection.instance().ensureLoaded(); // Set the DetectorFactoryCollection finder.setDetectorFactoryCollection(DetectorFactoryCollection.instance()); //Set up user prefrences UserPreferences up = UserPreferences.createDefaultUserPreferences(); //up.enableAllDetectors(true); finder.setUserPreferences(up); } protected void doReportBug(BugInstance foundBug) { if (!foundBug.getPrimarySourceLineAnnotation().getSourceFile().equals(currBlock.getFile().getName())) //System.err.println("Bug reported for: " + foundBug.getPrimarySourceLineAnnotation().getSourceFile() + // " but working on : " + currBlock.getFile().getName()); return; if (foundBug.getPrimarySourceLineAnnotation().isUnknown()) return; int start = foundBug.getPrimarySourceLineAnnotation().getStartLine(); int end = foundBug.getPrimarySourceLineAnnotation().getEndLine(); //io.Out.println("unknown = " + foundBug.getPrimarySourceLineAnnotation().isUnknown() ); //io.Out.println("start-end = " + start + "-" + end ); Iterator iter = currBlock.getLines(start - 1, end); while (iter.hasNext()) { CodeLine l = iter.next(); l.setFeature(new StandardValueFeature(featureName(), true)); //io.Out.println(l.toString()); } currBlock.setFeature(new StandardValueFeature(featureName(), true)); GlobalStats.bugCount++; raykernel.io.Out.println("fb bug " + GlobalStats.bugCount); } public String featureName() { return "findbugs"; } public String[] featureNames() { return Common.makeSingletonArray("findbugs"); } public void finish() { System.gc(); //probably not needed } public BugReporter getRealBugReporter() { return this; } public void observeClass(ClassDescriptor arg0) { } public void reportAnalysisError(AnalysisError arg0) { } public void reportMissingClass(String arg0) { } public void runDetector(Trainable block) { if (!(block instanceof CodeFile)) throw new IllegalArgumentException(); CodeFile codefile = (CodeFile) block; currBlock = codefile; if (!codefile.hasClassFile()) { raykernel.io.Out.println("no class file for: " + codefile.getFile().getName() + ". Cannot run FindBugs."); return; } //io.Out.println("running fb on " + codefile.getFile().getName()); //create project with the .class files Project p = new Project(); Iterator iter = codefile.getClassFiles(); int max = 3; int count = 0; while (iter.hasNext() && count < max) { p.addFile(iter.next().toString()); count++; } finder.setProject(p); try { finder.execute(); } catch (Exception e) { e.printStackTrace(); } } } PK w:3GYM M (raykernel/ml/core/TrainableAdapter.class1"raykernel/ml/core/TrainableAdapterjava/lang/Objectraykernel/ml/feature/TrainableattrLweka/core/Attribute; featureMapLjava/util/Map; SignatureALjava/util/Map;featuresLjava/util/Set;#Ljava/util/Set;()VCode  java/util/TreeMap   java/util/TreeSet   LineNumberTableLocalVariableTablethis$Lraykernel/ml/core/TrainableAdapter;addFeatureName(Ljava/lang/String;)V &(' java/util/Set )*add(Ljava/lang/Object;)Z feature_nameLjava/lang/String;featureIterator()Ljava/util/Iterator;6()Ljava/util/Iterator; 132 java/util/Map 45values()Ljava/util/Collection; 798java/util/Collection :.iteratorfeatureNamesIterator*()Ljava/util/Iterator; &9getClassAttribute()Lweka/core/Attribute; A Cweka/core/FastVector BE F(I)VHless BJ KL addElement(Ljava/lang/Object;)VNmorePweka/core/AttributeRbug OT U+(Ljava/lang/String;Lweka/core/FastVector;)VclassValLweka/core/FastVector; getFeature2(Ljava/lang/String;)Lraykernel/ml/feature/Feature; 1[ \]get&(Ljava/lang/Object;)Ljava/lang/Object;_raykernel/ml/feature/Feature featurename getInstance;(Ljava/lang/String;[Ljava/lang/String;)Lweka/core/Instance;dweka/core/Instance cE g XYi)raykernel/ml/feature/StandardValueFeature hk l(Ljava/lang/String;F)V n >? ^p qrvalue()F ct uvsetValue(Lweka/core/Attribute;D)Vxjava.lang.String z|{java/lang/String }~contains(Ljava/lang/CharSequence;)Z ^ ? getAttribute class_feature[Ljava/lang/String;instLweka/core/Instance; classFeatureLraykernel/ml/feature/Feature; currFeatureIf setFeature!(Lraykernel/ml/feature/Feature;)V ^ name()Ljava/lang/String; 1 put8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; SourceFileTrainableAdapter.java!    Q**Y*Y !"#$D *+%W    !" +,-. /9*06 !";. <4 *=$  !">?|0@@BYDL+GI+MIOYQ+S@@)* ,-.0,2 0!"VWXYB*+Z^7 !"`,ab0 cY,`eN*+f:hY+ j:6-*mos,Y: 66A 2:wy**f:  hY+ j: -  os->< >@B#E&H4NHPRRUW]Yb[m`|Ne R!",  |u&bH4+,] H*++W jm !"PK 4v:px" 'raykernel/ml/core/TrainableAdapter.javapackage raykernel.ml.core; import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; import raykernel.ml.feature.Feature; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import weka.core.Attribute; import weka.core.FastVector; import weka.core.Instance; public class TrainableAdapter implements Trainable { static Attribute attr; Map featureMap = new TreeMap(); Set features = new TreeSet(); public void addFeatureName(String feature_name) { features.add(feature_name); } public Iterator featureIterator() { return featureMap.values().iterator(); } public Iterator featureNamesIterator() { return features.iterator(); } public Attribute getClassAttribute() { if (attr != null) return attr; FastVector classVal = new FastVector(2); classVal.addElement("less"); classVal.addElement("more"); attr = new Attribute("bug", classVal); return attr; } public Feature getFeature(String featurename) { return featureMap.get(featurename); } public Instance getInstance(String class_feature, String[] features) { Instance inst = new Instance(features.length + 1); Feature classFeature = getFeature(class_feature); if (classFeature == null) { classFeature = new StandardValueFeature(class_feature, 0); } int currFeature = 0; //first add bug feature inst.setValue(getClassAttribute(), classFeature.value()); //inst.setValue(currFeature++, classFeature.value()); //io.Out.println("class feature: " + getClassAttribute() + " " + classFeature.value()); //add the rest for (String feature_name : features) { if (feature_name.contains("java.lang.String")) { continue; } //io.Out.println("adding: " + feature_name); Feature f = getFeature(feature_name); if (f == null) { f = new StandardValueFeature(class_feature, 0); } //io.Out.println("index: " + f.getAttribute().index()); inst.setValue(f.getAttribute(), f.value()); //inst.setValue(currFeature++, f.value()); } return inst; } public void setFeature(Feature f) { featureMap.put(f.name(), f); //io.Out.println("added feature: (" + f.name() + ", " + f.value() + ")" ); } } PK :il!raykernel/ml/core/Evaluator.class1&raykernel/ml/core/Evaluatorjava/lang/Object$raykernel/ml/feature/FeatureDetectorjava/io/Serializable bug_scoresLjava/util/Vector; Signature%Ljava/util/Vector; classifierLweka/classifiers/Classifier; classNameLjava/lang/String;maxScoreFminScore nonbug_scores otherFeatures[Ljava/lang/String;scoreMapLjava/util/HashMap;FLjava/util/HashMap; trainingSetLweka/core/Instances; writeVector'(Ljava/util/Vector;Ljava/lang/String;)VCode  java/io/File " #$(Ljava/lang/String;)V&java/io/BufferedWriter(java/io/FileWriter '* #+(Ljava/io/File;)V %- #.(Ljava/io/Writer;)V 021java/util/Vector 34iterator()Ljava/util/Iterator; 687java/util/Iterator 9:next()Ljava/lang/Object;<java/lang/StringBuilder ;> #?()V ;A BCappend-(Ljava/lang/Object;)Ljava/lang/StringBuilder;E ;G BH-(Ljava/lang/String;)Ljava/lang/StringBuilder; ;J KLtoString()Ljava/lang/String; %N O$write 6Q RShasNext()Z %U V?flush XZYjava/lang/System [\errLjava/io/PrintStream;^could not write to: ;" acbjava/io/PrintStream d$println fhgjava/io/IOException i?printStackTraceLineNumberTableLocalVariableTablevfNamefLjava/io/File;brLjava/io/BufferedWriter;oLjava/lang/Object;eLjava/io/IOException;}(Lweka/classifiers/Classifier;Lraykernel/ml/feature/DetectorSuite;Lraykernel/ml/feature/DetectorSuite;Lweka/core/Instances;)V > 0> z |  ~    java/util/HashMap >      thisLraykernel/ml/core/Evaluator; featureSuite$Lraykernel/ml/feature/DetectorSuite;bugSuiteZ(Lweka/classifiers/Classifier;Lweka/core/Instances;Ljava/lang/String;[Ljava/lang/String;)V     featureNames()[Ljava/lang/String;  getClass()Ljava/lang/Class; java/lang/Class L getSimpleName raykernel/util/Common makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; getClassFor#(Lraykernel/ml/feature/Trainable;)I get&(Ljava/lang/Object;)Ljava/lang/Object;java/lang/Float intValue()I Lraykernel/ml/feature/Trainable; getScoreFor#(Lraykernel/ml/feature/Trainable;)F  floatValue()F getScoreMap()Ljava/util/HashMap;H()Ljava/util/HashMap;printEvaluation(Ljava/util/Collection;)V;(Ljava/util/Collection;)V 2java/util/Collectionraykernel/ml/feature/Trainable  getFeature2(Ljava/lang/String;)Lraykernel/ml/feature/Feature; raykernel/ml/feature/Feature value ratio : ; B(F)Ljava/lang/StringBuilder; raykernel/io/Out d(Ljava/lang/Object;)VfilesLjava/util/Collection;bugCountIsumValuesBugLines nonBugCountsumVauesNonBugLinesbugscore avgBugScoreavgNonBugScoreratioLocalVariableTypeTable8Ljava/util/Collection; runDetector#(Lraykernel/ml/feature/Trainable;)V  getInstance;(Ljava/lang/String;[Ljava/lang/String;)Lweka/core/Instance; weka/core/Instance  setDataset(Lweka/core/Instances;)V weka/classifiers/Classifier distributionForInstance(Lweka/core/Instance;)[D raykernel/config/GlobalStats  minimiseScore(F)F valueOf(F)Ljava/lang/Float; 0 add(Ljava/lang/Object;)Z  put8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; )raykernel/ml/feature/StandardValueFeature   #(Ljava/lang/String;F)V   setFeature!(Lraykernel/ml/feature/Feature;)V hjava/lang/Exceptionblockprob[DiLweka/core/Instance;classFetLraykernel/ml/feature/Feature;Ljava/lang/Exception; writeScores'(Ljava/lang/String;Ljava/lang/String;)V !  fName_bug fName_nobug SourceFileEvaluator.java!        pY+!M%Y'Y,),N*/:$5:-;Y=@DFIMP-TNW;Y]_+FI`-e QTfj* $&+(C&M+T.U0k1o4k>pl pm gno;pq+rsUtu#v;*w*0Yxy* {* }*0Yx*Y*+*j& C5:;=$?/E4F:Gk4;; ;;;#E*w*0Yxy* {* }*0Yx*Y*+*,*-*j. L5:;=$?/N4O9P>QDRk4EE EEE8*jUk C*+jZknC*+j_kn /*jdk   = F6 8+:L5:*8*8  % bF  b8P%n8n8n8;Y̷_DFIѱjJlmop s!u1vBxIzL{TW^shnv}kz  !=n1-B n)v!} ^+**N-**-M,18+*: *yW*W*} *}*{ *{*+W+Y* 2 N-jF )5DTakt~kH )5utW*y+ *, jk "#$%PK :.yy raykernel/ml/core/Evaluator.javapackage raykernel.ml.core; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.Serializable; import java.util.Collection; import java.util.HashMap; import java.util.Vector; import raykernel.config.GlobalStats; import raykernel.ml.feature.DetectorSuite; import raykernel.ml.feature.Feature; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; import weka.classifiers.Classifier; import weka.core.Instance; import weka.core.Instances; /** * Evaluate how well a feature suite works relative to a bug detector * Unfortunatelly this is a bit hackish */ public class Evaluator implements FeatureDetector, Serializable { public static void writeVector(Vector v, String fName) { File f = new File(fName); try { BufferedWriter br = new BufferedWriter(new FileWriter(f)); for (Object o : v) { br.write(o + "\n"); } br.flush(); } catch (IOException e) { System.err.println("could not write to: " + fName); e.printStackTrace(); } } Vector bug_scores = new Vector(); Classifier classifier; private String className; float maxScore = 0; float minScore = 1; Vector nonbug_scores = new Vector(); private String[] otherFeatures; HashMap scoreMap = new HashMap(); Instances trainingSet; public Evaluator(Classifier classifier, DetectorSuite featureSuite, DetectorSuite bugSuite, Instances trainingSet) { this.classifier = classifier; this.trainingSet = trainingSet; } /** * uses default features */ public Evaluator(Classifier classifier, Instances trainingSet, String className, String... otherFeatures) { this.classifier = classifier; this.trainingSet = trainingSet; this.className = className; this.otherFeatures = otherFeatures; } public String[] featureNames() { return Common.makeSingletonArray(classifier.getClass().getSimpleName()); } public int getClassFor(Trainable f) { return scoreMap.get(f).intValue(); } public float getScoreFor(Trainable f) { return scoreMap.get(f); } public HashMap getScoreMap() { return scoreMap; } public void printEvaluation(Collection files) { //normalizeScores(); int bugCount = 0; float sumValuesBugLines = 0; int nonBugCount = 0; float sumVauesNonBugLines = 0; //My Evauator for (Trainable f : files) { float bug = f.getFeature(className).value(); //does it contain bug? float score = scoreMap.get(f); //score it was given if (bug > 0) { bugCount++; sumValuesBugLines += score; } else { nonBugCount++; sumVauesNonBugLines += score; } } float avgBugScore = sumValuesBugLines / bugCount; float avgNonBugScore = sumVauesNonBugLines / nonBugCount; float ratio = avgBugScore / avgNonBugScore; raykernel.io.Out.println("ratio : " + ratio + "\n"); } /* public double getProbFor( Trainable block, int classNum ) { Instance i = block.getInstance( this.className, otherFeatures ); i.setDataset( trainingSet ); double[] prob = { -1, -1 }; try{ prob = classifier.distributionForInstance( i ); } catch( Exception e ) { System.err.println("classification failed"); e.printStackTrace(); } return prob[classNum]; } */ public void runDetector(Trainable block) { double[] prob; try { Instance i = block.getInstance(this.className, otherFeatures); i.setDataset(trainingSet); //io.Out.println("to classify: " + i); float score; //if (Config.classifyMode) //{ prob = classifier.distributionForInstance(i); score = GlobalStats.minimiseScore((float) prob[0]); //} //else //{ // score = (float) classifier.classifyInstance(i); //} Feature classFet = block.getFeature(className); if (classFet != null && classFet.value() > 0) { bug_scores.add(score); } else { nonbug_scores.add(score); } //record min / max if (score < minScore) { minScore = score; } else if (score > maxScore) { maxScore = score; } scoreMap.put(block, score); block.setFeature(new StandardValueFeature(featureNames()[0], score)); } catch (Exception e) { e.printStackTrace(); } } public void writeScores(String fName_bug, String fName_nobug) { writeVector(this.bug_scores, fName_bug); writeVector(this.nonbug_scores, fName_nobug); } /* public void showScores(int limit) { int c=0; io.Out.println(scores); for( float s : scores) { io.Out.println(s); c++; if( c > limit ) break; } } */ } PK w:4WTT(raykernel/ml/core/RandomClassifier.class14"raykernel/ml/core/RandomClassifierweka/classifiers/ClassifierrLjava/util/Random;()VCode   java/util/Random  LineNumberTableLocalVariableTablethis$Lraykernel/ml/core/RandomClassifier;buildClassifier(Lweka/core/Instances;)V Exceptionsjava/lang/Exception instancesLweka/core/Instances;classifyInstance(Lweka/core/Instance;)D  !nextInt(I)IiLweka/core/Instance;distributionForInstance(Lweka/core/Instance;)[D ' () nextDouble()DdDret[D getRevision()Ljava/lang/String;1rev 1 SourceFileRandomClassifier.java! B* * Y     5 > *  "#$% j*&IY(RY(gR:*"#*+,-./ -0  23PK t:TT'raykernel/ml/core/RandomClassifier.javapackage raykernel.ml.core; import java.util.Random; import weka.classifiers.Classifier; import weka.core.Instance; import weka.core.Instances; public class RandomClassifier extends Classifier { Random r = new Random(); public void buildClassifier(Instances instances) throws Exception { } public double classifyInstance(Instance i) { return r.nextInt(2); } public double[] distributionForInstance(Instance i) { double d = r.nextDouble(); double[] ret = {d, 1 - d}; return ret; } public String getRevision() { return "rev 1"; } } PK w:嫁 raykernel/ml/core/Trainer.class1raykernel/ml/core/Trainerjava/lang/ObjectblocksLjava/util/Collection; Signature8Ljava/util/Collection; classFeatureLjava/lang/String; otherFeatures[Ljava/lang/String; trainingSetLweka/core/Instances;extractInstancesR(Ljava/util/Collection;Ljava/lang/String;[Ljava/lang/String;)Lweka/core/Instances;t(Ljava/util/Collection;Ljava/lang/String;[Ljava/lang/String;)Lweka/core/Instances;Codeweka/core/FastVector  ()V java/util/Collection iterator()Ljava/util/Iterator; "!java/util/Iterator #$next()Ljava/lang/Object;&raykernel/ml/feature/Trainable %( )*getClassAttribute()Lweka/core/Attribute; , -. addElement(Ljava/lang/Object;)V 021raykernel/ml/feature/Feature 34 getAttribute)(Ljava/lang/String;)Lweka/core/Attribute;6weka/core/Instances8 some_name : ;<size()I 5> ?,(Ljava/lang/String;Lweka/core/FastVector;I)V 5A BC setClassIndex(I)V %E FG getInstance;(Ljava/lang/String;[Ljava/lang/String;)Lweka/core/Instance; 5I JKadd(Lweka/core/Instance;)V M NOhasNext()ZLineNumberTableLocalVariableTablefsvecLweka/core/FastVector;fNameinst Lraykernel/ml/feature/Trainable;instLweka/core/Instance;LocalVariableTypeTable>(Ljava/util/Collection;Ljava/lang/String;[Ljava/lang/String;)V  _ a c thisLraykernel/ml/core/Trainer;classification_feature((Ljava/lang/String;[Ljava/lang/String;)V addTrainable#(Lraykernel/ml/feature/Trainable;)Vkjava/util/LinkedList j n Jo(Ljava/lang/Object;)ZgetTrainingSet()Lweka/core/Instances; s  u trainClassifier (Lweka/classifiers/Classifier;)V y pq {}|weka/classifiers/Classifier ~buildClassifier(Lweka/core/Instances;)V java/lang/System errLjava/io/PrintStream;unknown weka error! java/io/PrintStream println(Ljava/lang/String;)V java/lang/Exception printStackTrace CexitcLweka/classifiers/Classifier;eLjava/lang/Exception; SourceFile Trainer.java!  EYN-*%'+,Y:662:-/+5Y7-*9h=:@*:!%:+,D:HLP2 "3$<"F)[*a,x.2,5QRR  ST3 U [<VxWXYZ[ R\l*]*,^*-`*+bP@B CDEQ*def  gY*]*+^*,`PGI JKQ def  hi^*b*jYlb*b+mWPOQTUQdeWXpqQ*r**b*^*`tr*rPY[^Q devw*xM+,zN- Pci kmnorQ*deVPK 4v:.. . raykernel/ml/core/Trainer.javapackage raykernel.ml.core; import java.util.Collection; import java.util.LinkedList; import raykernel.ml.feature.Feature; import raykernel.ml.feature.Trainable; import weka.classifiers.Classifier; import weka.core.FastVector; import weka.core.Instance; import weka.core.Instances; /** * Used to train a classifier to recognise bugs found by a bug detector from * featurws found by a suite of featureDetectors * */ public class Trainer { public static Instances extractInstances(Collection fs, String classFeature, String[] otherFeatures) { //*** Setup Attriibutes //Iterator features = fs.iterator().next().featureIterator(); //create attribute vector FastVector vec = new FastVector(); //add bug feature first vec.addElement(fs.iterator().next().getClassAttribute()); //now add the others for (String fName : otherFeatures) { vec.addElement(Feature.getAttribute(fName)); } // *** Get Instances Instances ins = new Instances("some_name", vec, fs.size() * 20); ins.setClassIndex(0); for (Trainable t : fs) { Instance inst = t.getInstance(classFeature, otherFeatures); //io.Out.println("instance: " + inst); ins.add(inst); } return ins; } Collection blocks; String classFeature; String[] otherFeatures; Instances trainingSet; @SuppressWarnings("unchecked") public Trainer(Collection blocks, String classification_feature, String[] otherFeatures) { classFeature = classification_feature; this.otherFeatures = otherFeatures; this.blocks = blocks; } public Trainer(String classification_feature, String[] otherFeatures) { classFeature = classification_feature; this.otherFeatures = otherFeatures; } public void addTrainable(Trainable t) { if (blocks == null) { blocks = new LinkedList(); } blocks.add(t); } public Instances getTrainingSet() { if (trainingSet == null) { trainingSet = extractInstances(blocks, classFeature, otherFeatures); } return trainingSet; } public void trainClassifier(Classifier c) { Instances ins = getTrainingSet(); //io.Out.println("*** Training Set ***\n" + ins + "\n**********\n" ); try { c.buildClassifier(ins); } catch (Exception e) { System.err.println("unknown weka error!"); e.printStackTrace(); System.exit(0); } } } PK w:Z)raykernel/ml/core/UniformClassifier.class1'#raykernel/ml/core/UniformClassifierweka/classifiers/ClassifierguessD()VCode    LineNumberTableLocalVariableTablethis%Lraykernel/ml/core/UniformClassifier;buildClassifier(Lweka/core/Instances;)V Exceptionsjava/lang/Exceptionarg0Lweka/core/Instances;classifyInstance(Lweka/core/Instance;)DiLweka/core/Instance;distributionForInstance(Lweka/core/Instance;)[Dret[D getRevision()Ljava/lang/String;$rev 1 SourceFileUniformClassifier.java! < * *     5 9*  XY* RY* gRM,   !" -# %&PK t:-CC(raykernel/ml/core/UniformClassifier.javapackage raykernel.ml.core; import weka.classifiers.Classifier; import weka.core.Instance; import weka.core.Instances; public class UniformClassifier extends Classifier { double guess = 0; public void buildClassifier(Instances arg0) throws Exception { // do nothing } public double classifyInstance(Instance i) { return guess; } public double[] distributionForInstance(Instance i) { double[] ret = {guess, 1 - guess}; return ret; } public String getRevision() { // TODO Auto-generated method stub return "rev 1"; } }PK w:uv!  )raykernel/ml/core/PerfectClassifier.class1O#raykernel/ml/core/PerfectClassifierweka/classifiers/Classifier classZeroLjava/util/HashSet; Signature)Ljava/util/HashSet;()VCode  java/util/HashSet   LineNumberTableLocalVariableTablethis%Lraykernel/ml/core/PerfectClassifier;buildClassifier(Lweka/core/Instances;)V Exceptionsjava/lang/Exceptionarg0Lweka/core/Instances;classifyInstance(Lweka/core/Instance;)D!java/lang/StringBuilder#input(classify) = % &(Ljava/lang/String;)V (*)weka/core/Instance +, classValue()D . /0append(D)Ljava/lang/StringBuilder; 2 34toString()Ljava/lang/String; 687raykernel/io/Out 9:println(Ljava/lang/Object;)ViLweka/core/Instance;distributionForInstance(Lweka/core/Instance;)[D@input = (B CD stringValue(I)Ljava/lang/String; F /G-(Ljava/lang/String;)Ljava/lang/StringBuilder;ret[D getRevisionLrev 1 SourceFilePerfectClassifier.java!  B* *Y     5 S Y"$+'-15+' !;<=> w- Y?$+AE15YRYRM,+'R,')#++- --;<# HIJ4 -K3 MNPK t:gE]](raykernel/ml/core/PerfectClassifier.javapackage raykernel.ml.core; import java.util.HashSet; import weka.classifiers.Classifier; import weka.core.Instance; import weka.core.Instances; public class PerfectClassifier extends Classifier { HashSet classZero = new HashSet(); public void buildClassifier(Instances arg0) throws Exception { /* Enumeration e = arg0.enumerateInstances(); while( e.hasMoreElements() ) { Instance i = (Instance) e.nextElement(); String classV = i.stringValue( i.classAttribute() ); //io.Out.println("training on = " + classV); } */ } public double classifyInstance(Instance i) { raykernel.io.Out.println("input(classify) = " + i.classValue()); return i.classValue(); } public double[] distributionForInstance(Instance i) { //String classV = i.stringValue( i.classAttribute() ); raykernel.io.Out.println("input = " + i.stringValue(0)); double[] ret = {0, 0}; ret[(int) i.classValue()] = 1; return ret; } public String getRevision() { // TODO Auto-generated method stub return "rev 1"; } } PK w:j,00%raykernel/ml/core/ValidationSet.class1-raykernel/ml/core/ValidationSetjava/lang/Object trainingDataLjava/util/List; Signature2Ljava/util/List;validationData()VCode  LineNumberTableLocalVariableTablethis!Lraykernel/ml/core/ValidationSet;addTrainingBlocks(Ljava/util/List;)V5(Ljava/util/List;)V  java/util/LinkedList  java/util/List  addAll(Ljava/util/Collection;)ZmoreDataLocalVariableTypeTablegetTrainingData()Ljava/util/List;4()Ljava/util/List;getValidationData ( setTrainingDatasetValidationData SourceFileValidationSet.java!   /*   p**Y*+W!" !#$% /* &$% /*' ) P*+ "#" * P*+' &' "  +,PK ;v:$raykernel/ml/core/ValidationSet.javapackage raykernel.ml.core; import java.util.LinkedList; import java.util.List; import raykernel.ml.feature.Trainable; public class ValidationSet { List trainingData; List validationData; public void addTrainingBlocks(List moreData) { if (trainingData == null) { trainingData = new LinkedList(); } trainingData.addAll(moreData); } public List getTrainingData() { return trainingData; } public List getValidationData() { return validationData; } public void setTrainingData(List trainingData) { this.trainingData = trainingData; } public void setValidationData(List validationData) { this.validationData = validationData; } } PK w:qɖ =raykernel/apps/readability/core/WholeProgramReadability.class17raykernel/apps/readability/core/WholeProgramReadabilityjava/lang/Object()VCode  LineNumberTableLocalVariableTablethis9Lraykernel/apps/readability/core/WholeProgramReadability;main([Ljava/lang/String;)V  run(Ljava/lang/String;)Vargs[Ljava/lang/String; java/io/File   raykernel/util/Timer start java "$#raykernel/io/FileFinder %&findAll2(Ljava/io/File;Ljava/lang/String;)Ljava/util/List; (*)6raykernel/apps/readability/detectors/FunctionExtractor +,getAllFunctions)(Ljava/util/Collection;I)Ljava/util/List;.4raykernel/apps/readability/core/ReadabilityEvaluator - 1Training 3 4lap 687java/util/List 9:iterator()Ljava/util/Iterator; <>=java/util/Iterator ?@next()Ljava/lang/Object;B(raykernel/apps/readability/code/Function -D EFgetReadability7(Lraykernel/apps/readability/code/TrainableCodeBlock;)DHjava/lang/StringBuilder AJ KL getClassName()Ljava/lang/String; NPOjava/lang/String QRvalueOf&(Ljava/lang/Object;)Ljava/lang/String; GU. GW XYappend-(Ljava/lang/String;)Ljava/lang/StringBuilder; A[ \L getMethodName^ : G` Xa(D)Ljava/lang/StringBuilder; Gc dLtoString fhgraykernel/io/Out ijprintln(Ljava/lang/Object;)V <l mnhasNext()Z 6p qrsize()It Average: v Evaluation ( Gx Xy(I)Ljava/lang/StringBuilder;{ methods) } ~printAllbenchLjava/lang/String;srcLjava/io/File; functionsLjava/util/List;re6Lraykernel/apps/readability/core/ReadabilityEvaluator;sumDf*Lraykernel/apps/readability/code/Function;readmeanLocalVariableTypeTable; SourceFileWholeProgramReadability.java!/*   5*2    ƻY*L+!''M-Y/N029,5:J;A:-C9GYIMSTVZV]V_bec9k,oo9GYsS_beGYuS,owzVb2| B  !&!)#@%H't){#,-/12 R !)@;H35 PK ;v:utt<raykernel/apps/readability/core/WholeProgramReadability.javapackage raykernel.apps.readability.core; import java.io.File; import java.util.List; import raykernel.apps.readability.code.Function; import raykernel.apps.readability.detectors.FunctionExtractor; import raykernel.io.FileFinder; import raykernel.util.Timer; public class WholeProgramReadability { public static void main(String[] args) { run(args[0]); } public static void run(String bench) { File src = new File(bench); Timer.start(); //step1 get all the methods List functions = FunctionExtractor.getAllFunctions(FileFinder.findAll(src, "java"), 9999); //step2 get readability ReadabilityEvaluator re = new ReadabilityEvaluator(); Timer.lap("Training"); double sum = 0; for (Function f : functions) { double read = re.getReadability(f); raykernel.io.Out.println(f.getClassName() + "." + f.getMethodName() + " : " + read); sum += read; } double mean = sum / (double) functions.size(); raykernel.io.Out.println("\nAverage: " + mean); Timer.lap("Evaluation (" + functions.size() + " methods)"); Timer.printAll(); } } PK w:4 7raykernel/apps/readability/core/TrainFromSnippets.class1#1raykernel/apps/readability/core/TrainFromSnippetsjava/lang/ObjectblocksLjava/util/List; Signature=Ljava/util/List;()VCode  java/util/LinkedList   LineNumberTableLocalVariableTablethis3Lraykernel/apps/readability/core/TrainFromSnippets;addBlock.(Lraykernel/apps/readability/code/CodeBlock;)V java/util/List add(Ljava/lang/Object;)Zb+Lraykernel/apps/readability/code/CodeBlock; SourceFileTrainFromSnippets.java!  B* *Y   D *+W     !"PK ;v: ;;6raykernel/apps/readability/core/TrainFromSnippets.javapackage raykernel.apps.readability.core; import java.util.LinkedList; import java.util.List; import raykernel.apps.readability.code.CodeBlock; public class TrainFromSnippets { List blocks = new LinkedList(); public void addBlock(CodeBlock b) { blocks.add(b); } } PK w:f  6raykernel/apps/readability/core/BasicReadability.class1}0raykernel/apps/readability/core/BasicReadabilityjava/lang/ObjectbrLjava/io/BufferedReader;()VCode java/io/BufferedReader java/io/InputStreamReader java/lang/System inLjava/io/InputStream;  (Ljava/io/InputStream;)V  (Ljava/io/Reader;)V  LineNumberTableLocalVariableTable  this2Lraykernel/apps/readability/core/BasicReadability; getNextBlock6()Lraykernel/apps/readability/code/TrainableCodeBlock;&(raykernel/apps/readability/code/Function % ) *+readLine()Ljava/lang/String;-break /10raykernel/config/Config 23get&(Ljava/lang/String;)Ljava/lang/String; 576java/lang/String 89equals(Ljava/lang/Object;)Z;(raykernel/apps/readability/code/CodeLine := >(Ljava/lang/String;)V %@ AB appendLine-(Lraykernel/apps/readability/code/CodeLine;)VDjava/lang/Exceptionf*Lraykernel/apps/readability/code/Function;nextLjava/lang/String;eLjava/lang/Exception;main([Ljava/lang/String;)VN4raykernel/apps/readability/core/ReadabilityEvaluator M Q #$ SUT2raykernel/apps/readability/code/TrainableCodeBlock VWisEmpty()Z MY Z[getReadability7(Lraykernel/apps/readability/code/TrainableCodeBlock;)D]java/lang/StringBuilder_ readability: \= \b cdappend(D)Ljava/lang/StringBuilder;f \h ci-(Ljava/lang/String;)Ljava/lang/StringBuilder; \k l+toString nporaykernel/io/Out qrprintln(Ljava/lang/Object;)Vargs[Ljava/lang/String;re6Lraykernel/apps/readability/core/ReadabilityEvaluator;block4Lraykernel/apps/readability/code/TrainableCodeBlock; readabilityD SourceFileBasicReadability.java! 9 Y Y    /*  !"#$ :%Y'K(LM%+!+,.4*:Y+<?*C& !&#)&58)*2EFGHGHIJ KL <MYOLPM,.,R$+,XJ\Y^`)aegjmб"/3 57; <81;?*<st4uv ,wx yz{|PK ;v:+J%$5raykernel/apps/readability/core/BasicReadability.javapackage raykernel.apps.readability.core; import java.io.BufferedReader; import java.io.InputStreamReader; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.Function; import raykernel.apps.readability.code.TrainableCodeBlock; public class BasicReadability { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //args: snippetDir scoreFile static TrainableCodeBlock getNextBlock() { Function f = new Function(); String next; while (true) { try { next = br.readLine(); } catch (Exception e) { break; } if (next == null || next.equals(raykernel.config.Config.get("break"))) { break; } f.appendLine(new CodeLine(next)); } return f; } public static void main(String[] args) { ReadabilityEvaluator re = new ReadabilityEvaluator(); while (true) { TrainableCodeBlock block = getNextBlock(); if (block == null || block.isEmpty()) { break; } else { double readability = re.getReadability(block); raykernel.io.Out.println("readability: " + readability + "\n"); } } } }PK :NL-aa:raykernel/apps/readability/core/ReadabilityEvaluator.class14raykernel/apps/readability/core/ReadabilityEvaluatorjava/lang/Object classifierLweka/classifiers/Classifier;cutoffFds$Lraykernel/ml/feature/DetectorSuite;evalLraykernel/ml/core/Evaluator;ssfd@Lraykernel/apps/readability/snippet/SnippetScoreFeatureDetector;()VCode   raykernel/config/Config getDefaultClassifier()Lweka/classifiers/Classifier;  ?   "!=raykernel/apps/readability/detectors/ReadabilityDetectorSuite #$getDefaultSuite&()Lraykernel/ml/feature/DetectorSuite; & (Software Readability Metric *,+raykernel/io/Out -.verbose(Ljava/lang/Object;)V0building model...2 java/io/File4 snippet_dir 6 78get&(Ljava/lang/String;)Ljava/lang/String; 1: ;(Ljava/lang/String;)V= score_file?>raykernel/apps/readability/snippet/SnippetScoreFeatureDetector >A B(Ljava/io/File;F)V D  F GH getSnippetsx(Ljava/io/File;Ljava/io/File;Lraykernel/ml/feature/FeatureDetector;Lraykernel/ml/feature/DetectorSuite;)Ljava/util/List; J KLtrain(Ljava/util/Collection;)VN done. LineNumberTableLocalVariableTablethis6Lraykernel/apps/readability/core/ReadabilityEvaluator;Ljava/io/File; scoreFilesnippetsLjava/util/List;LocalVariableTypeTable>Ljava/util/List;getReadability7(Lraykernel/apps/readability/code/TrainableCodeBlock;)D \^]"raykernel/ml/feature/DetectorSuite _`runAll#(Lraykernel/ml/feature/Trainable;)V b dferaykernel/ml/core/Evaluator g` runDetector di jk getScoreFor#(Lraykernel/ml/feature/Trainable;)Fblock4Lraykernel/apps/readability/code/TrainableCodeBlock; Signature(Ljava/io/File;Ljava/io/File;Lraykernel/ml/feature/FeatureDetector;Lraykernel/ml/feature/DetectorSuite;)Ljava/util/List; qsr0raykernel/apps/readability/snippet/SnippetLoader tu loadSnippets"(Ljava/io/File;)Ljava/util/Vector; wyxjava/util/List z{iterator()Ljava/util/Iterator; }~java/util/Iterator next()Ljava/lang/Object;*raykernel/apps/readability/snippet/Snippet f$raykernel/ml/feature/FeatureDetector } hasNext()Zscore_detector&Lraykernel/ml/feature/FeatureDetector;s,Lraykernel/apps/readability/snippet/Snippet;G(Ljava/util/Collection;)Vraykernel/ml/core/Trainer >  featureName()Ljava/lang/String; \  featureNames()[Ljava/lang/String; >(Ljava/util/Collection;Ljava/lang/String;[Ljava/lang/String;)V trainClassifier (Lweka/classifiers/Classifier;)V getTrainingSet()Lweka/core/Instances; d Z(Lweka/classifiers/Classifier;Lweka/core/Instances;Ljava/lang/String;[Ljava/lang/String;)VLjava/util/Collection;tLraykernel/ml/core/Trainer;DLjava/util/Collection; SourceFileReadabilityEvaluator.java! f****%')/)1Y359L1Y<59M*>Y,*@C*,+*C*%EN*-IM)O6   "$/%<'L)[+`-e.P*fQR/74S<*TS[ UVW [ UXYZV*%+[*a+c*a+hO234PQRlmGHno:,p:v:|:[-O9;=%>-;7APH:QR:TS:4S:: 4UVW 4UXKLnAY+*C*%M,**dY*,*C*%aOFIL@OP AQRAU*W AUPK :Xj9raykernel/apps/readability/core/ReadabilityEvaluator.javapackage raykernel.apps.readability.core; import java.io.File; import java.util.Collection; import java.util.List; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.apps.readability.detectors.ReadabilityDetectorSuite; import raykernel.apps.readability.snippet.Snippet; import raykernel.apps.readability.snippet.SnippetLoader; import raykernel.apps.readability.snippet.SnippetScoreFeatureDetector; import raykernel.ml.core.Evaluator; import raykernel.ml.core.Trainer; import raykernel.ml.feature.DetectorSuite; import raykernel.ml.feature.FeatureDetector; import weka.classifiers.Classifier; public class ReadabilityEvaluator { Classifier classifier = raykernel.config.Config.getDefaultClassifier(); float cutoff = (float) 0.5; DetectorSuite ds = ReadabilityDetectorSuite.getDefaultSuite(); Evaluator eval; SnippetScoreFeatureDetector ssfd; public ReadabilityEvaluator() { raykernel.io.Out.verbose("Software Readability Metric"); raykernel.io.Out.verbose("building model..."); File snippet_dir, scoreFile; snippet_dir = new File(raykernel.config.Config.get("snippet_dir")); scoreFile = new File(raykernel.config.Config.get("score_file")); ssfd = new SnippetScoreFeatureDetector(scoreFile, cutoff); List snippets = getSnippets(scoreFile, snippet_dir, ssfd, ds); train(snippets); raykernel.io.Out.verbose(" done.\n"); } public double getReadability(TrainableCodeBlock block) { ds.runAll(block); eval.runDetector(block); return eval.getScoreFor(block); } public List getSnippets(File scoreFile, File snippet_dir, FeatureDetector score_detector, DetectorSuite ds) { List snippets = SnippetLoader.loadSnippets(snippet_dir); for (Snippet s : snippets) { ds.runAll(s); score_detector.runDetector(s); } return snippets; } void train(Collection snippets) { Trainer t = new Trainer(snippets, ssfd.featureName(), ds.featureNames()); //train t.trainClassifier(classifier); //run evaluator eval = new Evaluator(classifier, t.getTrainingSet(), ssfd.featureName(), ds.featureNames()); //ObjectStore.put("readability_eval", eval); } } PK w:$1޶ 4raykernel/apps/readability/core/SnippetGenMain.class1.raykernel/apps/readability/core/SnippetGenMainjava/lang/ObjectdescLjava/lang/String;htmlZjsnipMAXFILESI num_snippets output_dir()VCodedefault          c:/snippetout  LineNumberTableLocalVariableTable % #this0Lraykernel/apps/readability/core/SnippetGenMain;checkDir"(Ljava/lang/String;)Ljava/io/File;+ java/io/File *- #.(Ljava/lang/String;)V *0 12exists()Z *4 52 isDirectory7java/lang/StringBuilder9Invalid directory: 6- 6< =>append-(Ljava/lang/String;)Ljava/lang/StringBuilder; 6@ ABtoString()Ljava/lang/String; DFEraykernel/io/Out GHprintln(Ljava/lang/Object;)V JLKjava/lang/System MNexit(I)VpathdirLjava/io/File;main([Ljava/lang/String;)VU Provide args! W () Y Z) tryCreateDir\java ^`_raykernel/io/FileFinder abfindAll2(Ljava/io/File;Ljava/lang/String;)Ljava/util/List; dfejava/util/List ghsize()I dj klsubList(II)Ljava/util/List;ncandidate files = 6p =q(I)Ljava/lang/StringBuilder;s7raykernel/apps/readability/snippet/MassSnippetGenerator ru #v%(Ljava/util/List;Ljava/lang/String;)V rx yNgenerateSnippets *{ |BgetAbsolutePath ~java/lang/String valueOf&(Ljava/lang/Object;)Ljava/lang/String; /meta.txt r outputMetaData(Ljava/io/File;)V r outputSnippets r outputSnippetsHTML(Ljava/io/File;I)Vargs[Ljava/lang/String; outputDir javaFilesLjava/util/List;gen9Lraykernel/apps/readability/snippet/MassSnippetGenerator;LocalVariableTypeTable Ljava/util/List; * 2mkdirCouldn't create directory:  SourceFileSnippetGenMain.java!    Uȳ!   "#/*$!" &' ()t0*Y*,L+/ +36Y8:*;?CI+! *."0O 'PQ RSX* TC*2VLXM+[]N-c-iN6Ym:-co?CrY-t:w*Y6Y,z}:;?,*Y,z,*Y,z,!F') * -.0 2,477O9\;d=?ADFI"4PQQ \X   Z)v.*Y*,L+W+/6Y:*;?CI+!M NPR(S,V".O %PQPK ;v:U/i3raykernel/apps/readability/core/SnippetGenMain.javapackage raykernel.apps.readability.core; import java.io.File; import java.util.List; import raykernel.apps.readability.snippet.MassSnippetGenerator; public class SnippetGenMain { private static String desc = "default"; private static boolean html = true; private static boolean jsnip = true; private static int MAXFILES = 200; private static int num_snippets = 5; private static String output_dir = "c:/snippetout"; private static File checkDir(String path) { File dir = new File(path); if (!dir.exists() || !dir.isDirectory()) { raykernel.io.Out.println("Invalid directory: " + path); System.exit(0); } return dir; } /** * @param args */ public static void main(String[] args) { if (args.length == 0) { raykernel.io.Out.println("Provide args!"); return; } File dir = checkDir(args[0]); File outputDir = tryCreateDir(output_dir); List javaFiles = raykernel.io.FileFinder.findAll(dir, "java"); if (javaFiles.size() > MAXFILES) { javaFiles = javaFiles.subList(0, MAXFILES); } raykernel.io.Out.println("candidate files = " + javaFiles.size()); MassSnippetGenerator gen = new MassSnippetGenerator(javaFiles, desc); gen.generateSnippets(num_snippets); gen.outputMetaData(new File(outputDir.getAbsolutePath() + "/meta.txt")); if (jsnip) { gen.outputSnippets(new File(outputDir.getAbsolutePath())); } if (html) { gen.outputSnippetsHTML(new File(outputDir.getAbsolutePath()), 0); } } private static File tryCreateDir(String path) { File dir = new File(path); dir.mkdir(); if (!dir.exists()) { raykernel.io.Out.println("Couldn't create directory: " + path); System.exit(0); } return dir; } } PK w:)  8raykernel/apps/readability/core/ReadComplexityCorr.class12raykernel/apps/readability/core/ReadComplexityCorrjava/lang/Object()VCode  LineNumberTableLocalVariableTablethis4Lraykernel/apps/readability/core/ReadComplexityCorr;main([Ljava/lang/String;)Vraykernel/experiment/Benchmark  (Ljava/lang/String;)V  run#(Lraykernel/experiment/Benchmark;)Vargs[Ljava/lang/String; raykernel/util/Timer start !"$raykernel/apps/complexity/Cyclomatic$ Complexity & 'lap )*1raykernel/apps/readability/core/MethodReadability, Readablity . /0 getSrcDir()Ljava/io/File; 243'raykernel/apps/docinf/data/JavaDocDBase 56 addSrcDir(Ljava/io/File;)V 28 9: getInstance+()Lraykernel/apps/docinf/data/JavaDocDBase; 2< => getMethods()Ljava/util/Collection; @BA)raykernel/apps/docinf/ast/UserDocInstance CDrecordUserDocs(Ljava/lang/Iterable;)VFjava/util/Vector E !< JLKjava/util/Collection MNiterator()Ljava/util/Iterator; PRQjava/util/Iterator STnext()Ljava/lang/Object;V"raykernel/apps/docinf/code/JMethod X YZisMember'(Lraykernel/apps/docinf/code/JMethod;)Z )\ ]^getReadability8(Lraykernel/apps/docinf/code/JMethod;)Ljava/lang/Double; !` ab getComplexity9(Lraykernel/apps/docinf/code/JMethod;)Ljava/lang/Integer; !d eb getLength Eg hiadd(Ljava/lang/Object;)Z kmljava/lang/Integer no doubleValue()D qsrjava/lang/Double tuvalueOf(D)Ljava/lang/Double;wjava/lang/StringBuilder v vz {|append-(Ljava/lang/Object;)Ljava/lang/StringBuilder;~ v {-(Ljava/lang/String;)Ljava/lang/StringBuilder; v toString()Ljava/lang/String; raykernel/io/Out println(Ljava/lang/Object;)V P hasNext()ZComputing correlation   printAllreadability/complexity corr: v raykernel/stats/Correlation getPearsonCorrelation'(Ljava/util/Vector;Ljava/util/Vector;)D v {(D)Ljava/lang/StringBuilder;readability/length corr: complexity/length corr: bench Lraykernel/experiment/Benchmark; readabilityLjava/util/Vector; complexity methlengthtotalIjm$Lraykernel/apps/docinf/code/JMethod;readLjava/lang/Double;compLjava/lang/Integer;lengthLocalVariableTypeTable&Ljava/util/Vector; SourceFileReadComplexityCorr.java!/*   <Y*2     I* #%*(+%*-17;?EYGLEYGMEYGN6HI:OU:*W[:_:c: lgb ]+fW,jpfW- jpfWvYxy}_y}cy}[y[%vY+,vY+-vY,- (  !%#-$5%='@)Y+b,e.h0o1v2}4678:;:)?ACEF GFH#I+H1J:KBJHM \ I-5= @ Yo|vu}n -5= PK ;v:Vbb7raykernel/apps/readability/core/ReadComplexityCorr.javapackage raykernel.apps.readability.core; import java.util.Vector; import raykernel.apps.complexity.Cyclomatic; import raykernel.apps.docinf.ast.UserDocInstance; import raykernel.apps.docinf.code.JMethod; import raykernel.apps.docinf.data.JavaDocDBase; import raykernel.experiment.Benchmark; import raykernel.util.Timer; public class ReadComplexityCorr { public static void main(String[] args) { run(new Benchmark(args[0])); } public static void run(Benchmark bench) { Timer.start(); Cyclomatic.run(bench); Timer.lap("Complexity"); MethodReadability.run(bench); Timer.lap("Readablity"); JavaDocDBase.addSrcDir(bench.getSrcDir()); UserDocInstance.recordUserDocs(JavaDocDBase.getInstance().getMethods()); Vector readability = new Vector(); Vector complexity = new Vector(); Vector methlength = new Vector(); int total = 0; for (JMethod jm : Cyclomatic.getMethods()) { if (!bench.isMember(jm)) continue; total++; Double read = MethodReadability.getReadability(jm); Integer comp = Cyclomatic.getComplexity(jm); Integer length = Cyclomatic.getLength(jm); if (total > 0 && read != null && comp != null && length != null) { readability.add(read); complexity.add(comp.doubleValue()); methlength.add(length.doubleValue()); raykernel.io.Out.println(jm + "\t" + Cyclomatic.getComplexity(jm) + "\t" + Cyclomatic.getLength(jm) + "\t" + MethodReadability.getReadability(jm)); } } Timer.lap("Computing correlation"); raykernel.io.Out.println(); Timer.printAll(); raykernel.io.Out.println(); raykernel.io.Out.println("readability/complexity corr: " + raykernel.stats.Correlation.getPearsonCorrelation(readability, complexity)); raykernel.io.Out.println("readability/length corr: " + raykernel.stats.Correlation.getPearsonCorrelation(readability, methlength)); raykernel.io.Out.println("complexity/length corr: " + raykernel.stats.Correlation.getPearsonCorrelation(complexity, methlength)); } } PK w:Ǭ= = 7raykernel/apps/readability/core/MethodReadability.class11raykernel/apps/readability/core/MethodReadabilityjava/lang/ObjectreadabilityMapLjava/util/Map; SignatureGLjava/util/Map;()VCode java/util/HashMap     LineNumberTableLocalVariableTable this3Lraykernel/apps/readability/core/MethodReadability;getReadability8(Lraykernel/apps/docinf/code/JMethod;)Ljava/lang/Double;  java/util/Map get&(Ljava/lang/Object;)Ljava/lang/Object;!java/lang/Doublejm$Lraykernel/apps/docinf/code/JMethod;main([Ljava/lang/String;)V'raykernel/experiment/Benchmark &) *(Ljava/lang/String;)V , -.run#(Lraykernel/experiment/Benchmark;)Vargs[Ljava/lang/String; &2 34 getSrcDir()Ljava/io/File;6java 8:9raykernel/io/FileFinder ;<findAll2(Ljava/io/File;Ljava/lang/String;)Ljava/util/List; >@?6raykernel/apps/readability/detectors/FunctionExtractor ABgetAllFunctions)(Ljava/util/Collection;I)Ljava/util/List;D4raykernel/apps/readability/core/ReadabilityEvaluator C GIHjava/util/List JKiterator()Ljava/util/Iterator; MONjava/util/Iterator PQnext()Ljava/lang/Object;S(raykernel/apps/readability/code/FunctionU"raykernel/apps/docinf/code/JMethod RW XY getClassName()Ljava/lang/String; R[ \Y getMethodName T^ _'(Ljava/lang/String;Ljava/lang/String;)V Ca b7(Lraykernel/apps/readability/code/TrainableCodeBlock;)D d efvalueOf(D)Ljava/lang/Double; h ijput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;ljava/lang/StringBuilder k ko pqappend-(Ljava/lang/Object;)Ljava/lang/StringBuilder;s ku pv-(Ljava/lang/String;)Ljava/lang/StringBuilder; kx py(D)Ljava/lang/StringBuilder; k{ |YtoString ~raykernel/io/Out println(Ljava/lang/Object;)V M hasNext()Zbench Lraykernel/experiment/Benchmark; functionsLjava/util/List;re6Lraykernel/apps/readability/core/ReadabilityEvaluator;f*Lraykernel/apps/readability/code/Function;LocalVariableTypeTable; SourceFileMethodReadability.java!  / Y    /*   7 *   "# $% <&Y*2(+   /0 -. |*157'=LCYEM+F:QLRNTY-V-Z]:,-`cgWkYmnrt,-`wz}* $ % $(*.,?.R0q*{24|ld.C?2"# lPK ;v:A6raykernel/apps/readability/core/MethodReadability.javapackage raykernel.apps.readability.core; import java.util.HashMap; import java.util.List; import java.util.Map; import raykernel.apps.docinf.code.JMethod; import raykernel.apps.readability.code.Function; import raykernel.apps.readability.detectors.FunctionExtractor; import raykernel.experiment.Benchmark; import raykernel.io.FileFinder; /** * Goal here is to print out method names and readability values * * @author buse * */ public class MethodReadability { static Map readabilityMap = new HashMap(); public static Double getReadability(JMethod jm) { return readabilityMap.get(jm); } public static void main(String[] args) { run(new Benchmark(args[0])); } public static void run(Benchmark bench) { //step1 get all the methods\ List functions = FunctionExtractor.getAllFunctions(FileFinder.findAll(bench.getSrcDir(), "java"), 9999); //step2 get readability ReadabilityEvaluator re = new ReadabilityEvaluator(); for (Function f : functions) { JMethod jm = new JMethod(f.getClassName(), f.getMethodName()); readabilityMap.put(jm, re.getReadability(f)); raykernel.io.Out.println(jm + " " + re.getReadability(f)); } } } PK L:J<@@2raykernel/apps/readability/core/Experimenter.class1,,raykernel/apps/readability/core/Experimenterjava/lang/ObjectcutoffFds$Lraykernel/ml/feature/DetectorSuite;score_detector&Lraykernel/ml/feature/FeatureDetector;()VCode?   =raykernel/apps/readability/detectors/ReadabilityDetectorSuite getDefaultSuite&()Lraykernel/ml/feature/DetectorSuite;  LineNumberTableLocalVariableTable   this.Lraykernel/apps/readability/core/Experimenter;avgCrossFmeasue$(Lraykernel/ml/validate/CrossVal;I)F#raykernel/ml/validate/Analyzer " &('raykernel/ml/validate/CrossVal ) run &+ ,-getOrderedResults()Ljava/util/Vector; "/ 01getAvgBestFmeasure(Ljava/util/Vector;)Fcval Lraykernel/ml/validate/CrossVal; iterationsIana Lraykernel/ml/validate/Analyzer;totalithisrunavgWekaFmeasue#(Lraykernel/ml/validate/WekaVal;I)F >@?raykernel/ml/validate/WekaVal AB runCrossVal()FwvalLraykernel/ml/validate/WekaVal;compareAvgValues,(Ljava/util/Collection;[Ljava/lang/String;)V SignatureZ(Ljava/util/Collection;[Ljava/lang/String;)VJraykernel/util/FilterL*raykernel/util/FeatureGreaterThanPredicate N PRQ$raykernel/ml/feature/FeatureDetector ST featureNames()[Ljava/lang/String; KW X(Ljava/lang/String;F)V IZ [(Lraykernel/util/Predicate;)V]"raykernel/util/HasFeaturePredicate \_ `(Ljava/lang/String;)Vbraykernel/util/PredicateNOT aZ Ie fgfilter.(Ljava/util/Collection;)Ljava/util/Collection;ijava/lang/StringBuilder kmljava/util/Collection nosize()I qsrjava/lang/String tuvalueOf(I)Ljava/lang/String; h_x lessReadableSnippets hz {|append-(Ljava/lang/String;)Ljava/lang/StringBuilder; h~ toString()Ljava/lang/String; raykernel/io/Out println(Ljava/lang/Object;)V moreReadableSnippetsfeature less more q t&(Ljava/lang/Object;)Ljava/lang/String;  getAvgFeatureValue+(Ljava/util/Collection;Ljava/lang/String;)F h {(F)Ljava/lang/StringBuilder;snippetsLjava/util/Collection;features[Ljava/lang/String; scoredFilterLraykernel/util/Filter;lessReadableFiltermoreReadableFilterscoredSnippetslessReadableSnippetsmoreReadableSnippetsfLjava/lang/String;LocalVariableTypeTableDLjava/util/Collection;ELraykernel/util/Filter;compareClassifiersJ(Ljava/util/List;[Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/String;)Vx(Ljava/util/List;[Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/String;)Vclassifier name weka standard & J(Ljava/util/List;ILjava/lang/Class;Ljava/lang/String;[Ljava/lang/String;)V  ! java/lang/Class  getSimpleNameA Ljava/util/List; classifiers[Ljava/lang/Class; classFeature otherFeatures classifierLjava/lang/Class;j cv_others>Ljava/util/List;compareFeaturesI(Ljava/util/List;Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/String;)Vw(Ljava/util/List;Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/String;)V classifier = all features = feature name only leftout q equals(Ljava/lang/Object;)Z  targetFeature thisFeature leaveOneOutfeatrunstotal_ototal_tcv_this experimentA(Ljava/util/List;)VA(Ljava/util/List;)V!weka/classifiers/bayes/NaiveBayes%weka/classifiers/functions/RBFNetwork weka/classifiers/misc/HyperPipes)weka/classifiers/functions/SimpleLogistic#weka/classifiers/functions/Logisticweka/classifiers/trees/J48 R"raykernel/ml/feature/DetectorSuite   experimentBp(Ljava/util/Collection;Ljava/lang/Class;Lraykernel/ml/feature/FeatureDetector;Lraykernel/experiment/Benchmark;)V(Ljava/util/Collection;Ljava/lang/Class;Lraykernel/ml/feature/FeatureDetector;Lraykernel/experiment/Benchmark;)V6 -- Experiment B : Correlate with external measures --  getClass()Ljava/lang/Class; 8raykernel/apps/readability/bugdetectors/FindBugsDetector raykernel/experiment/Benchmark  getSrcDir()Ljava/io/File; .raykernel/apps/readability/misc/CodeFileLoader  getCodeFiles'(Ljava/io/File;I)Ljava/util/Collection;   getBinDir class    attachAuxVersions9(Ljava/util/Collection;Ljava/io/File;Ljava/lang/String;)V   getOldDirjava Code Files loaded. k iterator()Ljava/util/Iterator; java/util/Iterator next()Ljava/lang/Object; (raykernel/apps/readability/code/CodeFile P" #$ runDetector#(Lraykernel/ml/feature/Trainable;)V & '(hasNext()Z I* f+/(Ljava/util/Collection;I)Ljava/util/Collection;-+finished running bug detector. Identified /10raykernel/config/GlobalStats 25bugCount h4 {5(I)Ljava/lang/StringBuilder;7 bugs.9in ; files.=java/util/LinkedList < <@ ABaddAll(Ljava/util/Collection;)Z DFE6raykernel/apps/readability/detectors/FunctionExtractor G+getAllFunctionsI extracted K functionsM*raykernel/util/HasLineWithFeaturePredicate L_P(raykernel/apps/readability/code/Function RTSraykernel/util/Predicate U getBooleanW)raykernel/ml/feature/StandardValueFeature VY Z(Ljava/lang/String;Z)V O\ ]^ setFeature!(Lraykernel/ml/feature/Feature;)V`functions labeled b@cjava/util/Liste --- Working Set ---gfunctions (bugs>0): ifunctions (bugs=0): b l m$runAllo --- Evaluation Results ---q!raykernel/ml/validate/StraightVal ps t7(Ljava/util/List;Ljava/lang/String;Ljava/lang/String;)V p( pw x- getResults "z {|getBestFmeasure(Ljava/util/Collection;)F~ std fmeasure = " printScoreRatio(Ljava/util/Collection;)V classiferType bug_detectorbench Lraykernel/experiment/Benchmark; max_files max_functions code_filescf*Lraykernel/apps/readability/code/CodeFile; bugfilefilterreversefilefilter files_with_fbfiles_without_fbfileSetLjava/util/LinkedList;target_functions funHasBugLraykernel/util/Predicate;*Lraykernel/apps/readability/code/Function;hasBugZ bugfunfilterreversefunfilterfunctions_with_fbfunctions_without_fb all_functionssv_funs#Lraykernel/ml/validate/StraightVal;sBLjava/util/Collection;CLraykernel/util/Filter;BLjava/util/LinkedList;BLjava/util/Collection;FLraykernel/util/Predicate;CLraykernel/util/Filter;; experimentCJ(Ljava/util/Collection;Ljava/lang/Class;Lraykernel/experiment/Benchmark;)Vx(Ljava/util/Collection;Ljava/lang/Class;Lraykernel/experiment/Benchmark;)Vreadability =  getReadabilityJ(Ljava/util/Collection;Ljava/lang/Class;Lraykernel/experiment/Benchmark;)D h {(D)Ljava/lang/StringBuilder; experimentD*(Ljava/util/Collection;Ljava/lang/Class;)VX(Ljava/util/Collection;Ljava/lang/Class;)V raykernel/ml/validate/SnippetVal   (    printResultsval"Lraykernel/ml/validate/SnippetVal; experimentF  java/lang/System outLjava/io/PrintStream; java/io/PrintStream `print*raykernel/apps/readability/snippet/Snippet   getFeature2(Ljava/lang/String;)Lraykernel/ml/feature/Feature; raykernel/ml/feature/Feature Bvalue q t(F)Ljava/lang/String;  fd,Lraykernel/apps/readability/snippet/Snippet; experimentGJ(Lraykernel/ml/feature/FeatureDetector;Lraykernel/experiment/Benchmark;I)V$ -- Experiment G : How many bugs? --Y(Ljava/util/Collection;Ljava/lang/String;)Fraykernel/ml/feature/Trainable  featureNamet Lraykernel/ml/feature/Trainable;x(Ljava/util/Collection;Ljava/lang/Class;Lraykernel/experiment/Benchmark;)D /   startTimer raykernel/ml/validate/Stats |getAverageScore functions getSnippetsx(Ljava/io/File;Ljava/io/File;Lraykernel/ml/feature/FeatureDetector;Lraykernel/ml/feature/DetectorSuite;)Ljava/util/List;(Ljava/io/File;Ljava/io/File;Lraykernel/ml/feature/FeatureDetector;Lraykernel/ml/feature/DetectorSuite;)Ljava/util/List; 0raykernel/apps/readability/snippet/SnippetLoader  loadSnippets"(Ljava/io/File;)Ljava/util/Vector; # Snippets: bm # class 0:  # class 1:  # no class:  scoreFileLjava/io/File; snippet_dir zero_class one_classno_classlogBugExperiment -- Log Bug Experiment --/raykernel/versioncontrol/logbugs/LogBugDetector  java/io/File   getMainClass _   loadFunctions (Ljava/io/File;)Ljava/util/List; " R1Lraykernel/versioncontrol/logbugs/LogBugDetector;main([Ljava/lang/String;)V"# --- FeatureBased Bug Detection --- $ %(Ljava/io/File;)V  ( args SourceFileExperimenter.java!   4 -/ *  /**  ! 1"Y$M F6*%,**.8%bF%n"46 8:;A#8,D>123145)67 '8 95: ;<  E>*=8$bE$nIKM NKQ4CD45895 :EFGH  IYKYMO2UVYMIY\YMO2^YNIYaY\YMO2^cY:,*d:-d:d:hYjpvwy}hYjpvy}+Y: 6 6 =  2:hYvyy}   ±VWXWY#Z,Y4[<\P[U^\_d`mcdfhjkjhm\ 4U\dm0H4U\dm G  u+Y:66^2: 86 "&Y* ,-:   b8   ݻhYvyn}* rt|}"2>}HjttRuuuuQN8)5 2 3 u G KhYķv+y} 86!&Y* +,-: b8 ޻hYƷvn}ȸ-Y:662:qYS: -dq: 6 -Y:66 $ 2:  ʙ    S   6 8 86>&Y* +, :&Y* +, : b8  b8  hYvζy  ny n}&v.:D[`t@JKKKK28(5. 3t 95  |5 y vE5(33 K G ;YSYSYSYSYSYSL*۲MO2"  #$:;$ ; G  -,hY+vy}6'6,-:- -:- hYjpvy}::,!%IY\Y,O2^Y:IYaY\Y,O2^cY:d:  jh): hY,v.36y}hY8v j3:y}:   ?W  ?W C: hYHv j3Jy}LY,O2N:  :0O: Q6VY,O2X[%_IY\Y,O2^Y:IYaY\Y,O2^cY: d: j)::aWaWdhYfvj3}hYhvj3}j:O:k%npYMO2,O2r:u"Y$:vy8hY}v}v? ,16=HWbn#CLT\e  /!8"B#L%R&l')+)0898;=?BD F     1565Hb@!  L e w !/8:,67  Hb@!  L e w /8 G nhYv*+,} JK   G &Y*b+MO2M,,O POR!T%U &&  & G Mw,PL»hY+O2vy}*j:5N»hY-+O2϶Ӹطvy}%Ǹ,%"bd4eJgqe{i~bk j J'   T+**+N-+ +N-+ hY-jpvy}-::*!%hY,v.36y}:op quw$x2};~Fby> 5$;my$;m G 9 E*:N$-+bE%$*jn%/*9978  9G I y>'6,:C::O:k%pY*bMO22r:uvg6   7?I[chm\ yyyu5 p5cZ7h ycZ G  +:666j: f :-k,!,O2 6,O2϶ ,O2϶  %hYv3}hYv3}hYv3}hYv3}J'-5EHK`f{~\    5  5 5'W   G F  ,hY+vy}YN-Y,:hYHvj3Jy}:O:-%_IY\Y-2^Y:IYaY\Y-2^cY:d:j)::  aW aWdhYfvj3}hYhvj3} j:  O:  k %npY MO2-2r:  u"Y$:   vy8 hY}v }  v% #+< \ t z !"#-%E'M%W,]4m5r4x7}9;>@B+<vt E x: ,67   H<v   g'!YY*2#LY&+'FLm&q')*+PK L:QKKSKS1raykernel/apps/readability/core/Experimenter.javapackage raykernel.apps.readability.core; import java.io.File; import java.util.Collection; import java.util.LinkedList; import java.util.List; import raykernel.apps.readability.bugdetectors.FindBugsDetector; import raykernel.apps.readability.code.CodeFile; import raykernel.apps.readability.code.Function; import raykernel.apps.readability.detectors.FunctionExtractor; import raykernel.apps.readability.detectors.ReadabilityDetectorSuite; import raykernel.apps.readability.misc.CodeFileLoader; import raykernel.apps.readability.snippet.Snippet; import raykernel.apps.readability.snippet.SnippetLoader; import raykernel.config.GlobalStats; import raykernel.experiment.Benchmark; import raykernel.ml.feature.DetectorSuite; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.ml.validate.Analyzer; import raykernel.ml.validate.CrossVal; import raykernel.ml.validate.SnippetVal; import raykernel.ml.validate.Stats; import raykernel.ml.validate.StraightVal; import raykernel.ml.validate.WekaVal; import raykernel.util.FeatureGreaterThanPredicate; import raykernel.util.Filter; import raykernel.util.HasFeaturePredicate; import raykernel.util.HasLineWithFeaturePredicate; import raykernel.util.Predicate; import raykernel.util.PredicateNOT; import raykernel.versioncontrol.logbugs.LogBugDetector; import weka.classifiers.bayes.NaiveBayes; import weka.classifiers.functions.Logistic; import weka.classifiers.functions.RBFNetwork; import weka.classifiers.functions.SimpleLogistic; import weka.classifiers.misc.HyperPipes; import weka.classifiers.trees.J48; public class Experimenter { static float cutoff = (float) 0.5; static DetectorSuite ds = ReadabilityDetectorSuite.getDefaultSuite(); static FeatureDetector score_detector; private static float avgCrossFmeasue(CrossVal cval, int iterations) { Analyzer ana = new Analyzer(); float total = 0; for (int i = 0; i < iterations; i++) { cval.run(); float thisrun = ana.getAvgBestFmeasure(cval.getOrderedResults()); //io.Out.println("-----"); //ana.printScores( cval.getResults() ); total += thisrun; } return total / iterations; } private static float avgWekaFmeasue(WekaVal wval, int iterations) { float total = 0; for (int i = 0; i < iterations; i++) { float thisrun = wval.runCrossVal(); total += thisrun; } return total / iterations; } public static void compareAvgValues(Collection snippets, String... features) { //filer raykernel.util.Filter scoredFilter = new Filter(new FeatureGreaterThanPredicate( score_detector.featureNames()[0], -1)); Filter lessReadableFilter = new Filter(new HasFeaturePredicate(score_detector .featureNames()[0])); Filter moreReadableFilter = new Filter(new PredicateNOT( new HasFeaturePredicate(score_detector.featureNames()[0]))); Collection scoredSnippets = scoredFilter.filter(snippets); Collection lessReadableSnippets = lessReadableFilter.filter(scoredSnippets); Collection moreReadableSnippets = moreReadableFilter.filter(scoredSnippets); //print raykernel.io.Out.println(lessReadableSnippets.size() + " lessReadableSnippets"); raykernel.io.Out.println(moreReadableSnippets.size() + " moreReadableSnippets"); raykernel.io.Out.println("feature\t\tless\tmore"); for (String f : features) { raykernel.io.Out.println(f + "\t" + getAvgFeatureValue(lessReadableSnippets, f) + "\t" + getAvgFeatureValue(moreReadableSnippets, f)); } } public static void compareClassifiers(List snippets, Class[] classifiers, String classFeature, String[] otherFeatures) { raykernel.io.Out.println("classifier name\tweka\tstandard"); for (Class classifier : classifiers) { //WekaVal wval = new WekaVal( snippets, classifier, classFeature, otherFeatures); //CrossVal cval = new CrossVal(snippets, 10, classifier, classFeature, otherFeatures); //float weka = avgWekaFmeasue(wval, 10); //float std = avgCrossFmeasue(cval, 10); float total = 0; for (int j = 0; j < 10; j++) { CrossVal cv_others = new CrossVal(snippets, 10, classifier, classFeature, otherFeatures); total += avgCrossFmeasue(cv_others, 10); } raykernel.io.Out.println(classifier.getSimpleName() + "\t" + (total / 10)); } } public static void compareFeatures(List snippets, Class classifier, String classFeature, String[] otherFeatures) { raykernel.io.Out.println("classifier = " + classifier.getSimpleName()); float total = 0; for (int j = 0; j < 10; j++) { CrossVal cv_others = new CrossVal(snippets, 10, classifier, classFeature, otherFeatures); total += avgCrossFmeasue(cv_others, 10); } raykernel.io.Out.println("all features = " + (total / 10)); raykernel.io.Out.println("feature name\t\tonly\tleftout"); //leave others out for (String targetFeature : otherFeatures) { String[] thisFeature = {targetFeature}; String[] leaveOneOut = new String[otherFeatures.length - 1]; int i = 0; for (String feat : otherFeatures) { if (feat.equals(targetFeature)) { continue; } leaveOneOut[i] = feat; i++; } //WekaVal wval_this = new WekaVal( snippets, classifier, classFeature, thisFeature); //WekaVal wval_others = new WekaVal( snippets, classifier, classFeature, leaveOneOut); //CrossVal cv_this = new CrossVal( snippets, 10, classifier, classFeature, thisFeature); int runs = 30; float total_o = 0, total_t = 0; for (int j = 0; j < runs; j++) { CrossVal cv_others = new CrossVal(snippets, 10, classifier, classFeature, leaveOneOut); CrossVal cv_this = new CrossVal(snippets, 10, classifier, classFeature, thisFeature); total_t += avgCrossFmeasue(cv_others, 10); total_o += avgCrossFmeasue(cv_this, 10); } raykernel.io.Out.println(targetFeature + "\t\t" + (total_o / runs) + "\t" + (total_t / runs)); } } public static void experimentA(List snippets) { //try some classifiers Class[] classifiers = {NaiveBayes.class, //LMT.class, RBFNetwork.class, HyperPipes.class, //MultilayerPerceptron.class, //SMO.class, //VFI.class, SimpleLogistic.class, //KStar.class, //ADTree.class, Logistic.class, //IB1.class, J48.class, //JRip.class, //NBTree.class }; //compareClassifiers( snippets, classifiers, score_detector.featureNames()[0], ds.featureNames() ); compareFeatures(snippets, NaiveBayes.class, score_detector.featureNames()[0], ds.featureNames()); } public static void experimentB(Collection snippets, Class classiferType, FeatureDetector bug_detector, Benchmark bench) { raykernel.io.Out.println("\n-- Experiment B : Correlate with external measures --"); raykernel.io.Out.println(bench); raykernel.io.Out.println(bug_detector.getClass().getSimpleName()); raykernel.io.Out.println(classiferType.getSimpleName() + "\n"); int max_files = 1000; int max_functions = 10000; //*** run detectors Collection code_files; if (bug_detector instanceof FindBugsDetector) { code_files = CodeFileLoader.getCodeFiles(bench.getSrcDir(), max_files); CodeFileLoader.attachAuxVersions(code_files, bench.getBinDir(), "class"); } else //new version detector { code_files = CodeFileLoader.getCodeFiles(bench.getOldDir(), max_files); CodeFileLoader.attachAuxVersions(code_files, bench.getSrcDir(), "java"); } raykernel.io.Out.println(code_files.size() + " Code Files loaded."); for (CodeFile cf : code_files) { bug_detector.runDetector(cf); } //select set of functions with at least 1 fb Filter bugfilefilter = new Filter(new HasFeaturePredicate(bug_detector .featureNames()[0])); Filter reversefilefilter = new Filter(new PredicateNOT( new HasFeaturePredicate(bug_detector.featureNames()[0]))); Collection files_with_fb = bugfilefilter.filter(code_files); Collection files_without_fb = reversefilefilter.filter(code_files, files_with_fb.size() * 2); raykernel.io.Out.println("finished running bug detector. Identified " + GlobalStats.bugCount + " bugs."); raykernel.io.Out.println("in " + files_with_fb.size() + " files."); //combine LinkedList fileSet = new LinkedList(); fileSet.addAll(files_with_fb); fileSet.addAll(files_without_fb); Collection target_functions = FunctionExtractor.getAllFunctions(fileSet, max_functions); raykernel.io.Out.println("extracted " + target_functions.size() + " functions"); //label functions Predicate funHasBug = new HasLineWithFeaturePredicate(bug_detector.featureNames()[0]); for (Function f : target_functions) { boolean hasBug = funHasBug.getBoolean(f); f.setFeature(new StandardValueFeature(bug_detector.featureNames()[0], hasBug)); } raykernel.io.Out.println("functions labeled"); //*** Partition data //select set of functions with at least 1 fb Filter bugfunfilter = new Filter(new HasFeaturePredicate(bug_detector .featureNames()[0])); Filter reversefunfilter = new Filter(new PredicateNOT( new HasFeaturePredicate(bug_detector.featureNames()[0]))); Collection functions_with_fb = bugfunfilter.filter(target_functions); Collection functions_without_fb = reversefunfilter.filter(target_functions, functions_with_fb.size()); List all_functions = new LinkedList(); all_functions.addAll(functions_with_fb); all_functions.addAll(functions_without_fb); raykernel.io.Out.println("\n--- Working Set ---"); raykernel.io.Out.println("functions (bugs>0): " + functions_with_fb.size()); raykernel.io.Out.println("functions (bugs=0): " + functions_without_fb.size()); for (Function f : all_functions) { ds.runAll(f); } //*** Run Analysis raykernel.io.Out.println("\n--- Evaluation Results ---"); //WekaVal wval = new WekaVal( snippets, classiferType, score_detector.featureNames()[0], ds.featureNames()); //double w = wval.runStraightVal(all_functions, bug_detector.featureNames()[0]); //StraightVal sv_funs = new StraightVal(snippets, all_functions, classiferType, score_detector.featureNames()[0], //bug_detector.featureNames()[0], ds.featureNames()); StraightVal sv_funs = new StraightVal(all_functions, score_detector.featureNames()[0], bug_detector .featureNames()[0]); sv_funs.run(); Analyzer ana = new Analyzer(); float s = ana.getBestFmeasure(sv_funs.getResults()); //io.Out.println( "weka fmeasure = " + w ); raykernel.io.Out.println(" std fmeasure = " + s); ana.printScoreRatio(sv_funs.getResults()); } public static void experimentC(Collection snippets, Class classiferType, Benchmark bench) { raykernel.io.Out.println("readability = " + getReadability(snippets, classiferType, bench)); } public static void experimentD(Collection snippets, Class classifier) { SnippetVal val = new SnippetVal((List) snippets, classifier, score_detector.featureNames()[0], ds.featureNames()); val.run(); val.printResults(); } /* public static void experimentE(Collection snippets, Class classiferType, File benchDir) { for (Benchmark2 b : getBenchmarks(benchDir)) { io.Out.println(b.getName() + "\t" + getReadability(snippets, classiferType, b)); } }*/ private static void experimentF(List snippets) { for (FeatureDetector fd : ReadabilityDetectorSuite.getDefaultSuite()) { System.out.print(fd.featureNames()[0] + "\t"); for (Snippet s : snippets) { System.out.print(s.getFeature(fd.featureNames()[0]).value() + "\t"); } raykernel.io.Out.println(); } } public static void experimentG(FeatureDetector bug_detector, Benchmark bench, int max_files) { raykernel.io.Out.println("\n-- Experiment G : How many bugs? --"); raykernel.io.Out.println(bench); raykernel.io.Out.println(bug_detector.getClass().getSimpleName()); Collection code_files; if (bug_detector instanceof FindBugsDetector) { code_files = CodeFileLoader.getCodeFiles(bench.getSrcDir(), max_files); CodeFileLoader.attachAuxVersions(code_files, bench.getBinDir(), "class"); } else //new version detector { code_files = CodeFileLoader.getCodeFiles(bench.getOldDir(), max_files); CodeFileLoader.attachAuxVersions(code_files, bench.getSrcDir(), "java"); } raykernel.io.Out.println(code_files.size() + " Code Files loaded."); for (CodeFile cf : code_files) { bug_detector.runDetector(cf); } raykernel.io.Out.println("finished running bug detector. Identified " + GlobalStats.bugCount + " bugs."); } public static float getAvgFeatureValue(Collection moreReadableSnippets, String featureName) { float total = 0; for (Trainable t : moreReadableSnippets) { total += t.getFeature(featureName).value(); } return total / moreReadableSnippets.size(); } /* public static List getBenchmarks(File directory) { LinkedList marks = new LinkedList(); for (File f : directory.listFiles()) { if (f.isDirectory()) { if (f.getName().equals("bin") || f.getName().equals("lib")) { continue; } Benchmark2 b = new Benchmark2(f, f.getName()); marks.add(b); } } return marks; }*/ static double getReadability(Collection snippets, Class classiferType, Benchmark bench) { int max_files = 1000; int max_functions = 10000; //*** run detectors GlobalStats.startTimer(); Collection code_files = CodeFileLoader.getCodeFiles(bench.getSrcDir(), max_files); //io.Out.println(code_files.size() + " Code Files loaded."); Collection functions = FunctionExtractor.getAllFunctions(code_files, max_functions); //io.Out.println(functions.size() + " Functions Extracted."); for (Function f : functions) { ds.runAll(f); } //StraightVal sv_funs = new StraightVal(snippets, functions, classiferType, score_detector.featureNames()[0], // score_detector.featureNames()[0], ds.featureNames()); //StraightVal sv_funs = new StraightVal(snippets, functions, classiferType, score_detector.featureNames()[0], // score_detector.featureNames()[0], ds.featureNames()); StraightVal sv_funs = new StraightVal((List) snippets, score_detector.featureNames()[0], ds.featureNames()[0]); sv_funs.run(); //io.Out.println( "time = " + GlobalStats.endTimer() ); return 1.0 - Stats.getAverageScore(sv_funs.getResults()); } public static List getSnippets(File scoreFile, File snippet_dir, FeatureDetector score_detector, DetectorSuite ds) { List snippets = SnippetLoader.loadSnippets(snippet_dir); //List classified = new LinkedList(); int zero_class = 0, one_class = 0, no_class = 0; for (Snippet s : snippets) { ds.runAll(s); score_detector.runDetector(s); if (s.getFeature(score_detector.featureNames()[0]) == null) { no_class++; continue; } if (s.getFeature(score_detector.featureNames()[0]).value() == 0) { zero_class++; } else if (s.getFeature(score_detector.featureNames()[0]).value() == 1) { one_class++; } //classified.add(s); } raykernel.io.Out.println("# Snippets:\t" + snippets.size()); raykernel.io.Out.println("# class 0:\t" + zero_class); raykernel.io.Out.println("# class 1:\t" + one_class); raykernel.io.Out.println("# no class:\t" + no_class); //return classified; return snippets; } public static void logBugExperiment(Collection snippets, Class classiferType, Benchmark bench) { raykernel.io.Out.println("\n-- Log Bug Experiment --"); raykernel.io.Out.println(bench); raykernel.io.Out.println(classiferType.getSimpleName() + "\n"); //int max_files = 1000; //int max_functions = 10000; //*** run detectors LogBugDetector bug_detector = new LogBugDetector(); Collection target_functions = bug_detector.loadFunctions(new File(bench.getMainClass())); raykernel.io.Out.println("extracted " + target_functions.size() + " functions"); for (Function f : target_functions) { bug_detector.runDetector(f); } raykernel.io.Out.println("functions labeled"); //*** Partition data //select set of functions with at least 1 fb Filter bugfunfilter = new Filter(new HasFeaturePredicate(bug_detector .featureNames()[0])); Filter reversefunfilter = new Filter(new PredicateNOT( new HasFeaturePredicate(bug_detector.featureNames()[0]))); Collection functions_with_fb = bugfunfilter.filter(target_functions); Collection functions_without_fb = reversefunfilter.filter(target_functions, functions_with_fb.size()); List all_functions = new LinkedList(); all_functions.addAll(functions_with_fb); all_functions.addAll(functions_without_fb); raykernel.io.Out.println("\n--- Working Set ---"); raykernel.io.Out.println("functions (bugs>0): " + functions_with_fb.size()); raykernel.io.Out.println("functions (bugs=0): " + functions_without_fb.size()); for (Function f : all_functions) { ds.runAll(f); } //*** Run Analysis raykernel.io.Out.println("\n--- Evaluation Results ---"); //WekaVal wval = new WekaVal( snippets, classiferType, score_detector.featureNames()[0], ds.featureNames()); //double w = wval.runStraightVal(all_functions, bug_detector.featureNames()[0]); //StraightVal sv_funs = new StraightVal(snippets, all_functions, classiferType, score_detector.featureNames()[0], // bug_detector.featureNames()[0], ds.featureNames()); StraightVal sv_funs = new StraightVal(all_functions, score_detector.featureNames()[0], bug_detector .featureNames()[0]); sv_funs.run(); Analyzer ana = new Analyzer(); float s = ana.getBestFmeasure(sv_funs.getResults()); //io.Out.println( "weka fmeasure = " + w ); raykernel.io.Out.println(" std fmeasure = " + s); ana.printScoreRatio(sv_funs.getResults()); } public static void main(String[] args) { raykernel.io.Out.println("\n--- FeatureBased Bug Detection ---"); //get files //File snippet_dir = new File("C:/snip"); //File snippet_dir = new File("data/snippets"); Benchmark bench = new Benchmark(new File(args[0])); //File scoreFile = new File("C:/Users/buse/Desktop/research/svn/readability/data/scorefiles/final.txt"); //File scoreFile = new File("data/scorefiles/final.txt"); //*** load and train //score_detector = new RandomScoreDetector( 12 ); //score_detector = new SnippetScoreFeatureDetector(scoreFile, cutoff); //List snippets = getSnippets(scoreFile, snippet_dir, score_detector, ds); //io.Out.println("\n--- Run ---"); //calcSnippetable( data_dir ); //compareAvgValues( snippets, DetectorSuite.getDefaultSuite().featureNames() ); //experimentA( snippets ); //experimentB(snippets, NaiveBayes.class, new FindBugsDetector(), bench); //experimentB(snippets, NaiveBayes.class, new VersionBugDetector(), bench); // //experimentC(snippets, NaiveBayes.class, bench); //experimentE( snippets, NaiveBayes.class, new File( args[0] ) ); //one snippet at a time //experimentD( snippets, NaiveBayes.class ); //experimentF(snippets); experimentG(new FindBugsDetector(), bench, 1000); //logBugExperiment(snippets, NaiveBayes.class, bench); } /* private static void calcSnippetable(File data_dir) { int max_files = 200; int max_functions = 1200; Vector code_files = CodeFileLoader.getFilesFromDir( data_dir, max_files ); SnippetGenerator sg = new SnippetGenerator(); FeatureDetector avgSnippetable = new AvgLineValueDetector( sg.featureNames()[0] ); for( CodeFile f : code_files ) { sg.runDetector(f); } List functions = FunctionExtractor.getAllFunctions(code_files, max_functions); float total = 0; float count = 0; for( Function f : functions ) { avgSnippetable.runDetector(f); float coverage = f.getFeature(avgSnippetable.featureNames()[0]).value(); total += coverage; //if( coverage > 0 ) count++; io.Out.println("coverage = " + coverage); } io.Out.println("averageSnippetable = " + total/count); } */ } PK w:z\raykernel/util/MathBox.class1raykernel/util/MathBoxjava/lang/Object()VCode  LineNumberTableLocalVariableTablethisLraykernel/util/MathBox;max(FF)FfirstFsecondmin SourceFile MathBox.java!/*   F "#"#     F "#"#    PK Tv:ۣ))raykernel/util/MathBox.javapackage raykernel.util; public class MathBox { public static float max(float first, float second) { if (first > second) return first; return second; } public static float min(float first, float second) { if (first < second) return first; return second; } } PK w:JTx  !raykernel/util/PredicateAND.class1(raykernel/util/PredicateANDjava/lang/Objectraykernel/util/PredicateaLraykernel/util/Predicate; SignatureLraykernel/util/Predicate;b7(Lraykernel/util/Predicate;Lraykernel/util/Predicate;)VA(Lraykernel/util/Predicate;Lraykernel/util/Predicate;)VCode  ()V    LineNumberTableLocalVariableTablethisLraykernel/util/PredicateAND;LocalVariableTypeTable"Lraykernel/util/PredicateAND; getBoolean(Ljava/lang/Object;)Z(TT;)Z ! tLjava/lang/Object;TT; SourceFilePredicateAND.javaGLjava/lang/Object;Lraykernel/util/Predicate;!      **+*,        n*+ *+ "#"$%& 'PK t:t;L'' raykernel/util/PredicateAND.javapackage raykernel.util; public class PredicateAND implements Predicate { Predicate a, b; public PredicateAND(Predicate a, Predicate b) { this.a = a; this.b = b; } public boolean getBoolean(T t) { return a.getBoolean(t) && b.getBoolean(t); } } PK w:W~Ossraykernel/util/Filter.class1Mraykernel/util/Filterjava/lang/ObjectpredLraykernel/util/Predicate; SignatureLraykernel/util/Predicate;(Lraykernel/util/Predicate;)V"(Lraykernel/util/Predicate;)VCode  ()V  LineNumberTableLocalVariableTablethisLraykernel/util/Filter;pLocalVariableTypeTableLraykernel/util/Filter;filter.(Ljava/util/Collection;)Ljava/util/Collection;8(Ljava/util/Collection;)Ljava/util/Collection;  /(Ljava/util/Collection;I)Ljava/util/Collection;lLjava/util/Collection;Ljava/util/Collection;9(Ljava/util/Collection;I)Ljava/util/Collection;%java/util/LinkedList $ (*)java/util/Collection +,iterator()Ljava/util/Iterator; .0/java/util/Iterator 12next()Ljava/lang/Object; 465raykernel/util/Predicate 78 getBoolean(Ljava/lang/Object;)Z (: ;8add (= >?size()I .A BChasNext()ZmaxIfilteredoLjava/lang/Object;TT; SourceFile Filter.java(Ljava/lang/Object;!  b * *+       X*+ ! "# O$Y&N+':3-:*3 -9W-< @-"-6 @"CM&4OO !ODEGF!$GH*OO "GF"$GIJKLPK t:A3KKraykernel/util/Filter.javapackage raykernel.util; import java.util.Collection; import java.util.LinkedList; public class Filter { Predicate pred; public Filter(Predicate p) { this.pred = p; } public Collection filter(Collection l) { return filter(l, Integer.MAX_VALUE); } public Collection filter(Collection l, int max) { Collection filtered = new LinkedList(); for (T o : l) { if (pred.getBoolean(o)) { filtered.add(o); } if (filtered.size() >= max) { break; } } return filtered; } } PK w:_@raykernel/util/Difference.class1[raykernel/util/Differencejava/lang/ObjectNONEI ConstantValueaddEndaddStartdelEnddelStart(IIII)VCode  ()V        LineNumberTableLocalVariableTablethisLraykernel/util/Difference;equals(Ljava/lang/Object;)ZobjLjava/lang/Object;other getAddedEnd()I getAddedStart getDeletedEndgetDeletedStartsetAdded(I)V ,.-java/lang/Math /0min(II)I ,2 30maxline setDeletedtoString()Ljava/lang/String;9java/lang/StringBuffer 8<java/lang/StringBuilder>del: [ ;@ A(Ljava/lang/String;)V ;C DEappend(I)Ljava/lang/StringBuilder;G, ;I DJ-(Ljava/lang/String;)Ljava/lang/StringBuilder;L] ;N 67 8P DQ,(Ljava/lang/String;)Ljava/lang/StringBuffer;S Uadd: [ 8NbufLjava/lang/StringBuffer; SourceFileDifference.java!      .********** ' !)*"+',--4.. . . .  >+8+M*,&*,*,*,68 :<= >>!" 0#$%/*F &%/*O '%/*X (%/*a )*U**+**1j kl45*U**+**1t uv467f8Y:L+;Y=?*BFH*BKHMOW+ROW+;YT?*BFH*BKHMOW+V~18af^WXYZPK t:d d raykernel/util/Difference.javapackage raykernel.util; /** * Represents a difference, as used in Diff. A difference consists * of two pairs of starting and ending points, each pair representing either the * "from" or the "to" collection passed to Diff. If an ending point * is -1, then the difference was either a deletion or an addition. For example, * if getDeletedEnd() returns -1, then the difference represents an * addition. */ public class Difference { public static final int NONE = -1; /** * The point at which the addition ends. */ private int addEnd = NONE; /** * The point at which the addition starts. */ private int addStart = NONE; /** * The point at which the deletion ends. */ private int delEnd = NONE; /** * The point at which the deletion starts. */ private int delStart = NONE; /** * Creates the difference for the given start and end points for the * deletion and addition. */ public Difference(int delStart, int delEnd, int addStart, int addEnd) { this.delStart = delStart; this.delEnd = delEnd; this.addStart = addStart; this.addEnd = addEnd; } /** * Compares this object to the other for equality. Both objects must be of * type Difference, with the same starting and ending points. */ public boolean equals(Object obj) { if (obj instanceof Difference) { Difference other = (Difference) obj; return (delStart == other.delStart && delEnd == other.delEnd && addStart == other.addStart && addEnd == other.addEnd); } else return false; } /** * The point at which the addition ends, if any. A value equal to * NONE means this must be an addition. */ public int getAddedEnd() { return addEnd; } /** * The point at which the addition starts, if any. A value equal to * NONE means this must be an addition. */ public int getAddedStart() { return addStart; } /** * The point at which the deletion ends, if any. A value equal to * NONE means this is an addition. */ public int getDeletedEnd() { return delEnd; } /** * The point at which the deletion starts, if any. A value equal to * NONE means this is an addition. */ public int getDeletedStart() { return delStart; } /** * Sets the point as added. The start and end points will be modified to * include the given line. */ public void setAdded(int line) { addStart = Math.min(line, addStart); addEnd = Math.max(line, addEnd); } /** * Sets the point as deleted. The start and end points will be modified to * include the given line. */ public void setDeleted(int line) { delStart = Math.min(line, delStart); delEnd = Math.max(line, delEnd); } /** * Returns a string representation of this difference. */ public String toString() { StringBuffer buf = new StringBuffer(); buf.append("del: [" + delStart + ", " + delEnd + "]"); buf.append(" "); buf.append("add: [" + addStart + ", " + addEnd + "]"); return buf.toString(); } } PK w:uI|\\raykernel/util/Tuple.class1+raykernel/util/Tuplejava/lang/Objectjava/io/SerializablefirstLjava/lang/Object; SignatureTT1;secondTT2;()VCode  LineNumberTableLocalVariableTablethisLraykernel/util/Tuple;LocalVariableTypeTable Lraykernel/util/Tuple;'(Ljava/lang/Object;Ljava/lang/Object;)V (TT1;TT2;)V    equals(Ljava/lang/Object;)Z ! othashCode()I ' $% SourceFile Tuple.javaTLjava/lang/Object;Ljava/io/Serializable;!      E*      **+*,      .++M*, *,   .." # .$%L*&*&h#  () *PK t:&.zRRraykernel/util/Tuple.javapackage raykernel.util; import java.io.Serializable; public class Tuple implements Serializable { public T1 first; public T2 second; public Tuple() { // empty tuple } public Tuple(T1 first, T2 second) { this.first = first; this.second = second; } @SuppressWarnings("unchecked") public boolean equals(Object o) { if (!(o instanceof Tuple)) return false; Tuple t = (Tuple) o; return first.equals(t.first) && second.equals(t.second); } public int hashCode() { return first.hashCode() * second.hashCode(); } } PK w:Δ #raykernel/util/EnumerativeMap.class1raykernel/util/EnumerativeMapjava/lang/Objectjava/lang/Iterablejava/util/Comparator java/io/SerializableserialVersionUIDJ ConstantValueQF'mapLjava/util/HashMap; Signature)Ljava/util/HashMap;()VCode  java/util/HashMap   LineNumberTableLocalVariableTablethisLraykernel/util/EnumerativeMap;LocalVariableTypeTable$Lraykernel/util/EnumerativeMap;add(Ljava/lang/Object;)V(TT;)V ( )*getCount(Ljava/lang/Object;)F ,.-java/lang/Float /0valueOf(F)Ljava/lang/Float; ,2 34 floatValue()F 6 78put8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;tLjava/lang/Object;currentLjava/lang/Float;TT;addAll(Ljava/util/Collection;)V(Ljava/util/Collection<+TT;>;)V BDCjava/util/Collection EFiterator()Ljava/util/Iterator; HJIjava/util/Iterator KLnext()Ljava/lang/Object; N $% HP QRhasNext()ZtsLjava/util/Collection;Ljava/util/Collection<+TT;>;compare'(Ljava/lang/Object;Ljava/lang/Object;)I (TT;TT;)Iarg0arg1(TT;)F ] ^_get&(Ljava/lang/Object;)Ljava/lang/Object; getSortedList()Ljava/util/List;()Ljava/util/List;djava/util/LinkedList c g hikeySet()Ljava/util/Set; kmljava/util/List >n(Ljava/util/Collection;)Z prqjava/util/Collections stsort)(Ljava/util/List;Ljava/util/Comparator;)VkeysLjava/util/List;Ljava/util/List;()Ljava/util/Iterator; zD{ java/util/Set g()Ljava/util/Set;remove  ~_setCount(Ljava/lang/Object;F)V(TT;F)VvalFsize()I z  SourceFileEnumerativeMap.javarLjava/lang/Object;Ljava/lang/Iterable;Ljava/util/Comparator;Ljava/io/Serializable;!    T**Y    !"  #$%&*+'+M,1 b+M*+,5W   !9: ;<" #9=>?@#+AN-GM*,M-O"! # !#ST9:" # ##SU9=VWXq *+'*,'f%  ! Y: Z:"  # Y= Z=)*[*+\,M, +M,1* ,.1  !9: ;<" #9=`abvcYeL+*fjW+*o+679; !uv" #uwEFxF *fy@  !"  #uabscYeL+*|BjW+EGI !uv" #uwhi}D*|O  !"  #~%&^ *+W T V ! 9:" # 9=l*+$+5W Z [  !9:" #9=F *f_  !"  #PK Tv:yN"raykernel/util/EnumerativeMap.javapackage raykernel.util; import java.io.Serializable; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Set; public class EnumerativeMap implements Iterable, Comparator, Serializable { private static final long serialVersionUID = 5895741080487844100L; HashMap map = new HashMap(); public void add(T t) { Float current = getCount(t); current++; map.put(t, current); } public void addAll(Collection ts) { for (T t : ts) { add(t); } } public int compare(T arg0, T arg1) { return (int) (getCount(arg0) - getCount(arg1)); } public float getCount(T t) { Float current = map.get(t); if (current == null) { current = (float) 0.0; } return current; } public List getSortedList() { List keys = new LinkedList(); keys.addAll(keySet()); Collections.sort(keys, this); return keys; } public Iterator iterator() { return this.keySet().iterator(); } public List keys() { List keys = new LinkedList(); keys.addAll(map.keySet()); return keys; } public Set keySet() { return map.keySet(); } public void remove(T t) { map.remove(t); } public void setCount(T t, float val) { map.put(t, val); } public int size() { return keySet().size(); } } PK w:#< raykernel/util/PredicateOR.class1(raykernel/util/PredicateORjava/lang/Objectraykernel/util/PredicateaLraykernel/util/Predicate; SignatureLraykernel/util/Predicate;b7(Lraykernel/util/Predicate;Lraykernel/util/Predicate;)VA(Lraykernel/util/Predicate;Lraykernel/util/Predicate;)VCode  ()V    LineNumberTableLocalVariableTablethisLraykernel/util/PredicateOR;LocalVariableTypeTable!Lraykernel/util/PredicateOR; getBoolean(Ljava/lang/Object;)Z(TT;)Z ! tLjava/lang/Object;TT; SourceFilePredicateOR.javaGLjava/lang/Object;Lraykernel/util/Predicate;!      **+*,        n*+ *+ "#"$%& 'PK t:+%%raykernel/util/PredicateOR.javapackage raykernel.util; public class PredicateOR implements Predicate { Predicate a, b; public PredicateOR(Predicate a, Predicate b) { this.a = a; this.b = b; } public boolean getBoolean(T t) { return a.getBoolean(t) || b.getBoolean(t); } } PK w:raykernel/util/Timer.class1xraykernel/util/Timerjava/lang/ObjectbeginLjava/util/Date;lapsLjava/util/Vector; SignatureOLjava/util/Vector;>;()VCodejava/util/Vector     LineNumberTableLocalVariableTable thisLraykernel/util/Timer;lap(Ljava/lang/String;)V    start"java/util/Date !%raykernel/util/Tuple !' ()getTime()JDz ,.-java/lang/Float /0valueOf(F)Ljava/lang/Float; $2 3'(Ljava/lang/Object;Ljava/lang/Object;)V 5 67add(Ljava/lang/Object;)ZsLjava/lang/String;nowprintAll= Run Time Summary ?A@raykernel/io/Out BCprintln(Ljava/lang/Object;)VE------------------------- G HIiterator()Ljava/util/Iterator; KMLjava/util/Iterator NOnext()Ljava/lang/Object;Qjava/lang/StringBuilder $S TUfirstLjava/lang/Object;Wjava/lang/String VY /Z&(Ljava/lang/Object;)Ljava/lang/String; P\ ^: P` abappend-(Ljava/lang/String;)Ljava/lang/StringBuilder; $d eUsecond Pg ah-(Ljava/lang/Object;)Ljava/lang/StringBuilder;8 Pk lmtoString()Ljava/lang/String; Ko pqhasNext()ZtLraykernel/util/Tuple;LocalVariableTypeTable;Lraykernel/util/Tuple; SourceFile Timer.java!    / Y    /*   7!Y#L$Y*+&&e*n+14W+ 26789&: ;  U<>D>FL5+J$KPY*RVX[]_*cfi_j>+nD> !FO#T$ (rst (ru  / !Y# ( )vwPK t:PY::raykernel/util/Timer.javapackage raykernel.util; import java.util.Date; import java.util.Vector; public class Timer { static Date begin; static Vector> laps = new Vector>(); public static void lap(String s) { if (begin == null) { start(); } Date now = new Date(); laps.add(new Tuple(s, ((now.getTime() - begin.getTime())) / 1000f)); begin = now; } public static void printAll() { raykernel.io.Out.println("\n Run Time Summary"); raykernel.io.Out.println("-------------------------"); for (Tuple t : laps) { raykernel.io.Out.println(t.first + ":\t" + t.second + "s"); } raykernel.io.Out.println("-------------------------"); } public static void start() { begin = new Date(); } } PK w:do0raykernel/util/FeatureGreaterThanPredicate.class16*raykernel/util/FeatureGreaterThanPredicatejava/lang/Objectraykernel/util/Predicate featurenameLjava/lang/String;gtF(Ljava/lang/String;F)VCode  ()V    LineNumberTableLocalVariableTablethis,Lraykernel/util/FeatureGreaterThanPredicate;LocalVariableTypeTable1Lraykernel/util/FeatureGreaterThanPredicate; getBoolean#(Lraykernel/ml/feature/Trainable;)Z Signature(TT;)Z "!raykernel/ml/feature/Trainable #$ getFeature2(Ljava/lang/String;)Lraykernel/ml/feature/Feature; &('raykernel/ml/feature/Feature )*value()Ft Lraykernel/ml/feature/Trainable;fLraykernel/ml/feature/Feature;TT;(Ljava/lang/Object;)Z 2  SourceFile FeatureGreaterThanPredicate.javaVLjava/lang/Object;Lraykernel/util/Predicate;!   k**+*$      +*M,%*  +, -.+/A0 ) *+ 1345PK t:=-  /raykernel/util/FeatureGreaterThanPredicate.javapackage raykernel.util; import raykernel.ml.feature.Feature; import raykernel.ml.feature.Trainable; public class FeatureGreaterThanPredicate implements Predicate { private final String featurename; float gt; public FeatureGreaterThanPredicate(String featurename, float gt) { this.featurename = featurename; this.gt = gt; } public boolean getBoolean(T t) { Feature f = t.getFeature(featurename); if (f.value() > gt) return true; return false; } } PK w:02raykernel/util/TagFile.class1raykernel/util/TagFilejava/lang/Objectcomment_starters[Ljava/lang/String; currentTagLjava/lang/String;tagMapLjava/util/HashMap; SignatureKLjava/util/HashMap;>;main([Ljava/lang/String;)VCode java/io/File  (Ljava/lang/String;)V  (Ljava/io/File;)VLineNumberTableLocalVariableTableargstLraykernel/util/TagFile;   ()V"java/lang/String$%&# ( *java/util/HashMap ) - / 0readInthisfileLjava/io/File; addValues((Ljava/lang/String;[Ljava/lang/String;)V )7 89get&(Ljava/lang/Object;)Ljava/lang/Object;;java/util/List=java/util/LinkedList < )@ ABput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; !D EFtrim()Ljava/lang/String; !H IJlength()I :L MNadd(Ljava/lang/Object;)Ztagvalues valueListLjava/util/List;vLocalVariableTypeTable$Ljava/util/List; getBoolean(Ljava/lang/String;)Z :Y 8Z(I)Ljava/lang/Object;\true !^ _NequalsvalsgetValue&(Ljava/lang/String;)Ljava/lang/String; getValueArray'(Ljava/lang/String;)[Ljava/lang/String; :f gJsize :i jkiterator()Ljava/util/Iterator; monjava/util/Iterator pqnext()Ljava/lang/Object; ms tuhasNext()ZretiIs getValues$(Ljava/lang/String;)Ljava/util/List;8(Ljava/lang/String;)Ljava/util/List;process  b remComments ) keySet()Ljava/util/Set; i java/util/Setjava/lang/StringBuilder$  append-(Ljava/lang/String;)Ljava/lang/StringBuilder; FtoString  ab ! replaceD(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;: ! contains(Ljava/lang/CharSequence;)Z ! indexOf(I)I !  substring(II)Ljava/lang/String; ! (I)Ljava/lang/String;  , ! dsplit  45linebeforeafterprune8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; ! (Ljava/lang/String;)Icommentindexjava/io/BufferedReaderjava/io/FileReader  (Ljava/io/Reader;)V FreadLine  } uready java/lang/System outLjava/io/PrintStream;error reading benchmark file: -(Ljava/lang/Object;)Ljava/lang/StringBuilder; java/io/PrintStream printlnjava/lang/ExceptionbrLjava/io/BufferedReader;eLjava/lang/Exception;   SourceFile TagFile.java!   KYY*2L k'**!Y#SY%S'*)Y+,*+.!&'1'2345Y*,+6:N-N*,+-?W,Y:66%2:C:G -KWڱ*  "#"&6(=)E+N&X/4Y1YOYP MQR6ST  MQUVW%*,+6:M,,X!C[]3 568 %1%O `RT  `Uaby*,+6:M,,X!= ?@B 1O `RT  `UcdK*,+6:M,,e!N6,h:l!:-Sr-& G IJLNO6Q?OIT>K1KO ?`R/v,wx6 yT  ?`Uz{ |@ *,+6:Y 1 O}**+~L*,N'-l!M+Y,*,L-r+3++:CN++:`C:*-M +M* **,6 ^` b:`CgLi[jllqm|qtvyH1 OyPP[!ly+,>++C} *1x0=YY+ķM *,ȷ,͚NлYַ-ض۱"%%&<*=1=23&bp&*'Y:6>2M*+,L+$ &1&yPK {:s raykernel/util/TagFile.javapackage raykernel.util; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.util.HashMap; import java.util.LinkedList; import java.util.List; public class TagFile { public static void main(String[] args) { TagFile t = new TagFile(new File(args[0])); } String[] comment_starters = {"%", "#"}; private String currentTag; HashMap> tagMap = new HashMap>(); public TagFile(File file) { readIn(file); } private void addValues(String tag, String[] values) { List valueList = tagMap.get(tag); if (valueList == null) { valueList = new LinkedList(); tagMap.put(tag, valueList); } for (String v : values) { v = v.trim(); if (v.length() != 0) { valueList.add(v); } } } public boolean getBoolean(String tag) { List vals = tagMap.get(tag); if (vals == null) return false; return vals.get(0).trim().equals("true"); } public String getValue(String tag) { List vals = tagMap.get(tag); if (vals == null) return null; return vals.get(0); } public String[] getValueArray(String tag) { List vals = tagMap.get(tag); if (vals == null) return null; String[] ret = new String[vals.size()]; int i = 0; for (String s : vals) { ret[i++] = s; } return ret; } public List getValues(String tag) { return tagMap.get(tag); } private void process(String line) { line = remComments(line); for (String tag : tagMap.keySet()) { line = line.replace("$" + tag, getValue(tag)); } String[] values; if (line.contains(":")) { String before = line.substring(0, line.indexOf(':')).trim(); String after = line.substring(line.indexOf(':') + 1).trim(); currentTag = before; values = after.split(","); } else { values = line.split(","); } if (currentTag != null) { addValues(currentTag, values); } } public String prune(String line, String comment) { int index = line.indexOf(comment); if (index < 0) return line; if (index == 0) return ""; return line.substring(0, index).trim(); } private void readIn(File file) { BufferedReader br; try { br = new BufferedReader(new FileReader(file)); while (br.ready()) { process(br.readLine()); } } catch (Exception e) { System.out.println("error reading benchmark file: " + e); } } public String remComments(String line) { for (String s : comment_starters) { line = prune(line, s); } return line; } } PK w:PԎ!raykernel/util/PredicateNOT.class1%raykernel/util/PredicateNOTjava/lang/Objectraykernel/util/PredicatenotLraykernel/util/Predicate; SignatureLraykernel/util/Predicate;(Lraykernel/util/Predicate;)V"(Lraykernel/util/Predicate;)VCode  ()V  LineNumberTableLocalVariableTablethisLraykernel/util/PredicateNOT;LocalVariableTypeTable"Lraykernel/util/PredicateNOT; getBoolean(Ljava/lang/Object;)Z(TT;)Z  tLjava/lang/Object;TT; SourceFilePredicateNOT.javaGLjava/lang/Object;Lraykernel/util/Predicate;!     b **+       c*+ !"# $PK t:bbp raykernel/util/PredicateNOT.javapackage raykernel.util; public class PredicateNOT implements Predicate { Predicate not; public PredicateNOT(Predicate not) { this.not = not; } public boolean getBoolean(T t) { return !(not.getBoolean(t)); } }PK w:qt raykernel/util/ObjectStore.class1raykernel/util/ObjectStorejava/lang/ObjectlocationLjava/lang/String;()VCode java/lang/StringBuilder  objectstore raykernel/config/Config get&(Ljava/lang/String;)Ljava/lang/String; java/lang/String valueOf&(Ljava/lang/Object;)Ljava/lang/String;  (Ljava/lang/String;)V/ ! "#append-(Ljava/lang/String;)Ljava/lang/StringBuilder; % &'toString()Ljava/lang/String; ) LineNumberTableLocalVariableTable - thisLraykernel/util/ObjectStore;&(Ljava/lang/String;)Ljava/lang/Object;2obstore_output 4 56 getBoolean(Ljava/lang/String;)Z8OBSTORE: reading: <>=raykernel/io/Out ?@println'(Ljava/lang/String;Ljava/lang/String;)V BDCraykernel/util/Tools EFmakeDir"(Ljava/lang/String;)Ljava/io/File;Hjava/io/FileInputStreamJ.dat GMjava/io/ObjectInputStream LO P(Ljava/io/InputStream;)V LR ST readObject()Ljava/lang/Object; VXWjava/lang/System YZerrLjava/io/PrintStream;\unable to load data: ^ "_-(Ljava/lang/Object;)Ljava/lang/StringBuilder; acbjava/io/PrintStream ?eloaded: %hjava/lang/ExceptionkeyinLjava/lang/Object;f_inLjava/io/FileInputStream;obj_inLjava/io/ObjectInputStream;eLjava/lang/Exception;main([Ljava/lang/String;)Vuworked <w ?x(Ljava/lang/Object;)Vargs[Ljava/lang/String;put'(Ljava/lang/String;Ljava/lang/Object;)V~ writing: java/io/FileOutputStream java/io/ObjectOutputStream (Ljava/io/OutputStream;)V x writeObjectfailed to write data: put: java/io/IOExceptionof_outLjava/io/FileOutputStream;obj_outLjava/io/ObjectOutputStream;Ljava/io/IOException; SourceFileObjectStore.java!  ? Y  $(*   + /*,* + ./ 0 137 Y9* $;L(AWGY Y(* I $KMLY,NN-QLMU Y[,]$`137 Yd+f $;+UXg*2 &GP X#Y%o(w)++4irjkGlmPnoYpq rs 4tv* ;=+ yz {| 137 Y}* $;Y Y(* I $MY,N-+N Y-]$v137 Y* $;LO** @AG>JGMOOPQcTkUV+4ik>GPpPK ;v:\e55raykernel/util/ObjectStore.javapackage raykernel.util; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import raykernel.config.Config; public class ObjectStore { private static String location = Config.get("objectstore") + "/"; public static Object get(String key) { if (Config.getBoolean("obstore_output")) raykernel.io.Out.println("OBSTORE", "reading: " + key); // Read from disk using FileInputStream Object in = null; try { Tools.makeDir(location); FileInputStream f_in = new FileInputStream(location + key + ".dat"); // Read object using ObjectInputStream ObjectInputStream obj_in = new ObjectInputStream(f_in); // Read an object in = obj_in.readObject(); } catch (Exception e) { System.err.println("unable to load data: " + e); } if (Config.getBoolean("obstore_output")) raykernel.io.Out.println("OBSTORE", "loaded: " + in.toString()); return in; } public static void main(String[] args) { /* String s = "hello"; ObjectStore.put("yo", s); String out = (String) ObjectStore.get("yo"); io.Out.println("world? " + out); */ //ExceptionInstance ei = new ExceptionInstance(new JClass("hi"), new JMethod( //"foo.util.TestB void computeMore(int,)")); raykernel.io.Out.println("worked"); } public static void put(String key, Object o) { if (Config.getBoolean("obstore_output")) raykernel.io.Out.println("OBSTORE", "writing: " + key); // Write to disk with FileOutputStream FileOutputStream f_out; try { f_out = new FileOutputStream(location + key + ".dat"); // Write object with ObjectOutputStream ObjectOutputStream obj_out = new ObjectOutputStream(f_out); // Write object out to disk obj_out.writeObject(o); } catch (IOException e) { raykernel.io.Out.println("failed to write data: " + e); } if (Config.getBoolean("obstore_output")) raykernel.io.Out.println("OBSTORE", "put: " + key); } } PK w:z raykernel/util/CharCounter.class1Praykernel/util/CharCounterjava/lang/ObjectcountMapLjava/util/HashMap; Signature=Ljava/util/HashMap;maxCmax_valI()VCode  java/util/HashMap      LineNumberTableLocalVariableTablethisLraykernel/util/CharCounter;count(C)V "$#java/lang/Character %&valueOf(C)Ljava/lang/Character; ( )*get&(Ljava/lang/Object;)Ljava/lang/Object;,java/lang/Integer +. /0intValue()I +2 %3(I)Ljava/lang/Integer; 5 67put8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;ccurrentLjava/lang/Integer;newval(Ljava/lang/String;)V >@?java/lang/String ABcharAt(I)C D  >F G0lengthsLjava/lang/String;i getMaxChar()C getMaxVal SourceFileCharCounter.java!  U**Y* *    ?*!'+M>, ,-`>*!14W* **& ,49>*??8 09:.; <(=+=>  *C+E#% &(#'+*((HI%J  8 KL/*/ M0/*4 NOPK t:QF  raykernel/util/CharCounter.javapackage raykernel.util; import java.util.HashMap; public class CharCounter { HashMap countMap = new HashMap(); //keep track of max char max = ' '; int max_val = 0; public void count(char c) { Integer current = countMap.get(c); int newval = 1; if (current != null) { newval = current.intValue() + 1; } countMap.put(c, newval); if (newval > max_val) { max_val = newval; max = c; } } public void count(String s) { for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c != ' ' && c != '\t') { count(c); } } } public char getMaxChar() { return max; } public int getMaxVal() { return max_val; } } PK w: raykernel/util/Analyzer.class1 raykernel/util/Analyzerjava/lang/Objectanalyze(Ljava/lang/Object;)V Signature(TT;)V SourceFile Analyzer.java(Ljava/lang/Object;   PK t:|__raykernel/util/Analyzer.javapackage raykernel.util; public interface Analyzer { public void analyze(T t); } PK w:}=^raykernel/util/Runner.class1traykernel/util/Runnerjava/lang/Object()VCode  LineNumberTableLocalVariableTablethisLraykernel/util/Runner; runCommand#(Ljava/lang/String;Ljava/io/File;)Djava/lang/StringBuilder running:  (Ljava/lang/String;)V  append-(Ljava/lang/String;)Ljava/lang/StringBuilder;  toString()Ljava/lang/String; "!raykernel/io/Out #$println(Ljava/lang/Object;)V&java/util/Date % )+*java/lang/Runtime ,- getRuntime()Ljava/lang/Runtime; )/ 01exec'(Ljava/lang/String;)Ljava/lang/Process; )3 04H(Ljava/lang/String;[Ljava/lang/String;Ljava/io/File;)Ljava/lang/Process;6done8java/io/BufferedReader:java/io/InputStreamReader <>=java/lang/Process ?@getInputStream()Ljava/io/InputStream; 9B C(Ljava/io/InputStream;)V 7E F(Ljava/io/Reader;)V <H I@getErrorStream KMLjava/lang/String NOvalueOf&(Ljava/lang/Object;)Ljava/lang/String;Q: 7S TreadLineV[err]: XZYjava/lang/Exception [printStackTrace %] ^_getTime()J@@commandLjava/lang/String;dirLjava/io/File;procLjava/lang/Process;briLjava/io/BufferedReader;brelineilineestartLjava/util/Date;endeLjava/lang/Exception; SourceFile Runner.java!/*    :::Y*%Y':+(*.M (*+2M57Y9Y,;ADN7Y9Y,GAD:Y*JP-RY:ާY*JURY:ݻ%Y': :  W\\e`o X R %)4>"C$V%j'm)',.,1358 z bcde1fg>fgVqhij]jimkc8kclcmn onpq rsPK t:)raykernel/util/Runner.javapackage raykernel.util; import java.io.BufferedReader; import java.io.File; import java.io.InputStreamReader; import java.util.Date; public class Runner { public static double runCommand(String command, File dir) { Process proc; BufferedReader bri, bre; String linei, linee = null; Date start = null, end = null; try { raykernel.io.Out.println("running: " + command); start = new Date(); if (dir == null) { proc = Runtime.getRuntime().exec(command); } else { proc = Runtime.getRuntime().exec(command, null, dir); } // proc.waitFor(); raykernel.io.Out.println("done"); bri = new BufferedReader(new InputStreamReader(proc.getInputStream())); bre = new BufferedReader(new InputStreamReader(proc.getErrorStream())); while ((linei = bri.readLine()) != null) { raykernel.io.Out.println(command + ": " + linei); } while ((linee = bre.readLine()) != null) { raykernel.io.Out.println(command + "[err]: " + linee); } end = new Date(); } catch (Exception e) { e.printStackTrace(); } return ((end.getTime() - start.getTime())) / 1000.0; } } PK w:ѰDGGraykernel/util/Diag.class1raykernel/util/Diagjava/lang/Object()VCode  LineNumberTableLocalVariableTablethisLraykernel/util/Diag; checkDepth SourceFile Diag.java!/*   !  PK t:t.Uiiraykernel/util/Diag.javapackage raykernel.util; public class Diag { public static void checkDepth() { /* Exception e = new Exception(); if( e.getStackTrace().length > 50 ) { io.Out.println("stack depth: " + e.getStackTrace().length ); } if( e.getStackTrace().length > 100 ) { e.printStackTrace(); System.exit(0); } */ } } PK w:a  raykernel/util/Permute.class1Uraykernel/util/Permutejava/lang/Object()VCode  LineNumberTableLocalVariableTablethisLraykernel/util/Permute;determinitsticPartition$(Ljava/util/List;I)[Ljava/util/List;java/util/LinkedList  java/util/List iterator()Ljava/util/Iterator; java/util/Iterator next()Ljava/lang/Object;  !"add(Ljava/lang/Object;)Z $ %&hasNext()ZlistLjava/util/List;partsIlists[Ljava/util/List;icountoLjava/lang/Object;exch(Ljava/util/List;II)V 4 56get(I)Ljava/lang/Object; 8 9:set'(ILjava/lang/Object;)Ljava/lang/Object;ljswaprandomPartition @ ABshuffle(Ljava/util/List;)V D  F GHsize()I JLKjava/lang/Math MNrandom()D P 12Nr SourceFile Permute.java!/*   NM>,YS>*::,p2W#, *  2?BL >N'(N)*I+,-*0.*2/012u!*3N**37W*-7W #$% & *!;(!-*!<*=0 >B *?*C *+  '( )* AB'*E<=Idk`>*O 12 452&7 *''( Q* -*R*STPK t: E<<raykernel/util/Permute.javapackage raykernel.util; import java.util.LinkedList; import java.util.List; public class Permute { @SuppressWarnings("unchecked") public static List[] determinitsticPartition(List list, int parts) { List[] lists = new LinkedList[parts]; for (int i = 0; i < parts; i++) { lists[i] = new LinkedList(); } int count = 0; for (Object o : list) { lists[count % parts].add(o); count++; } return lists; } // swaps array elements i and j @SuppressWarnings("unchecked") static void exch(List l, int i, int j) { Object swap = l.get(i); l.set(i, l.get(j)); l.set(j, swap); } public static List[] randomPartition(List list, int parts) { shuffle(list); return determinitsticPartition(list, parts); } // take as input an array of strings and rearrange them in random order public static void shuffle(List list) { int N = list.size(); for (int i = 0; i < N; i++) { int r = i + (int) (Math.random() * (N - i)); // between i and N-1 exch(list, i, r); } } } PK w:5o--0raykernel/util/HasLineWithFeaturePredicate.class1D*raykernel/util/HasLineWithFeaturePredicatejava/lang/Objectraykernel/util/Predicate featurenameLjava/lang/String;(Ljava/lang/String;)VCode  ()V  LineNumberTableLocalVariableTablethis,Lraykernel/util/HasLineWithFeaturePredicate;LocalVariableTypeTable1Lraykernel/util/HasLineWithFeaturePredicate; getBoolean7(Lraykernel/apps/readability/code/TrainableCodeBlock;)Z Signature(TT;)Z 2raykernel/apps/readability/code/TrainableCodeBlock  iterator()Ljava/util/Iterator; "$#java/util/Iterator %&next()Ljava/lang/Object;((raykernel/apps/readability/code/CodeLine '* +, getFeature2(Ljava/lang/String;)Lraykernel/ml/feature/Feature; .0/raykernel/ml/feature/Feature 12value()F "4 56hasNext()Zt4Lraykernel/apps/readability/code/TrainableCodeBlock;l*Lraykernel/apps/readability/code/CodeLine;fLraykernel/ml/feature/Feature;TT;(Ljava/lang/Object;)Z @  SourceFile HasLineWithFeaturePredicate.javaiLjava/lang/Object;Lraykernel/util/Predicate;!  X * *+       8+N(-!'M,*):- -3+-6*88789:;<887=A> ) *+?ABCPK t:܅1_hh/raykernel/util/HasLineWithFeaturePredicate.javapackage raykernel.util; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.Feature; public class HasLineWithFeaturePredicate implements Predicate { private final String featurename; public HasLineWithFeaturePredicate(String featurename) { this.featurename = featurename; } public boolean getBoolean(T t) { for (CodeLine l : t) { Feature f = l.getFeature(featurename); if (f != null && f.value() > 0) return true; } return false; } } PK w:!zu raykernel/util/SetList.class1qraykernel/util/SetListjava/lang/Objectjava/lang/IterablelistLjava/util/LinkedList; SignatureLjava/util/LinkedList;setLjava/util/HashSet;Ljava/util/HashSet;()VCode  java/util/LinkedList   java/util/HashSet   LineNumberTableLocalVariableTablethisLraykernel/util/SetList;LocalVariableTypeTableLraykernel/util/SetList;add(Ljava/lang/Object;)V(TT;)V ' ($addLasttLjava/lang/Object;TT;addAll(Ljava/util/Collection;)V(Ljava/util/Collection;)V 021java/util/Collection 34iterator()Ljava/util/Iterator; 687java/util/Iterator 9:next()Ljava/lang/Object; < #$ 6> ?@hasNext()ZmethodsLjava/util/Collection;Ljava/util/Collection;addFirst F GHcontains(Ljava/lang/Object;)Z J #H L D$ '(TT;)Zequals Q RSsize()I 2 V OHootheriter1Ljava/util/Iterator;iter2hashCode ^ \S ^isEmpty b `@()Ljava/util/Iterator; 2pop()TT; h i:remove k iHfirst Q SourceFile SetList.javaALjava/lang/Object;Ljava/lang/Iterable;!    c**Y*Y    ! "#$ %Z*+&  )*!")+,- .#+/N-5M*,;-=" # #AB)*! #"#AC)+D$ %y*+E*+IW*+K "#% )*!")+($ %y*+E*+IW*+M) +,. )*!")+GH NY *+E2  )*! " )+OHG+A+M*P,P1*TN,T:-55U-=. 9; =?@"B%D8E:BCJEN4G GW* 9X )YZ"#[Z! G"\SL*]*_hS  ! "`@D*aX  ! "34 cD*d]  ! "e: fk*gL*+jW+bcd  l*!" l+RSD*mi  ! "no pPK t:$FFraykernel/util/SetList.javapackage raykernel.util; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; public class SetList implements Iterable { LinkedList list = new LinkedList(); HashSet set = new HashSet(); public void add(T t) { addLast(t); } public void addAll(Collection methods) { for (T t : methods) { add(t); } } public void addFirst(T t) { if (!set.contains(t)) { set.add(t); list.addFirst(t); } } public void addLast(T t) { if (!set.contains(t)) { set.add(t); list.addLast(t); } } public boolean contains(T t) { return set.contains(t); } public boolean equals(Object o) { //io.Out.println("call to equals"); if (o instanceof SetList) //could be { SetList other = (SetList) o; if (this.size() == other.size()) //still could be { Iterator iter1 = this.iterator(); Iterator iter2 = other.iterator(); while (iter1.hasNext()) //already know same size { if (!iter1.next().equals(iter2.next())) return false; } // io.Out.println("true"); return true; } } return false; } public int hashCode() { return set.hashCode() * list.hashCode(); } public boolean isEmpty() { return list.isEmpty(); } public Iterator iterator() { return list.iterator(); } public T pop() { T first = list.remove(); set.remove(first); return first; } public int size() { return list.size(); } } PK w:g$00!raykernel/util/Distribution.class1Fraykernel/util/Distributionjava/lang/ObjectcountFmaxminsum()VCode         LineNumberTableLocalVariableTablethisLraykernel/util/Distribution;addFloat(F)VfaddInt(I)V # iIgetMax()FgetMeangetMintoString()Ljava/lang/String;-java/lang/StringBuilder/count= ,1 2(Ljava/lang/String;)V ,4 56append(F)Ljava/lang/StringBuilder;8 max= ,: 5;-(Ljava/lang/String;)Ljava/lang/StringBuilder;= mean = ? ('A sum = ,C *+ SourceFileDistribution.java!   Y* * ***     }1#**##**#*Y b*Y#b &011 ! ?*" $%&' /*# (' 4 **n(  )' /*- *+ b8,Y.0*379*3<9*>3@9*3B2 8DEPK t:_ raykernel/util/Distribution.javapackage raykernel.util; public class Distribution { private float count = 0; private float max = Float.MIN_VALUE; private float min = Float.MAX_VALUE; private float sum = 0; public void addFloat(float f) { if (f > max) { max = f; } if (f < min) { min = f; } count++; sum += f; } public void addInt(int i) { addFloat(i); } public float getMax() { return max; } public float getMean() { return sum / count; } public float getMin() { return min; } public String toString() { return "count= " + count + " max= " + max + " mean = " + getMean() + " sum = " + sum; } } PK w:B(raykernel/util/HasFeaturePredicate.class12"raykernel/util/HasFeaturePredicatejava/lang/Objectraykernel/util/Predicate featurenameLjava/lang/String;(Ljava/lang/String;)VCode  ()V  LineNumberTableLocalVariableTablethis$Lraykernel/util/HasFeaturePredicate;LocalVariableTypeTable)Lraykernel/util/HasFeaturePredicate; getBoolean#(Lraykernel/ml/feature/Trainable;)Z Signature(TT;)Z raykernel/ml/feature/Trainable   getFeature2(Ljava/lang/String;)Lraykernel/ml/feature/Feature; "$#raykernel/ml/feature/Feature %&value()Ft Lraykernel/ml/feature/Trainable;fLraykernel/ml/feature/Feature;TT;(Ljava/lang/Object;)Z .  SourceFileHasFeaturePredicate.javaVLjava/lang/Object;Lraykernel/util/Predicate;!  X * *+       +*M,,!   '( )*'+A, ) *+-/01PK t: implements Predicate { private final String featurename; public HasFeaturePredicate(String featurename) { this.featurename = featurename; } public boolean getBoolean(T t) { Feature f = t.getFeature(featurename); if (f != null && f.value() > 0) return true; return false; } } PK w:T raykernel/util/WordCounter.class1Craykernel/util/WordCounterjava/lang/ObjectcountMapLjava/util/HashMap; Signature:Ljava/util/HashMap;maxLjava/lang/String;max_valI()VCode  java/util/HashMap      LineNumberTableLocalVariableTablethisLraykernel/util/WordCounter; countWord(Ljava/lang/String;)V $&%java/lang/String '(length()I * +,get&(Ljava/lang/Object;)Ljava/lang/Object;.java/lang/Integer -0 1(intValue -3 45valueOf(I)Ljava/lang/Integer; 7 89put8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;scurrentLjava/lang/Integer;newval getMaxVal getMaxWord()Ljava/lang/String; SourceFileWordCounter.java!  U**Y**    !"B+#*+)-M>, ,/`>*+26W* **+.  "/7< A"*B B: -;<+= >(/*&  ?@/*+  ABPK t:Draykernel/util/WordCounter.javapackage raykernel.util; import java.util.HashMap; public class WordCounter { HashMap countMap = new HashMap(); //keep track of max String max = ""; int max_val = 0; public void countWord(String s) { if (s.length() < 2) return; Integer current = countMap.get(s); int newval = 1; if (current != null) { newval = current.intValue() + 1; } countMap.put(s, newval); if (newval > max_val) { max_val = newval; max = s; } } public int getMaxVal() { return max_val; } public String getMaxWord() { return max; } }PK w:J$praykernel/util/Common.class1raykernel/util/Commonjava/lang/Object()VCode  LineNumberTableLocalVariableTablethisLraykernel/util/Common;makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String;java/lang/StringtLjava/lang/String;ret[Ljava/lang/String; SourceFile Common.java!/*   G L+*S+   PK t:Eraykernel/util/Common.javapackage raykernel.util; public class Common { public static String[] makeSingletonArray(String t) { String[] ret = new String[1]; ret[0] = t; return ret; } } PK w:raykernel/util/Env.class1"raykernel/util/Envjava/lang/Object()VCode  LineNumberTableLocalVariableTablethisLraykernel/util/Env;runningWindows()Zos.name java/lang/System  getProperty&(Ljava/lang/String;)Ljava/lang/String;Windows java/lang/String contains(Ljava/lang/CharSequence;)Z SourceFileEnv.java!/*   +    !PK t:EXraykernel/util/Env.javapackage raykernel.util; public class Env { public static boolean runningWindows() { // io.Out.println("os: " + System.getProperty("os.name")); return System.getProperty("os.name").contains("Windows"); } } PK w:Qraykernel/util/Predicate.class1 raykernel/util/Predicatejava/lang/Object getBoolean(Ljava/lang/Object;)Z Signature(TT;)Z SourceFilePredicate.java(Ljava/lang/Object;   PK t:ffraykernel/util/Predicate.javapackage raykernel.util; public interface Predicate { public boolean getBoolean(T t); } PK w:BV raykernel/util/Counter.class1raykernel/util/Counterjava/lang/ObjectcountMapLjava/util/HashMap; Signature:Ljava/util/HashMap;distMapDLjava/util/HashMap;()VCodejava/util/HashMap       LineNumberTableLocalVariableTable thisLraykernel/util/Counter;add(Ljava/lang/String;F)V  !get&(Ljava/lang/Object;)Ljava/lang/Object;#raykernel/util/Distribution " & '(put8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; "* +,addFloat(F)VkeyLjava/lang/String;fFdLraykernel/util/Distribution;(Ljava/lang/String;I)V 5 iIgetCount(Ljava/lang/String;)I;java/lang/Integer := >?intValue()ILjava/lang/Integer;getMean(Ljava/lang/String;)F "D AE()Finc(Ljava/lang/String;)V :I J(I)VprintAll M NOkeySet()Ljava/util/Set; QSR java/util/Set TUiterator()Ljava/util/Iterator; WYXjava/util/Iterator Z[next()Ljava/lang/Object;]java/lang/String _ `G printCount Wb cdhasNext()Z f gG printDistsjjava/lang/StringBuilder \l mnvalueOf&(Ljava/lang/Object;)Ljava/lang/String; ip Gr : it uvappend-(Ljava/lang/String;)Ljava/lang/StringBuilder; x 89 iz u{(I)Ljava/lang/StringBuilder; i} ~toString()Ljava/lang/String; raykernel/io/Out println(Ljava/lang/Object;)V : not seen i u-(Ljava/lang/Object;)Ljava/lang/StringBuilder; SourceFile Counter.java!     =YY   /*   x&*"M,"Y$M*,%W,#)  % &-.&/0 12 3 ?*4 -.67 89 V*:L++< !"$-. 6@ AB H*"L+C * +-. 12 FG {3*:L+:YHL:Y+<`HL*+%W0 248);2<3-. (6@ K  MLPL+V\K*^+aLPL+V\K*e+a@B@&E?GCELIh.?h. `G LiY*koqs*wy| MN -. gG C*"L+iY*kos|iY*koqs+|R TV(ZB\C-. 812PK t:-..raykernel/util/Counter.javapackage raykernel.util; import java.util.HashMap; public class Counter { private static HashMap countMap = new HashMap(); private static HashMap distMap = new HashMap(); public static void add(String key, float f) { Distribution d = distMap.get(key); if (d == null) { d = new Distribution(); distMap.put(key, d); } d.addFloat(f); } public static void add(String key, int i) { add(key, (float) i); } public static int getCount(String key) { Integer i = countMap.get(key); if (i == null) return 0; return i.intValue(); } public static float getMean(String key) { // TODO Auto-generated method stub Distribution d = distMap.get(key); return d.getMean(); } public static void inc(String key) { Integer i = countMap.get(key); if (i == null) { i = new Integer(1); } else { i = new Integer(i.intValue() + 1); } countMap.put(key, i); } public static void printAll() { for (String s : countMap.keySet()) { printCount(s); } for (String s : distMap.keySet()) { printDist(s); } } public static void printCount(String key) { raykernel.io.Out.println(key + " : " + getCount(key)); } public static void printDist(String key) { Distribution d = distMap.get(key); if (d == null) { raykernel.io.Out.println(key + " : not seen"); } else { raykernel.io.Out.println(key + " : " + d); } } } PK w:y0OOraykernel/util/Diff.class1Nraykernel/util/Diffjava/lang/Object()VCode  LineNumberTableLocalVariableTablethisLraykernel/util/Diff;diff8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;java/lang/StringBuffer  \n java/lang/String split'(Ljava/lang/String;)[Ljava/lang/String;[[I   equals(Ljava/lang/Object;)Z "$#java/lang/Math %&max(II)I(java/lang/StringBuilder*< ', -(Ljava/lang/String;)V '/ 01append-(Ljava/lang/String;)Ljava/lang/StringBuilder;3 '5 67toString()Ljava/lang/String; 9 0:,(Ljava/lang/String;)Ljava/lang/StringBuffer;<> 5string1Ljava/lang/String;string2resultLjava/lang/StringBuffer;x[Ljava/lang/String;yMINoptij SourceFile Diff.java!/*    YM*N+:-66``:d6^d6 M-2 22 `2 `.`O"2 `2 .2 `.!O  66 v-2 2  ^`2 .2 `.&,'Y)+-2.2.48W$,'Y;+ 2.2.48W_ U','Y;+ 2.2.48W* #,'Y)+-2.2.48W ,= v   .7@Oh%&(*+-/3&!8$:+<O>V@v8D z >?@?ABzCDrEDnFG iHG.[I4cJG=RKG JGKG LMPK t:Lnssraykernel/util/Diff.javapackage raykernel.util; public class Diff { public static String diff(String string1, String string2) { StringBuffer result = new StringBuffer(); String[] x = string1.split("\\n"); String[] y = string2.split("\\n"); // number of lines of each file int M = x.length; int N = y.length; // opt[i][j] = length of LCS of x[i..M] and y[j..N] int[][] opt = new int[M + 1][N + 1]; // compute length of LCS and all subproblems via dynamic programming for (int i = M - 1; i >= 0; i--) { for (int j = N - 1; j >= 0; j--) { if (x[i].equals(y[j])) { opt[i][j] = opt[i + 1][j + 1] + 1; } else { opt[i][j] = Math.max(opt[i + 1][j], opt[i][j + 1]); } } } // recover LCS itself and print out non-matching lines to standard output int i = 0, j = 0; while (i < M && j < N) { if (x[i].equals(y[j])) { i++; j++; } else if (opt[i + 1][j] >= opt[i][j + 1]) { result.append("< " + x[i++] + "\n"); } else { result.append("> " + y[j++] + "\n"); } } // dump out one remainder of one string if the other is exhausted while (i < M || j < N) { if (i == M) { result.append("> " + y[j++] + "\n"); } else if (j == N) { result.append("< " + x[i++] + "\n"); } } return result.toString(); } }PK w:xl!raykernel/util/CachedString.class1.raykernel/util/CachedStringjava/lang/Object cached_strLjava/lang/String;dirtyZ()VCode   LineNumberTableLocalVariableTablethisLraykernel/util/CachedString; createString()Ljava/lang/String; inhertCache (Lraykernel/util/CachedString;)Vjava/lang/StringBuilder   java/lang/String !valueOf&(Ljava/lang/Object;)Ljava/lang/String; # $(Ljava/lang/String;)V & 'toStringcs recordChange +  SourceFileCachedString.java!  < * *    Z*+*Y+"% ()  4*  ' O******" ,-PK t:"A.. raykernel/util/CachedString.javapackage raykernel.util; public abstract class CachedString { protected String cached_str; protected boolean dirty = true; protected abstract String createString(); protected void inhertCache(CachedString cs) { this.dirty = cs.dirty; this.cached_str = cs.cached_str + ""; } protected void recordChange() { dirty = true; } public String toString() { if (dirty) { cached_str = createString(); dirty = false; } else { //io.Out.println("used cache!"); } return cached_str; } } PK w:S@ddraykernel/util/Tools.class1araykernel/util/Toolsjava/lang/Object()VCode  LineNumberTableLocalVariableTablethisLraykernel/util/Tools; getSubDir0(Ljava/io/File;Ljava/lang/String;)Ljava/io/File;  java/io/File getPath()Ljava/lang/String;/ java/lang/String endsWith(Ljava/lang/String;)Zjava/lang/StringBuilder ! "#valueOf&(Ljava/lang/Object;)Ljava/lang/String; % &(Ljava/lang/String;)V ( )*append-(Ljava/lang/String;)Ljava/lang/StringBuilder; , -toString / 01makeDir"(Ljava/lang/String;)Ljava/io/File;dirLjava/io/File;subLjava/lang/String;parent % 9 :;exists()Z=creating dir: ? )@-(Ljava/lang/Object;)Ljava/lang/StringBuilder; BDCraykernel/io/Out EFprintln(Ljava/lang/Object;)V H I;mkdirswdmakeNameSimple&(Ljava/lang/String;)Ljava/lang/String;O. Q RS lastIndexOf(Ljava/lang/String;)I U VW substring(I)Ljava/lang/String;name printTime[ TIMESTAMP: ]java/util/Date \  SourceFile Tools.java!/*   :*M,Y, $'+MY, $+'+M,.   "5 :23:45565 01n*Y*7L+8Y<$+>+A+GW+  #(! *J5 !K3 LM7 **NP`T &  X5 Y>YZ$\Y^>+A +, _`PK t:JSraykernel/util/Tools.javapackage raykernel.util; import java.io.File; import java.util.Date; public class Tools { public static File getSubDir(File dir, String sub) { String parent = dir.getPath(); if (!parent.endsWith("/")) { parent = parent + "/"; } parent = parent + sub; return makeDir(parent); } public static File makeDir(String s) { File wd = new File(s); if (!wd.exists()) { raykernel.io.Out.println("creating dir: " + wd); wd.mkdir(); } return wd; } public static String makeNameSimple(String name) { return name.substring(name.lastIndexOf(".") + 1); } public static void printTime() { raykernel.io.Out.println("TIMESTAMP: " + new Date()); } } PK w:$Y1raykernel/util/Test.class1=raykernel/util/Testjava/lang/Object()VCode  LineNumberTableLocalVariableTablethisLraykernel/util/Test;main([Ljava/lang/String;)V Exceptionsjava/io/IOExceptionjava/util/Scannerjava/io/BufferedReaderjava/io/FileReader resources  (Ljava/lang/String;)V   (Ljava/io/Reader;)V " #(Ljava/lang/Readable;)V % &'next()Ljava/lang/String; )+*raykernel/io/Out ,-println(Ljava/lang/Object;)V / 01hasNext()Z 3 4close6java/lang/Exceptionargs[Ljava/lang/String;sLjava/util/Scanner; SourceFile Test.java!/*   NLYYY!L +$(+.M++2N++2-++2+.5/: >$./#3%:";#?%C'E#I%M( N78L9:;(Ljava/lang/String;)VCode   ()V  LineNumberTableLocalVariableTablethis*Lraykernel/apps/readability/code/CodeLine;getLine-(I)Lraykernel/apps/readability/code/CodeLine;numIgetLines(II)Ljava/util/Iterator; SignatureD(II)Ljava/util/Iterator;  iterator()Ljava/util/ListIterator;startendF()Ljava/util/ListIterator;#java/util/LinkedList " "& '(add(Ljava/lang/Object;)Z "* + listIteratorlLjava/util/LinkedList;LocalVariableTypeTableBLjava/util/LinkedList;length()I 354java/lang/String 01lineContaining8'java/lang/UnsupportedOperationException 7 indexlinesContainingindex1index2 linesMatching/(Ljava/util/regex/Pattern;)Ljava/util/Iterator;[(Ljava/util/regex/Pattern;)Ljava/util/Iterator;pLjava/util/regex/Pattern;sizetoString()Ljava/lang/String; SourceFile CodeLine.java!  F * *+     D* U *#$ %  ! a"Y$L+*%W+)*+, ,-.  ,/01 2* 21 6 <7Y96:; F7Y9; <=>?@ <7Y9@ABC1 ,E DE /* J FGPK ;v:-raykernel/apps/readability/code/CodeLine.javapackage raykernel.apps.readability.code; import java.util.Iterator; import java.util.LinkedList; import java.util.ListIterator; import java.util.regex.Pattern; import raykernel.ml.core.TrainableAdapter; /** * A wrapper around a string, allows decorations in the form of Features * * @author rlb7g * */ public class CodeLine extends TrainableAdapter { String line; public CodeLine(String line) { this.line = line; } public CodeLine getLine(int num) { if (num == 0) return this; return null; } public Iterator getLines(int start, int end) { if (start == 0 && end == 0) return iterator(); return null; } public ListIterator iterator() { LinkedList l = new LinkedList(); l.add(this); return l.listIterator(); } public int length() { return line.length(); } public CodeLine lineContaining(int index) { throw new UnsupportedOperationException(); } public Iterator linesContaining(int index1, int index2) { throw new UnsupportedOperationException(); } public Iterator linesMatching(Pattern p) { throw new UnsupportedOperationException(); } public int size() { return 1; } public String toString() { return line; } } PK w:djZZ.raykernel/apps/readability/code/Function.class1=(raykernel/apps/readability/code/Function2raykernel/apps/readability/code/TrainableCodeBlock classnameLjava/lang/String; methodname()VCode   java/util/LinkedList   codeLinesLjava/util/LinkedList;LineNumberTableLocalVariableTablethis*Lraykernel/apps/readability/code/Function;(Ljava/lang/String;)V java/lang/String  split'(Ljava/lang/String;)[Ljava/lang/String;"(raykernel/apps/readability/code/CodeLine !$  & '(add(Ljava/lang/Object;)Zbodyline9(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V -  /  appendLine-(Lraykernel/apps/readability/code/CodeLine;)Vl*Lraykernel/apps/readability/code/CodeLine; getClassName()Ljava/lang/String; getMethodNameisEmpty()Z : 78 SourceFile Function.java!  B* * Y     ?* * Y+Y:6>2M*!Y,#%W%5> ??)%*+ N* *+,*,.* Y-Y:662:*!Y#%W"  "2$C"M&4NNNN)2*01 B *+%W * +  2345 /*,/ 65 /*.4 78 2*99 ;-raykernel/apps/readability/code/Function.javapackage raykernel.apps.readability.code; import java.util.LinkedList; public class Function extends TrainableCodeBlock { String classname, methodname; public Function() { codeLines = new LinkedList(); } public Function(String body) { codeLines = new LinkedList(); for (String line : body.split("\n")) { codeLines.add(new CodeLine(line)); } //io.Out.println("----new function-----\n" + this + "---------"); } public Function(String classname, String methodname, String body) { this.classname = classname; this.methodname = methodname; codeLines = new LinkedList(); for (String line : body.split("\n")) { codeLines.add(new CodeLine(line)); } } public void appendLine(CodeLine l) { this.codeLines.add(l); } public String getClassName() { return classname; } public String getMethodName() { return methodname; } public boolean isEmpty() { return codeLines.isEmpty(); } } PK w:Q\uu.raykernel/apps/readability/code/CodeFile.class1(raykernel/apps/readability/code/CodeFile2raykernel/apps/readability/code/TrainableCodeBlock classFilesLjava/util/Vector; Signature"Ljava/util/Vector;fileLjava/io/File;hasBugZloaded newVersion(Ljava/io/File;)VCode  ()Vjava/util/Vector        ! # $loadLineNumberTableLocalVariableTablethis*Lraykernel/apps/readability/code/CodeFile;fattachClassFile ,.- java/io/File /0exists()Z 2 34add(Ljava/lang/Object;)ZcfattachNewVersionnfextractFunction.(II)Lraykernel/apps/readability/code/Function;;(raykernel/apps/readability/code/Function : > ?@listContaining(II)Ljava/util/LinkedList; BDCjava/util/LinkedList EFiterator()Ljava/util/Iterator; HJIjava/util/Iterator KLnext()Ljava/lang/Object;N(raykernel/apps/readability/code/CodeLine :P QR appendLine-(Lraykernel/apps/readability/code/CodeLine;)V HT U0hasNextstartIendfun*Lraykernel/apps/readability/code/Function;l*Lraykernel/apps/readability/code/CodeLine; getClassFiles&()Ljava/util/Iterator; DgetFile()Ljava/io/File; getNewVersion hasClassFile e f0isEmpty hasNewVersion B j kl codeLinesLjava/util/LinkedList;njava/io/BufferedReaderpjava/io/FileReader or  mt u(Ljava/io/Reader;)V mw xyreadLine()Ljava/lang/String; M{ |(Ljava/lang/String;)V B2 m 0ready m close java/lang/System errLjava/io/PrintStream;java/lang/StringBuilderCould not load file: { , ygetAbsolutePath append-(Ljava/lang/String;)Ljava/lang/StringBuilder; ytoString java/io/PrintStream |printlnjava/io/IOExceptionreaderLjava/io/BufferedReader;lineeLjava/io/IOException; printReport *** File , ygetName *** raykernel/io/Out (Ljava/lang/Object;)V  E()Ljava/util/ListIterator; out java/lang/String valueOf(I)Ljava/lang/String;.) |print M FfeatureIteratorraykernel/ml/feature/Feature[ -(Ljava/lang/Object;)Ljava/lang/StringBuilder;] iterLjava/util/Iterator;iiter2Lraykernel/ml/feature/Feature;LocalVariableTypeTable@Ljava/util/Iterator;4Ljava/util/Iterator;setBug(Z)Vbunload gcwriteAnnotatedFile%(Ljava/io/File;Z[Ljava/lang/String;)Vjava/io/BufferedWriterjava/io/FileWriter r (Ljava/io/Writer;)V Djava/lang/StringBuffer  M  getFeature2(Ljava/lang/String;)Lraykernel/ml/feature/Feature;  featureAnnotation2(Lraykernel/ml/feature/Feature;)Ljava/lang/String; ,(Ljava/lang/String;)Ljava/lang/StringBuffer; &(Ljava/lang/Object;)Ljava/lang/String;  |write  flushunable to write file!java/lang/Exceptionoutfilebugsfeatures[Ljava/lang/String;brLjava/io/BufferedWriter;Ljava/lang/StringBuffer;Ljava/lang/String;Ljava/lang/Exception; SourceFile CodeFile.java!  x(**Y****+ *"%","$%.#0'2&('(() *M++ *+1W%68;&'(5 6I ++*+%?A C& '( 7 894:YELMijo&4p'(&&j5 \MGY* *L=h+GMNY-:+G:YȷͶS-+S%>#%(2KQT`|&>'(#t%rW2[[\Q<`)#tQ<>*% &'( T**i*۱% & '(` YY+:*:~GM:Y:-Y: 6 6   2:W   YʶWYS~:%6 &/CS]t&\ '(     &o[\/fC) PK ;v:??-raykernel/apps/readability/code/CodeFile.javapackage raykernel.apps.readability.code; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.Iterator; import java.util.LinkedList; import java.util.Vector; import raykernel.ml.feature.Feature; /** * Essentially a wrapper around a text file with methods to allow each line to * be treated as a CodeLine. * * Includes some data structures to make access fast. * * Also, keeps a record of associated .class files. This is probably not a great * design but its convienient for now, in the future this class should be * specific to java files - it would be better to use a subclass for that, or to * put that code in the FinBugsDetector class (this is the best solution). * */ public class CodeFile extends TrainableCodeBlock { Vector classFiles = new Vector(); //associated class files //the file associated with this clode block File file; //java src file boolean hasBug = false; boolean loaded = false; File newVersion = null; /** * Create from a file * * @param f */ public CodeFile(File f) { file = f; load(); } public void attachClassFile(File cf) { if (cf.exists()) { classFiles.add(cf); //io.Out.println( "added class file: " + cf.getName() ); } } public void attachNewVersion(File nf) { if (nf.exists()) { newVersion = nf; } } public Function extractFunction(int start, int end) { Function fun = new Function(); for (CodeLine l : listContaining(start, end)) { fun.appendLine(l); } return fun; } public Iterator getClassFiles() { return classFiles.iterator(); } /** * Get the underlying file object * */ public File getFile() { return file; } public File getNewVersion() { return newVersion; } public boolean hasBug() { return hasBug; } public boolean hasClassFile() { return !classFiles.isEmpty(); } public boolean hasNewVersion() { return newVersion != null; } public void load() { if (loaded) return; BufferedReader reader; codeLines = new LinkedList(); try { reader = new BufferedReader(new FileReader(file)); while (reader.ready()) { CodeLine line = new CodeLine(reader.readLine()); codeLines.add(line); } reader.close(); } catch (IOException e) { System.err.println("Could not load file: " + file.getAbsolutePath()); return; } loaded = true; } public void printReport() { raykernel.io.Out.println(" *** File " + file.getName() + " ***\n"); Iterator iter = iterator(); int i = 0; while (iter.hasNext()) { CodeLine l = iter.next(); System.out.print(i + ".) "); Iterator iter2 = l.featureIterator(); while (iter2.hasNext()) { Feature f = iter2.next();; System.out.print("[" + f + "] "); } raykernel.io.Out.println(l); i++; } } public void setBug(boolean b) { hasBug = b; } public void unload() { if (!loaded) return; this.codeLines = null; loaded = false; System.gc(); } public void writeAnnotatedFile(File outfile, boolean bugs, String... features) { try { BufferedWriter br = new BufferedWriter(new FileWriter(outfile)); for (CodeLine l : this) { StringBuffer line = new StringBuffer(); for (String f : features) { line.append(featureAnnotation(l.getFeature(f))); } line.append(" " + l); br.write(line.toString() + "\n"); br.flush(); } } catch (Exception e) { System.err.println("unable to write file!"); } } } PK w: 7raykernel/apps/readability/code/CodeLineProcessor.class11raykernel/apps/readability/code/CodeLineProcessorjava/lang/ObjectkeyWordsLjava/util/HashSet; Signature'Ljava/util/HashSet;KEYWORDS[Ljava/lang/String;()VCodejava/lang/Stringabstractassertbooleanbreakbytecasecatchchar!class#const%continue'default)do+double-else/enum1extends3false5final7finally9float;for=goto?ifA implementsCimportE instanceofGintI interfaceKlongMnativeOnewQnullSpackageUprivateW protectedYpublic[return]short_staticastrictfpcsupereswitchg synchronizedithiskthrowmthrowso transientqtruestryuvoidwvolatileywhile { LineNumberTableLocalVariableTable  ~ 3Lraykernel/apps/readability/code/CodeLineProcessor;getWords<(Lraykernel/apps/readability/code/CodeLine;)Ljava/util/List;P(Lraykernel/apps/readability/code/CodeLine;)Ljava/util/List; (raykernel/apps/readability/code/CodeLine toString()Ljava/lang/String;[\p{Punct}\p{Blank}]  split'(Ljava/lang/String;)[Ljava/lang/String;java/util/LinkedList  length()I java/util/List add(Ljava/lang/Object;)Zl*Lraykernel/apps/readability/code/CodeLine;wordsretLjava/util/List;wordLjava/lang/String;LocalVariableTypeTable$Ljava/util/List;init  java/util/HashSet k isKeyWord(Ljava/lang/String;)Z  containssisNumber java/lang/Integer parseInt(Ljava/lang/String;)Ijava/lang/NumberFormatExceptione!Ljava/lang/NumberFormatException; SourceFileCodeLineProcessor.java!   }A5YSYSYSYSYSYSYSYSY SY "SY $SY &SY (SY *SY,SY.SY0SY2SY4SY6SY8SY:SYSY@SYBSYDSYFSYHSYJSYLSYNSY PSY!RSY"TSY#VSY$XSY%ZSY&\SY'^SY(`SY)bSY*dSY+fSY,hSY-jSY.lSY/nSY0pSY1rSY2tSY3vSY4xSz|" , n.= @}~  /*|} i  D*LYM+Y:662N- ,-W,|" %-0 8B#}*D : 2% 2  t2YzYN=<-2K*W|()+-!/)-11} !  9 *| 56}   U *WL|=? A C} PK lt:Ea6raykernel/apps/readability/code/CodeLineProcessor.javapackage raykernel.apps.readability.code; import java.util.HashSet; import java.util.LinkedList; import java.util.List; public class CodeLineProcessor { static HashSet keyWords; private static final String[] KEYWORDS = {"abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "default", "do", "double", "else", "enum", "extends", "false", "final", "finally", "float", "for", "goto", "if", "implements", "import", "instanceof", "int", "interface", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "strictfp", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "void", "volatile", "while"}; public static List getWords(CodeLine l) { String[] words = l.toString().split("[\\p{Punct}\\p{Blank}]"); List ret = new LinkedList(); for (String word : words) { if (word.length() < 1) { continue; } ret.add(word); } return ret; } public static void init() { if (keyWords != null) return; keyWords = new HashSet(); for (String k : KEYWORDS) { keyWords.add(k); } } public static boolean isKeyWord(String s) { init(); return keyWords.contains(s); } public static boolean isNumber(String s) { try { Integer.parseInt(s); } catch (NumberFormatException e) { return false; } return true; } } PK w:2}}6raykernel/apps/readability/code/CodeBlockAdapter.class10raykernel/apps/readability/code/CodeBlockAdapterjava/lang/Object)raykernel/apps/readability/code/CodeBlock codeLinesLjava/util/LinkedList; SignatureBLjava/util/LinkedList;()VCode  java/util/LinkedList   LineNumberTableLocalVariableTablethis2Lraykernel/apps/readability/code/CodeBlockAdapter;featureAnnotation2(Lraykernel/ml/feature/Feature;)Ljava/lang/String; raykernel/ml/feature/Feature  name()Ljava/lang/String; " #$value()F & ''(Ljava/lang/String;F)Ljava/lang/String;fLraykernel/ml/feature/Feature;+java/lang/StringBuilder-[ */ 0(Ljava/lang/String;)V *2 34append-(Ljava/lang/String;)Ljava/lang/StringBuilder;6, *8 39(F)Ljava/lang/StringBuilder;;] *= > toStringLjava/lang/String;FgetLine-(I)Lraykernel/apps/readability/code/CodeLine; D EFget(I)Ljava/lang/Object;H(raykernel/apps/readability/code/CodeLinenumIgetLines(II)Ljava/util/Iterator;D(II)Ljava/util/Iterator; O PQsize()I S TUiterator()Ljava/util/Iterator; W XYsubList(II)Ljava/util/List; [S\java/util/Liststartend()Ljava/util/ListIterator;F()Ljava/util/ListIterator; b c_ listIteratorlineContaining fhgjava/util/Iterator ijnext()Ljava/lang/Object; Gl mQlength fo pqhasNext()Zindextotall*Lraykernel/apps/readability/code/CodeLine;linesContaining x yzlistContaining(II)Ljava/util/LinkedList;index1index2 linesMatching/(Ljava/util/regex/Pattern;)Ljava/util/Iterator;[(Ljava/util/regex/Pattern;)Ljava/util/Iterator; = java/util/regex/Pattern matcher3(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher; java/util/regex/Matcher ]Q ^Q  addAll(Ljava/util/Collection;)Z qfindpLjava/util/regex/Pattern;Ljava/util/regex/Matcher; matchingLinesLocalVariableTypeTableF(II)Ljava/util/LinkedList;"java/lang/IllegalArgumentExceptionIndex one must be <= index2! /  dB'Indexes appear to be out of range. 1: * 3(I)Ljava/lang/StringBuilder;, 2:  indexOf(Ljava/lang/Object;)I  c(I)Ljava/util/ListIterator;  add(Ljava/lang/Object;)ZfirstlastlineNumiterLjava/util/Iterator;buffer@Ljava/util/Iterator;java/lang/StringBuffer  S G= java/lang/String valueOf&(Ljava/lang/Object;)Ljava/lang/String; 3,(Ljava/lang/String;)Ljava/lang/StringBuffer; =strLjava/lang/StringBuffer;  T_ SourceFileCodeBlockAdapter.java!    B**Y     6 **!%  () ' S*Y,.*151#7:1<?#@AB @ *CG  IJKL M Y<=*Nd *Nd<*Nd *Nd=YR*VZ. "$' ) ,.#103:6?7J9 YY]JY^JT_ ` 2*a> dB 5=*R:eGN--k``=nCDFG I)D3L*55rJ3sJtuvL M H *wRY   {J |J}~  4+*MYN-*,,wW,-R_ ace(c/h*44 (   yz  K  Y*N*:-$Y*Y.1<*-6*f:Y:eG:W6 mnpqs%tFvPw^xg|s}{\ {J|JpuiuP5J^'gsiu^'g PQ 2*N >  CYL*N(-eGM+*Y,.Ŷ1<W-n+ʰ5> C;tuATU %*ͰPK ;v:1g g 5raykernel/apps/readability/code/CodeBlockAdapter.javapackage raykernel.apps.readability.code; import java.util.Iterator; import java.util.LinkedList; import java.util.ListIterator; import java.util.regex.Matcher; import java.util.regex.Pattern; import raykernel.ml.feature.Feature; public abstract class CodeBlockAdapter implements CodeBlock { public static String featureAnnotation(Feature f) { return featureAnnotation(f.name(), f.value()); } public static String featureAnnotation(String name, float value) { return "[" + name + ", " + value + "]"; } // content as list of lines protected LinkedList codeLines = new LinkedList(); public CodeLine getLine(int num) { return codeLines.get(num); } public Iterator getLines(int start, int end) { if (start < 0) { start = 0; } if (end < 0) { end = 0; } if (start > codeLines.size() - 1) { start = codeLines.size() - 1; } if (end > codeLines.size() - 1) { end = codeLines.size() - 1; } if (end <= start) return (new LinkedList()).iterator(); return codeLines.subList(start, end).iterator(); } public ListIterator iterator() { return codeLines.listIterator(); } public CodeLine lineContaining(int index) { int total = 0; for (CodeLine l : this.codeLines) { if (total > index) //just passed it return l; total += l.length() + 1; } return null; } /** * Return an iterator over all the lines that overlap the set of chars * between index1 and index2 inclusive. * * @param index1 * @param index2 * @return */ public Iterator linesContaining(int index1, int index2) { return listContaining(index1, index2).iterator(); } public Iterator linesMatching(Pattern p) { Matcher matcher = p.matcher(this.codeLines.toString()); LinkedList matchingLines = new LinkedList(); while (matcher.find()) { matchingLines.addAll(listContaining(matcher.start(), matcher.end())); } return matchingLines.iterator(); } protected LinkedList listContaining(int index1, int index2) { if (index1 > index2) throw new IllegalArgumentException("Index one must be <= index2!"); CodeLine first = lineContaining(index1); CodeLine last = lineContaining(index2); if (first == null || last == null) throw new IllegalArgumentException("Indexes appear to be out of range. 1: " + index1 + ", 2: " + index2); int lineNum = codeLines.indexOf(first); //codelines could store their index to make this O(1) Iterator iter = codeLines.listIterator(lineNum); LinkedList buffer = new LinkedList(); while (true) { CodeLine next = iter.next(); buffer.add(next); if (next == last) { break; } } return buffer; } public int size() { return this.codeLines.size(); } public String toString() { StringBuffer str = new StringBuffer(); for (CodeLine l : this) { str.append(l.toString() + "\n"); } return str.toString(); } } PK w:m_9raykernel/apps/readability/code/FileExtensionFilter.class193raykernel/apps/readability/code/FileExtensionFilter"javax/swing/filechooser/FileFilterjava/io/FileFilterdescLjava/lang/String;exten(Ljava/lang/String;)VCode  ()V  java/lang/StringBuilder.   append-(Ljava/lang/String;)Ljava/lang/StringBuilder;  toString()Ljava/lang/String; ! LineNumberTableLocalVariableTablethis5Lraykernel/apps/readability/code/FileExtensionFilter;'(Ljava/lang/String;Ljava/lang/String;)Vaccept(Ljava/io/File;)Z *,+ java/io/File -getName /10java/lang/String 23endsWith(Ljava/lang/String;)Zarg0Ljava/io/File;getDescription SourceFileFileExtensionFilter.java!   ^* *+*Y+ " #$%  & h* *+*Y, " # $% '( @ +)* ."!# $% 456 /*"&# $%78PK lt:P8raykernel/apps/readability/code/FileExtensionFilter.javapackage raykernel.apps.readability.code; import java.io.File; import java.io.FileFilter; /** * Merges differing file filter representations don't ask me why the java api * has 2 of them. * * @author buse * */ public class FileExtensionFilter extends javax.swing.filechooser.FileFilter implements FileFilter { String desc; String exten; public FileExtensionFilter(String exten) { this.desc = exten; this.exten = "." + exten; } public FileExtensionFilter(String desc, String exten) { this.desc = desc; this.exten = "." + exten; } public boolean accept(File arg0) { return arg0.getName().endsWith(exten); } public String getDescription() { return desc; } } PK w:gVu8raykernel/apps/readability/code/TrainableCodeBlock.class1A2raykernel/apps/readability/code/TrainableCodeBlock0raykernel/apps/readability/code/CodeBlockAdapterraykernel/ml/feature/Trainabletrain$Lraykernel/ml/core/TrainableAdapter;()VCode  "raykernel/ml/core/TrainableAdapter   LineNumberTableLocalVariableTablethis4Lraykernel/apps/readability/code/TrainableCodeBlock;addFeatureName(Ljava/lang/String;)V   feature_nameLjava/lang/String;featureIterator()Ljava/util/Iterator; Signature6()Ljava/util/Iterator; " featureNamesIterator*()Ljava/util/Iterator; & #getClassAttribute()Lweka/core/Attribute; * '( getFeature2(Ljava/lang/String;)Lraykernel/ml/feature/Feature; . +, featurename getInstance;(Ljava/lang/String;[Ljava/lang/String;)Lweka/core/Instance; 3 01 class_featurefeatures[Ljava/lang/String;isEmpty()Z setFeature!(Lraykernel/ml/feature/Feature;)V < 9:fLraykernel/ml/feature/Feature; SourceFileTrainableCodeBlock.java!   B* *Y    A *+    2*! #$ 2*% '( 2*)! +, = *+-&  /01 H *+,2+   4 5678 ,0 9: A *+; 56  =>?@PK 4v:=(pp7raykernel/apps/readability/code/TrainableCodeBlock.javapackage raykernel.apps.readability.code; import java.util.Iterator; import raykernel.ml.core.TrainableAdapter; import raykernel.ml.feature.Feature; import raykernel.ml.feature.Trainable; import weka.core.Attribute; import weka.core.Instance; public abstract class TrainableCodeBlock extends CodeBlockAdapter implements Trainable { TrainableAdapter train = new TrainableAdapter(); public void addFeatureName(String feature_name) { train.addFeatureName(feature_name); } public Iterator featureIterator() { return train.featureIterator(); } public Iterator featureNamesIterator() { return train.featureNamesIterator(); } public Attribute getClassAttribute() { return train.getClassAttribute(); } public Feature getFeature(String featurename) { return train.getFeature(featurename); } public Instance getInstance(String class_feature, String[] features) { return train.getInstance(class_feature, features); } public boolean isEmpty() { return false; } public void setFeature(Feature f) { train.setFeature(f); } } PK w:FF/raykernel/apps/readability/code/CodeBlock.class1)raykernel/apps/readability/code/CodeBlockjava/lang/Objectjava/lang/IterablegetLine-(I)Lraykernel/apps/readability/code/CodeLine;getLines(II)Ljava/util/Iterator; SignatureD(II)Ljava/util/Iterator;iterator()Ljava/util/ListIterator;F()Ljava/util/ListIterator;lineContaininglinesContaining linesMatching/(Ljava/util/regex/Pattern;)Ljava/util/Iterator;[(Ljava/util/regex/Pattern;)Ljava/util/Iterator;size()I SourceFileCodeBlock.javaRLjava/lang/Object;Ljava/lang/Iterable;          PK lt:.raykernel/apps/readability/code/CodeBlock.javapackage raykernel.apps.readability.code; import java.util.Iterator; import java.util.ListIterator; import java.util.regex.Pattern; public interface CodeBlock extends Iterable { public CodeLine getLine(int num); public Iterator getLines(int start, int end); public ListIterator iterator(); public CodeLine lineContaining(int index); public Iterator linesContaining(int index1, int index2); public Iterator linesMatching(Pattern p); public int size(); } PK w: -raykernel/common/code/FunctionExtractor.class1'raykernel/common/code/FunctionExtractor#org/eclipse/jdt/core/dom/ASTVisitorparser$Lorg/eclipse/jdt/core/dom/ASTParser; currentFileLjava/lang/String; extractedLjava/util/LinkedList; Signature;()VCode "org/eclipse/jdt/core/dom/ASTParser  newParser'(I)Lorg/eclipse/jdt/core/dom/ASTParser;  LineNumberTableLocalVariableTableextractFunctions (Ljava/io/File;)Ljava/util/List;F(Ljava/io/File;)Ljava/util/List;   ! " getFunctionsfileLjava/io/File;fe)Lraykernel/common/code/FunctionExtractor; this*java/util/LinkedList ) - / 01 getString"(Ljava/io/File;)Ljava/lang/String; 3  576java/lang/String 89 toCharArray()[C ; <= setSource([C)V ? @A createASTO(Lorg/eclipse/core/runtime/IProgressMonitor;)Lorg/eclipse/jdt/core/dom/ASTNode;C(org/eclipse/jdt/core/dom/CompilationUnit BE FGaccept((Lorg/eclipse/jdt/core/dom/ASTVisitor;)VIjava/lang/Exceptionast*Lorg/eclipse/jdt/core/dom/CompilationUnit;Mjava/lang/StringBuffer LPjava/io/BufferedReaderRjava/io/FileReader QT U(Ljava/io/File;)V OW X(Ljava/io/Reader;)VZjava/lang/StringBuilder O\ ]^readLine()Ljava/lang/String; 5` abvalueOf&(Ljava/lang/Object;)Ljava/lang/String; Yd e(Ljava/lang/String;)Vg Yi jkappend-(Ljava/lang/String;)Ljava/lang/StringBuilder; Ym n^toString Lp jq,(Ljava/lang/String;)Ljava/lang/StringBuffer; Os tuready()Z Ow xclose z|{java/lang/System }~errLjava/io/PrintStream;Could not load file:  java/io/File ^getAbsolutePath java/io/PrintStream eprintln Lmjava/io/IOExceptionreaderLjava/io/BufferedReader;contentLjava/lang/StringBuffer;eLjava/io/IOException;visit/(Lorg/eclipse/jdt/core/dom/MethodDeclaration;)Z"raykernel/apps/docinf/code/JMethod A(Lorg/eclipse/jdt/core/dom/MethodDeclaration;Ljava/lang/String;)V ) add(Ljava/lang/Object;)Z got method: Y j-(Ljava/lang/Object;)Ljava/lang/StringBuilder; raykernel/io/Out (Ljava/lang/Object;)Vmeth,Lorg/eclipse/jdt/core/dom/MethodDeclaration;newj$Lraykernel/apps/docinf/code/JMethod; SourceFileFunctionExtractor.java!     ,   FYL+*   !#$%&3*' (* (&" :*)Y+,**+.2*24:>BM,*DM*,!14H/ 13!7,84:5? :(&:#$,JK01dLYNNOYQY+SVM-YY,[_cfhloW,r,v:yYYc+hl-AD& EIKM6K=PDRFT_W4d(&d#$,\Fu+Y+*2M*,,WYYc,l\ ^`)b +(&+ PK ;v:,raykernel/common/code/FunctionExtractor.javapackage raykernel.common.code; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.LinkedList; import java.util.List; import org.eclipse.jdt.core.dom.AST; import org.eclipse.jdt.core.dom.ASTParser; import org.eclipse.jdt.core.dom.ASTVisitor; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.MethodDeclaration; import raykernel.apps.docinf.code.JMethod; /** * Gets ExtractedFunctions from an input java file * * @author buse * */ public class FunctionExtractor extends ASTVisitor { private static ASTParser parser = ASTParser.newParser(AST.JLS3); public static List extractFunctions(File file) { FunctionExtractor fe = new FunctionExtractor(); return fe.getFunctions(file); } String currentFile; LinkedList extracted; private FunctionExtractor() { } private List getFunctions(File file) { extracted = new LinkedList(); currentFile = getString(file); parser.setSource(currentFile.toCharArray()); try { CompilationUnit ast = (CompilationUnit) parser.createAST(null); ast.accept(this); } catch (Exception e) { } return extracted; } private String getString(File file) { BufferedReader reader; StringBuffer content = new StringBuffer(); try { reader = new BufferedReader(new FileReader(file)); while (reader.ready()) { content.append(reader.readLine() + "\n"); } reader.close(); } catch (IOException e) { System.err.println("Could not load file: " + file.getAbsolutePath()); } return content.toString(); } public boolean visit(MethodDeclaration meth) { JMethod newj = new JMethod(meth, currentFile); extracted.add(newj); raykernel.io.Out.println("got method: " + newj); return false; } } PK w:'f7%%$raykernel/common/code/JDTUtils.class1raykernel/common/code/JDTUtilsjava/lang/Object()VCode  LineNumberTableLocalVariableTablethis Lraykernel/common/code/JDTUtils; SourceFile JDTUtils.java!/*   PK ;v:IyAA#raykernel/common/code/JDTUtils.javapackage raykernel.common.code; public class JDTUtils { } PK w:+т -raykernel/common/code/ExtractedFunction.class1'raykernel/common/code/ExtractedFunctionjava/lang/ObjectpackLjava/lang/String;type returntypenamebodyA(Lorg/eclipse/jdt/core/dom/MethodDeclaration;Ljava/lang/String;)VCode  ()V *org/eclipse/jdt/core/dom/MethodDeclaration getStartPosition()I java/lang/String charAt(I)C    getParent$()Lorg/eclipse/jdt/core/dom/ASTNode;" anonymous $ & nopackage ( *(org/eclipse/jdt/core/dom/TypeDeclaration ), -.getName'()Lorg/eclipse/jdt/core/dom/SimpleName; 021#org/eclipse/jdt/core/dom/SimpleName 34toString()Ljava/lang/String; )7(org/eclipse/jdt/core/dom/CompilationUnit 69 :; getPackage/()Lorg/eclipse/jdt/core/dom/PackageDeclaration; =?>+org/eclipse/jdt/core/dom/PackageDeclaration -@!()Lorg/eclipse/jdt/core/dom/Name; B2Corg/eclipse/jdt/core/dom/Name E FGgetReturnType2!()Lorg/eclipse/jdt/core/dom/Type; I2Jorg/eclipse/jdt/core/dom/Type L  N O getLength Q RS substring(II)Ljava/lang/String; U  W XY parameters()Ljava/util/List;[java/lang/StringBuffer Z ^`_java/util/List abiterator()Ljava/util/Iterator; dfejava/util/Iterator ghnext()Ljava/lang/Object;j2org/eclipse/jdt/core/dom/SingleVariableDeclarationljava/lang/StringBuilder in oGgetType q rs makeSimple&(Ljava/lang/String;)Ljava/lang/String; u vwvalueOf&(Ljava/lang/Object;)Ljava/lang/String; ky z(Ljava/lang/String;)V|, k~ append-(Ljava/lang/String;)Ljava/lang/StringBuilder; k2 Z ,(Ljava/lang/String;)Ljava/lang/StringBuffer; d hasNext()Z   isConstructor   ,LineNumberTableLocalVariableTablethis)Lraykernel/common/code/ExtractedFunction;meth,Lorg/eclipse/jdt/core/dom/MethodDeclaration; currentFilestartIparent"Lorg/eclipse/jdt/core/dom/ASTNode;typedec*Lorg/eclipse/jdt/core/dom/TypeDeclaration;n*Lorg/eclipse/jdt/core/dom/CompilationUnit;paramsLjava/util/List; paramStringLjava/lang/StringBuffer;svd4Lorg/eclipse/jdt/core/dom/SingleVariableDeclaration;LocalVariableTypeTableFLjava/util/List;](Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)VgetBodygetSimpleSignature.:   lastIndexOf(I)I  R(I)Ljava/lang/String; SourceFileExtractedFunction.java!     *+>,d ,d +:*!#*%')/):*+/#56:*8<A'*+DHK*,++M`PT+V:ZY\:]:3ci:kY*mHptx{}W+ **+/b !$'%-&3'9)A+H-T.^/m3x69:;=;@BFHf  -H%^kb$ k   **+'*,#*-K**TJL MNOPQ>     4 /*TU 4 T*kY*'tx}*#}}*}Z *rs A ++.`_ PK Tv:׬Kyy,raykernel/common/code/ExtractedFunction.javapackage raykernel.common.code; import java.util.List; import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.MethodDeclaration; import org.eclipse.jdt.core.dom.SingleVariableDeclaration; import org.eclipse.jdt.core.dom.TypeDeclaration; /** * A function that lives on its own but still remembers where it came from * * @author buse * */ public class ExtractedFunction { String pack, type, returntype, name, body; public ExtractedFunction(MethodDeclaration meth, String currentFile) { int start = meth.getStartPosition(); while (true) { if (currentFile.charAt(start - 1) == ' ' || currentFile.charAt(start - 1) == '\t') { start--; } else { break; } } //type ASTNode parent = meth.getParent(); type = "anonymous"; pack = "nopackage"; if (parent instanceof TypeDeclaration) { TypeDeclaration typedec = (TypeDeclaration) parent; type = typedec.getName().toString(); CompilationUnit n = (CompilationUnit) typedec.getParent(); pack = n.getPackage().getName().toString(); } //return type returntype = meth.getReturnType2().toString(); //body body = currentFile.substring(start, meth.getStartPosition() + meth.getLength()); //param string List params = meth.parameters(); StringBuffer paramString = new StringBuffer(); for (SingleVariableDeclaration svd : params) { paramString.append(makeSimple(svd.getType().toString()) + ","); } if (meth.isConstructor()) { name = ""; } else { name = meth.getName().toString(); } } public ExtractedFunction(String pack, String type, String returntype, String name, String body) { this.pack = pack; this.type = type; this.returntype = returntype; this.name = name; this.body = body; } public String getBody() { return body; } public String getSimpleSignature() { return pack + "." + type + ":" + name; } String makeSimple(String name) { return name.substring(name.lastIndexOf('.') + 1); } } PK w:Մ99!raykernel/stats/KendallsTau.class1raykernel/stats/KendallsTaujava/lang/Object()VCode  LineNumberTableLocalVariableTablethisLraykernel/stats/KendallsTau;computeDistance#(Ljava/util/List;Ljava/util/List;)Draykernel/stats/Ranking  (Ljava/util/List;)V  5(Lraykernel/stats/Ranking;Lraykernel/stats/Ranking;)Dl1Ljava/util/List;l2$(Ljava/util/List;Ljava/util/List;I)D java/util/List !size()I # $6(Lraykernel/stats/Ranking;Lraykernel/stats/Ranking;I)DnumBinsI r1Lraykernel/stats/Ranking;r2 , -. makeBinMap(II)[I 0 12iterator()Ljava/util/Iterator; 465java/util/Iterator 78next()Ljava/lang/Object; : ;<getRank(Ljava/lang/Object;)I 4> ?@hasNext()Z@countmap[IxLjava/lang/Object;ydif1dif2nDmain([Ljava/lang/String;)V P QRmakeList([I)Ljava/util/List;Tjava/lang/StringBuilderVdist = SX Y(Ljava/lang/String;)V S[ \]append(D)Ljava/lang/StringBuilder; S_ `atoString()Ljava/lang/String; cedraykernel/io/Out fgprintln(Ljava/lang/Object;)V i jk printBinMap([I)Vargs[Ljava/lang/String;hwheightweightLocalVariableTypeTable%Ljava/util/List;bretbinsizesbase remaindericcurrentbinel Signature)([I)Ljava/util/List;java/util/LinkedList java/lang/Integer valueOf(I)Ljava/lang/Integer; add(Ljava/lang/Object;)ZarraylistLjava/util/LinkedList;+Ljava/util/LinkedList; java/lang/System outLjava/io/PrintStream;{ java/io/PrintStream Yprint java/lang/String (I)Ljava/lang/String;, S \-(Ljava/lang/String;)Ljava/lang/StringBuilder;}arrelement SourceFileKendallsTau.java! /*   HY*Y+   l&* *=Y*Y+"   &&&%& > *+*'"   () *) $U >*'+:*/:g3:+/:K3:8*9.*9.d6 +9.+9.d6   h==*'9AogkAoo :"$ (*0,7.:1O2d4l7o*y(<> f ()*)%&C& DE[FG0?HGO I& d J& KL MNl YOYOYOYOYOL YOYOYOYOYOM+ON,O:SYUWY-Y"Z^b+h EF0H5I;KbMkN 4llmTnE0<oE57p;1qr57ps;1qs -.] {< M Nl6p66 -O6-\.`O`p666!6 ,O  -., ZRTW XZ[]_%].b1c4e<f?gGcLjOlUo[qdoplyu p {K&{t& puElvEgw&bx&y&1Jz&O,{&R'|&X}& QR~-YL*Y:6>.=+W+ z|~"|+ -E% y&r % jk?*Y:>=$.<SYW^b 19> ?E&PK t:łLN N raykernel/stats/KendallsTau.javapackage raykernel.stats; import java.util.LinkedList; import java.util.List; public class KendallsTau { public static double computeDistance(List l1, List l2) { return computeDistance(new Ranking(l1), new Ranking(l2)); } public static double computeDistance(List l1, List l2, int numBins) { if (numBins > l1.size()) { numBins = l1.size(); } //io.Out.println("list 1: " + l1 ); //io.Out.println("list 2: " + l2 ); //io.Out.println("bins: " + numBins ); return (computeDistance(new Ranking(l1), new Ranking(l2), numBins)); } public static double computeDistance(Ranking r1, Ranking r2) { return computeDistance(r1, r2, r1.size()); } public static double computeDistance(Ranking r1, Ranking r2, int numBins) { int count = 0; int[] map = makeBinMap(r1.size(), numBins); //printBinMap( map ); for (Object x : r1) { for (Object y : r2) //for every (unique) pair { if (x == y) { continue; } int dif1 = map[r1.getRank(x)] - map[r1.getRank(y)]; int dif2 = map[r2.getRank(x)] - map[r2.getRank(y)]; if (dif1 * dif2 < 0) { //io.Out.println("count"); count++; } } } double n = r1.size(); return (count / 2.0) / (n * (n - 1.0) / 2.0); } public static void main(String[] args) { //test int[] h = {1, 2, 3, 4, 5}; int[] w = {1, 3, 2, 4, 5}; List height = makeList(h); List weight = makeList(w); raykernel.io.Out.println("dist = " + KendallsTau.computeDistance(new Ranking(height), new Ranking(weight), 2)); printBinMap(makeBinMap(31, 2)); } private static int[] makeBinMap(int n, int b) { if (b > n) { b = n; } int[] ret = new int[n]; int[] binsizes = new int[b]; int base = n / b; int remainder = n % b; for (int i = 0; i < b; i++) { binsizes[i] = base; } int c = 0; while (remainder > 0) { binsizes[c]++; remainder--; c = (c + 1) % b; } int current = 0; //for each bin for (int bin = 0; bin < b; bin++) { //for each element for (int el = 0; el < binsizes[bin]; el++) { ret[current++] = bin; } } return ret; } public static List makeList(int[] array) { LinkedList list = new LinkedList(); for (int i : array) { list.add(i); } return list; } private static void printBinMap(int[] arr) { System.out.print("{ "); for (int element : arr) { System.out.print(element + ", "); } raykernel.io.Out.println("}"); } } PK w:$.raykernel/stats/Sorter$FeatureComparator.class10(raykernel/stats/Sorter$FeatureComparatorjava/lang/Objectjava/util/ComparatorfeatureLjava/lang/String;(Ljava/lang/String;)VCode  ()V  LineNumberTableLocalVariableTablethis*Lraykernel/stats/Sorter$FeatureComparator;compare'(Ljava/lang/Object;Ljava/lang/Object;)Iraykernel/ml/feature/Trainable   getFeature2(Ljava/lang/String;)Lraykernel/ml/feature/Feature;  raykernel/ml/feature/Feature !"value()FF@o1Ljava/lang/Object;o2t1 Lraykernel/ml/feature/Trainable;t2 SourceFile Sorter.java InnerClasses.raykernel/stats/SorterFeatureComparator   F * *+    /+N,:-*#j*#jf 4//$%/&%*'( $)(*+, -/PK w:~a5raykernel/stats/Sorter$ReverseFeatureComparator.class10/raykernel/stats/Sorter$ReverseFeatureComparatorjava/lang/Objectjava/util/ComparatorfeatureLjava/lang/String;(Ljava/lang/String;)VCode  ()V  LineNumberTableLocalVariableTablethis1Lraykernel/stats/Sorter$ReverseFeatureComparator;compare'(Ljava/lang/Object;Ljava/lang/Object;)Iraykernel/ml/feature/Trainable   getFeature2(Ljava/lang/String;)Lraykernel/ml/feature/Feature;  raykernel/ml/feature/Feature !"value()FF@o1Ljava/lang/Object;o2t1 Lraykernel/ml/feature/Trainable;t2 SourceFile Sorter.java InnerClasses.raykernel/stats/SorterReverseFeatureComparator   F * *+$& '   /+N,:*#j-*#jf+, .4//$%/&%*'( $)(*+, -/PK w:L()VCode  LineNumberTableLocalVariableTablethisLraykernel/stats/Sorter;sort(Ljava/util/List;)V Signature&(Ljava/util/List;)V java/util/Collections valuesLjava/util/List;LocalVariableTypeTable#Ljava/util/List; sortByFeature%(Ljava/util/List;Ljava/lang/String;)VH(Ljava/util/List<+Lraykernel/ml/feature/Trainable;>;Ljava/lang/String;)V(raykernel/stats/Sorter$FeatureComparator  !(Ljava/lang/String;)V # $)(Ljava/util/List;Ljava/util/Comparator;)VtoSortfeatureLjava/lang/String;3Ljava/util/List<+Lraykernel/ml/feature/Trainable;>;sortByFeatureReverse+/raykernel/stats/Sorter$ReverseFeatureComparator *  SourceFile Sorter.java InnerClassesFeatureComparatorReverseFeatureComparator!/*   E* 57   W *Y+" < =  % &'  %( )W **Y+," B C  % &'  %(-./0*1PK ;v:LCʽraykernel/stats/Sorter.javapackage raykernel.stats; import java.util.Collections; import java.util.Comparator; import java.util.List; import raykernel.ml.feature.Trainable; public class Sorter { static class FeatureComparator implements Comparator { String feature; FeatureComparator(String feature) { this.feature = feature; } public int compare(Object o1, Object o2) { Trainable t1 = (Trainable) o1; Trainable t2 = (Trainable) o2; return (int) ((t1.getFeature(feature).value() * 10000) - (t2.getFeature(feature).value() * 10000)); } } static class ReverseFeatureComparator implements Comparator { String feature; ReverseFeatureComparator(String feature) { this.feature = feature; } public int compare(Object o1, Object o2) { Trainable t1 = (Trainable) o1; Trainable t2 = (Trainable) o2; return (int) ((t2.getFeature(feature).value() * 10000) - (t1.getFeature(feature).value() * 10000)); } } public static void sort(List values) { Collections.sort(values); } @SuppressWarnings("unchecked") public static void sortByFeature(List toSort, String feature) { Collections.sort(toSort, new FeatureComparator(feature)); } @SuppressWarnings("unchecked") public static void sortByFeatureReverse(List toSort, String feature) { Collections.sort(toSort, new ReverseFeatureComparator(feature)); } } PK w:귟raykernel/stats/Ranking.class1Sraykernel/stats/Rankingjava/lang/Objectjava/lang/IterableobjectsLjava/util/List; SignatureLjava/util/List;rankMapLjava/util/HashMap;+Ljava/util/HashMap;(Ljava/util/List;)V(Ljava/util/List;)VCode  ()Vjava/util/HashMap     java/util/List !iterator()Ljava/util/Iterator; #%$java/util/Iterator &'next()Ljava/lang/Object; )+*java/lang/Integer ,-valueOf(I)Ljava/lang/Integer; / 01put8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; #3 45hasNext()ZLineNumberTableLocalVariableTablethisLraykernel/stats/Ranking;rankItLjava/lang/Object;LocalVariableTypeTableLraykernel/stats/Ranking;TT;getRank(Ljava/lang/Object;)I(TT;)I E FGget&(Ljava/lang/Object;)Ljava/lang/Object; )I JKintValue()I()Ljava/util/Iterator;size O MK SourceFile Ranking.javaALjava/lang/Object;Ljava/lang/Iterable;!     G**Y*+=+:"N*-(.W2ޱ6" ,<F7*G89G1:;,<=> G8?G ,<@AB C_*+D)H6789<=>8?<@ ! LF *6 7  89>  8?MKF *N6%7  89>  8?PQ RPK t:'fkZZraykernel/stats/Ranking.javapackage raykernel.stats; import java.util.HashMap; import java.util.Iterator; import java.util.List; public class Ranking implements Iterable { //sorter needed List objects; HashMap rankMap = new HashMap(); public Ranking(List objects) { this.objects = objects; int rank = 0; for (T t : objects) { rankMap.put(t, rank++); } } public int getRank(T t) { return rankMap.get(t); } public Iterator iterator() { return objects.iterator(); } public int size() { return objects.size(); } } PK w: & !raykernel/stats/Correlation.class1uraykernel/stats/Correlationjava/lang/Object()VCode  LineNumberTableLocalVariableTablethisLraykernel/stats/Correlation;getPearsonCorrelation([D[D)D java/lang/Double valueOf(D)Ljava/lang/Double;   doubleValue()D java/lang/Math sqrt(D)Dscores1[Dscores2resultDsum_sq_xsum_sq_y sum_coproductmean_xmean_yiIsweepdelta_xdelta_ypop_sd_xpop_sd_ycov_x_y'(Ljava/util/Vector;Ljava/util/Vector;)D SignatureO(Ljava/util/Vector;Ljava/util/Vector;)D 687java/util/Vector 9:get(I)Ljava/lang/Object; 6< =>size()ILjava/util/Vector;LocalVariableTypeTable&Ljava/util/Vector;main([Ljava/lang/String;)V@@@@@??333333?333333?ٙ?Yjava/lang/StringBuilder[corr = X] ^(Ljava/lang/String;)V `  Xb cdappend(D)Ljava/lang/StringBuilder; Xf ghtoString()Ljava/lang/String; jlkraykernel/io/Out mnprintln(Ljava/lang/Object;)Vargs[Ljava/lang/String;v1v2 SourceFileCorrelation.java!/*   I999*19 +19 6jdo9*d1 g9+d1 g9kkc9kkc9kkc9 oc9  oc9 *`*o9*o9*o9koI( V    ,7BO\it  !"!#$%$&$ '$($ )$ s*+,S,$7H-$B=.$/$0$ 1$ 234I999*59 +59 6zdo9*d5 g9+d5 g9kkc9kkc9kkc9 oc9  oc9 *;`*;o9*;o9*;o9koI( V#$%& '(%)++<,O-b.o/|012)45678  ?"?#$%$&$ '$($ %)$ (*+<c,$OP-$b=.$"/$0$ 1$@ A"A BCfYRYDRYFRYHRYJRYLRLYRYNRYPRYRRYTRYVRMXYZ\+,_aei ='>N@eA fop'?q!Nr!stPK Tv:0644 raykernel/stats/Correlation.javapackage raykernel.stats; import java.util.Vector; public class Correlation { public static double getPearsonCorrelation(double[] scores1, double[] scores2) { double result = 0; double sum_sq_x = 0; double sum_sq_y = 0; double sum_coproduct = 0; double mean_x = scores1[0]; double mean_y = scores2[0]; for (int i = 2; i < scores1.length + 1; i += 1) { double sweep = Double.valueOf(i - 1) / i; double delta_x = scores1[i - 1] - mean_x; double delta_y = scores2[i - 1] - mean_y; sum_sq_x += delta_x * delta_x * sweep; sum_sq_y += delta_y * delta_y * sweep; sum_coproduct += delta_x * delta_y * sweep; mean_x += delta_x / i; mean_y += delta_y / i; } double pop_sd_x = (double) Math.sqrt(sum_sq_x / scores1.length); double pop_sd_y = (double) Math.sqrt(sum_sq_y / scores1.length); double cov_x_y = sum_coproduct / scores1.length; result = cov_x_y / (pop_sd_x * pop_sd_y); return result; } public static double getPearsonCorrelation(Vector scores1, Vector scores2) { double result = 0; double sum_sq_x = 0; double sum_sq_y = 0; double sum_coproduct = 0; double mean_x = scores1.get(0); double mean_y = scores2.get(0); for (int i = 2; i < scores1.size() + 1; i += 1) { double sweep = Double.valueOf(i - 1) / i; double delta_x = scores1.get(i - 1) - mean_x; double delta_y = scores2.get(i - 1) - mean_y; sum_sq_x += delta_x * delta_x * sweep; sum_sq_y += delta_y * delta_y * sweep; sum_coproduct += delta_x * delta_y * sweep; mean_x += delta_x / i; mean_y += delta_y / i; } double pop_sd_x = (double) Math.sqrt(sum_sq_x / scores1.size()); double pop_sd_y = (double) Math.sqrt(sum_sq_y / scores1.size()); double cov_x_y = sum_coproduct / scores1.size(); result = cov_x_y / (pop_sd_x * pop_sd_y); return result; } public static void main(String[] args) { double[] v1 = {1, 2, 3, 4, 5, 6}; double[] v2 = {0, .1, .15, .3, .4, .45}; raykernel.io.Out.println("corr = " + getPearsonCorrelation(v1, v2)); } } PK : 9raykernel/apps/readability/applet/PortableEvaluator.class13raykernel/apps/readability/applet/PortableEvaluatorjava/lang/Object classifierLweka/classifiers/Classifier;cutoffFds$Lraykernel/ml/feature/DetectorSuite;evalLraykernel/ml/core/Evaluator;ssfd&Lraykernel/ml/feature/FeatureDetector;()VCode  #weka/classifiers/functions/Logistic   ?   =raykernel/apps/readability/detectors/ReadabilityDetectorSuite !getDefaultSuite&()Lraykernel/ml/feature/DetectorSuite; # %Eraykernel/apps/readability/applet/PortableSnippetScoreFeatureDetector $ (  * +, getSnippets\(Lraykernel/ml/feature/FeatureDetector;Lraykernel/ml/feature/DetectorSuite;)Ljava/util/List; . /0train(Ljava/util/Collection;)VLineNumberTableLocalVariableTablethis5Lraykernel/apps/readability/applet/PortableEvaluator;snippetsLjava/util/List;LocalVariableTypeTable>Ljava/util/List;getReadability7(Lraykernel/apps/readability/code/TrainableCodeBlock;)D <>="raykernel/ml/feature/DetectorSuite ?@runAll#(Lraykernel/ml/feature/Trainable;)V B DFEraykernel/ml/core/Evaluator G@ runDetector DI JK getScoreFor#(Lraykernel/ml/feature/Trainable;)Fblock4Lraykernel/apps/readability/code/TrainableCodeBlock; Signature(Lraykernel/ml/feature/FeatureDetector;Lraykernel/ml/feature/DetectorSuite;)Ljava/util/List; QSR.raykernel/apps/readability/applet/PortableData +T()Ljava/util/List; VXWjava/util/List YZiterator()Ljava/util/Iterator; \^]java/util/Iterator _`next()Ljava/lang/Object;b*raykernel/apps/readability/snippet/Snippet dFe$raykernel/ml/feature/FeatureDetector \g hihasNext()Zscore_detectords2s,Lraykernel/apps/readability/snippet/Snippet;G(Ljava/util/Collection;)Vpraykernel/ml/core/Trainer dr st featureNames()[Ljava/lang/String; <r ow x>(Ljava/util/Collection;Ljava/lang/String;[Ljava/lang/String;)V oz {|trainClassifier (Lweka/classifiers/Classifier;)V o~ getTrainingSet()Lweka/core/Instances; D Z(Lweka/classifiers/Classifier;Lweka/core/Instances;Ljava/lang/String;[Ljava/lang/String;)VLjava/util/Collection;tLraykernel/ml/core/Trainer;DLjava/util/Collection; SourceFilePortableEvaluator.java! :**Y**"*$Y&'**'*")L*+-1"'4!9"2:344567 4589:V*"+;*A+C*A+H1&'(234LM+,NO5PN-U:[a:,;+cf-1-/1!2)/35245345j5k 156lm7 158/0NnIoY+*'q2*"uvM,*y*DY*,}*'q2*"uA1:=#@HA2 I34I5.7 I5PK :bd0ll8raykernel/apps/readability/applet/PortableEvaluator.javapackage raykernel.apps.readability.applet; import java.util.Collection; import java.util.List; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.apps.readability.detectors.ReadabilityDetectorSuite; import raykernel.apps.readability.snippet.Snippet; import raykernel.ml.core.Evaluator; import raykernel.ml.core.Trainer; import raykernel.ml.feature.DetectorSuite; import raykernel.ml.feature.FeatureDetector; import weka.classifiers.Classifier; import weka.classifiers.functions.Logistic; public class PortableEvaluator { Classifier classifier = new Logistic(); float cutoff = (float) 0.5; DetectorSuite ds = ReadabilityDetectorSuite.getDefaultSuite(); Evaluator eval; FeatureDetector ssfd; public PortableEvaluator() { ssfd = new PortableSnippetScoreFeatureDetector(); List snippets = getSnippets(ssfd, ds); train(snippets); } public double getReadability(TrainableCodeBlock block) { ds.runAll(block); eval.runDetector(block); return eval.getScoreFor(block); } public List getSnippets(FeatureDetector score_detector, DetectorSuite ds2) { List snippets = PortableData.getSnippets(); for (Snippet s : snippets) { ds2.runAll(s); score_detector.runDetector(s); } return snippets; } void train(Collection snippets) { Trainer t = new Trainer(snippets, ssfd.featureNames()[0], ds.featureNames()); //train t.trainClassifier(classifier); //run evaluator eval = new Evaluator(classifier, t.getTrainingSet(), ssfd.featureNames()[0], ds.featureNames()); } } PK ~:Hxx4raykernel/apps/readability/applet/PortableData.class1.raykernel/apps/readability/applet/PortableDatajava/lang/Objectsnippets[Ljava/lang/String;scores[I()VCode java/lang/String Object ret = body.eval(callstack, interpreter); boolean breakout = false; if(ret instanceof ReturnControl) { switch(((ReturnControl)ret).kind ) { case RETURN: return ret; , if (actionList.size() == 1) { ActionMenu menu = actionList.get(0); if (menu.getSubItems().length == 0) { return null; } if (menu.getSubItems().length == 1) { Action action = menu.getSubItems()[0].getAction();  private String compactString(String source) { String result= DELTA_START + source.substring(fPrefix, source.length() - fSuffix + 1) + DELTA_END; if (fPrefix > 0) result= computeCommonPrefix() + result; if (fSuffix > 0) result= result + computeCommonSuffix();  /** * Constructor, with a argument reference to the PUBLIC User Object which * is null if this is the SYS or PUBLIC user. * * The dependency upon a GranteeManager is undesirable. Hopefully we * can get rid of this dependency with an IOC or Listener re-design. */ Grantee(String name, Grantee inGrantee, GranteeManager man) throws HsqlException { rightsMap = new IntValueHashMap(); granteeName = name; granteeManager = man;  /** * Quits the application without any questions. */ public void quit() { getConnectController().quitGame(true); if (!windowed) { gd.setFullScreenWindow(null); } System.exit(0); s xsp = jj_scanpos; if (jj_scan_token(100)) { jj_scanpos = xsp; if (jj_scan_token(101)) return true; ? /** * Attention: DO NOT USE THIS! * Under Os/2 it has some problems with calculating the real Date! * * @deprecated */ public Date(int daysSince1970) { long l = (long) daysSince1970 * 24 * 60 * 60 * 1000; java.util.Date d = new java.util.Date(l); Calendar cal = Calendar.getInstance();  public TestMethodRunner(Object test, Method method, RunNotifier notifier, Description description) { super(test.getClass(), Before.class, After.class, test); fTest= test; fMethod= method; ; /** * Returns a vector containing the URI (type + path) for all the databases. */ public static Vector getDatabaseURIs() { Vector v = new Vector(); Iterator it = databaseIDMap.values().iterator(); while (it.hasNext()) { Database db = (Database) it.next(); !e private void moveUnit(KeyEvent e) { if (!parent.isMapboardActionsEnabled()) { return; } switch (e.getKeyCode()) { case KeyEvent.VK_ESCAPE: // main menu break; case KeyEvent.VK_NUMPAD1: case KeyEvent.VK_END: inGameController.moveActiveUnit(Map.SW); # if ( clas == null ) throw new ClassNotFoundException( "Class: " + value+ " not found in namespace"); asClass = clas; return asClass; % btPanel.add(cancel); getRootPane().setDefaultButton(ok); panel.add(btPanel, BorderLayout.SOUTH); ' * @param expected expected value * @param actual actual value */ static public void assertEquals(String message, Object expected, Object actual) { if (expected == null && actual == null) return; if (expected != null && isEquals(expected, actual)) return; else if (expected instanceof String && actual instanceof String) { String cleanMessage= message == null ? "" : message; ) Object removeName(String name) throws HsqlException { Object owner = nameList.remove(name); if (owner == null) { // should contain name throw Trace.error(Trace.GENERAL_ERROR); } return owner; +H int stepSize = Math.min((option.getMaximumValue() - option.getMinimumValue()) / 10, 1000); spinner = new JSpinner(new SpinnerNumberModel(option.getValue(), option.getMinimumValue(), option.getMaximumValue(), Math.max(1, stepSize))); spinner.setToolTipText(option.getShortDescription()); - if ( parent != null ) setStrictJava( parent.getStrictJava() ); this.sourceFileInfo = sourceFileInfo; BshClassManager bcm = BshClassManager.createClassManager( this ); / mDevices = new Vector(); DeviceFileHandling reader = new DeviceFileHandling(); for (int i = 0; i < num; i++) { String classname = (String) in.readObject(); 1 /** * Do not use. Testing purposes only. */ public Result runMain(String... args) { System.out.println("JUnit version " + Version.id()); List> classes= new ArrayList>(); List missingClasses= new ArrayList(); 36 /** * temp constraint constructor */ Constraint(HsqlName name, int[] mainCols, Table refTable, int[] refCols, int type, int deleteAction, int updateAction) { core = new ConstraintCore(); constName = name; constType = type; 5 int eventId = active? ON : OFF; ActionEvent blinkEvent = new ActionEvent(this,eventId,"blink"); fireActionEvent(blinkEvent); 7f else if ( isPrimitive( returnType ) ) { int opcode = IRETURN; String type; String meth; 99 /** * Returns the PluginPanel * @return Panel */ public JPanel createSettingsPanel() { mPanel = new CapturePluginPanel(mOwner, mCloneData); mPanel.setBorder(Borders.createEmptyBorder(Sizes.DLUY5,Sizes.DLUX5,Sizes.DLUY5,Sizes.DLUX5)); mPanel.setSelectedTab(mCurrentPanel); ;+ protected void printFailures(Result result) { if (result.getFailureCount() == 0) return; if (result.getFailureCount() == 1) getWriter().println("There was " + result.getFailureCount() + " failure:"); else getWriter().println("There were " + result.getFailureCount() + " failures:"); = public static long getNormalisedTime(long t) { synchronized (tempCalDefault) { setTimeInMillis(tempCalDefault, t); resetToTime(tempCalDefault); return getTimeInMillis(tempCalDefault); ? public boolean check(Unit u, PathNode p) { if (p.getTile().getSettlement() != null && p.getTile().getSettlement().getOwner() == player && p.getTile().getSettlement() != inSettlement) { Settlement s = p.getTile().getSettlement(); int turns = p.getTurns(); destinations.add(new ChoiceItem(s.toString() + " (" + turns + ")", s)); AM if ((bufpos + 1) >= len) System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); else { System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len - bufpos - 1); System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); C/ /** * Compute the proper position for a centered window */ private Point comuteDisplayPointCentre(Dimension dim) { Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); int x = (screen.width - dim.width) / 2; int y = (screen.height - dim.height) / 2; E public void filter(Filter filter) throws NoTestsRemainException { for (Iterator iter= fRunners.iterator(); iter.hasNext();) { Runner runner= iter.next(); if (filter.shouldRun(runner.getDescription())) filter.apply(runner); else iter.remove(); G\ boolean hasReturnValue; outlen = parameters.length; offset = 0; I /** * Sets the currently chosen MapTransform. * @param mt The transform that should be applied to a * Tile that is clicked on the map. */ public void setMapTransform(MapTransform mt) { currentMapTransform = mt; MapControlsAction mca = (MapControlsAction) freeColClient.getActionManager().getFreeColAction(MapControlsAction.ID); if (mca.getMapControls() != null) { mca.getMapControls().update(mt); KY if (iterateOverMe instanceof String) return createEnumeration(((String)iterateOverMe).toCharArray()); if (iterateOverMe instanceof StringBuffer) return createEnumeration( iterateOverMe.toString().toCharArray()); throw new IllegalArgumentException( "Cannot enumerate object of type "+iterateOverMe.getClass()); M /** * Constructs a new Date object, initialized with the current date. */ public Date() { Calendar mCalendar = Calendar.getInstance(); mYear = mCalendar.get(Calendar.YEAR); mMonth = mCalendar.get(Calendar.MONTH) + 1; O /** * @param contextLength the maximum length for expected and actual. When contextLength * is exceeded, the Strings are shortened * @param expected the expected string value * @param actual the actual string value */ public ComparisonCompactor(int contextLength, String expected, String actual) { fContextLength= contextLength; fExpected= expected; fActual= actual; Q case CompiledStatement.DELETE : return executeDeleteStatement(cs); case CompiledStatement.CALL : return executeCallStatement(cs); case CompiledStatement.DDL : return executeDDLStatement(cs); SA /** * Creates a new DisbandUnitAction. * * @param freeColClient The main controller object for the client. */ DisbandUnitAction(FreeColClient freeColClient) { super(freeColClient, "unit.state.8", null, KeyStroke.getKeyStroke('D', 0)); putValue(BUTTON_IMAGE, freeColClient.getImageLibrary().getUnitButtonImageIcon(ImageLibrary.UNIT_BUTTON_DISBAND, 0)); putValue(BUTTON_ROLLOVER_IMAGE, freeColClient.getImageLibrary().getUnitButtonImageIcon( ImageLibrary.UNIT_BUTTON_DISBAND, 1)); U Class clas = object.getClass(); Field field = Reflect.resolveJavaField( clas, name, false/*onlyStatic*/ ); if ( field != null ) return new Variable( name, field.getType(), new LHS( object, field ) ); W for(AbstractPluginProgramFormating config : mConfigs) if(config != null && config.isValid()) list.add(new ProgramReceiveTarget(this, config.getName(), config.getId())); if(list.isEmpty()) list.add(new ProgramReceiveTarget(this, DEFAULT_CONFIG.getName(), DEFAULT_CONFIG.getId())); return list.toArray(new ProgramReceiveTarget[list.size()]); Y Class expectedException(Method method) { Test annotation= method.getAnnotation(Test.class); if (annotation.expected() == None.class) return null; else return annotation.expected(); [ row[1] = ns.getCatalogName(row[0]); row[2] = schema.equals(defschema) ? Boolean.TRUE : Boolean.FALSE; t.insertSys(row); ] /** * Handles an "deliverGift"-request. * * @param element The element (root element in a DOM-parsed XML tree) that * holds all the information. */ private Element deliverGift(Element element) { Element unitElement = Message.getChildElement(element, Unit.getXMLElementTagName()); Unit unit = (Unit) getGame().getFreeColGameObject(unitElement.getAttribute("ID")); unit.readFromXMLElement(unitElement); _ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case EQ: t = jj_consume_token(EQ); break; case NE: t = jj_consume_token(NE); a public synchronized void removeProgram(Program program) { PluginTreeNode node = findProgramTreeNode(program, false); if (node != null) { mChildNodes.remove(node); if (mMarker != null) { program.unmark(mMarker); c private TestClassRunnerForParameters(Class klass, Object[] parameters, int i) { super(klass); fParameters= parameters; fParameterSetNumber= i; e void link(IndexRowIterator other) { other.next = next; other.last = this; next.last = other; g final String heightText = Messages.message("height"); final JTextField inputWidth = new JTextField(Integer.toString(DEFAULT_WIDTH), COLUMNS); final JTextField inputHeight = new JTextField(Integer.toString(DEFAULT_HEIGHT), COLUMNS); ij /** Get the top level namespace or this namespace if we are the top. Note: this method should probably return type bsh.This to be consistent with getThis(); */ public This getGlobal( Interpreter declaringInterpreter ) { if ( parent != null ) return parent.getGlobal( declaringInterpreter ); else return getThis( declaringInterpreter ); kC /** * Read Settings * @param stream * @throws IOException * @throws ClassNotFoundException */ public void readData(ObjectInputStream stream) throws IOException, ClassNotFoundException { int version = stream.readInt(); mNumber = stream.readInt(); mName = stream.readUTF(); mD /** * Constructs a comparison failure. * @param message the identifying message or null * @param expected the expected string value * @param actual the actual string value */ public ComparisonFailure (String message, String expected, String actual) { super (message); fExpected= expected; fActual= actual; o public void close() { if (isClosed) { return; } isClosed = true; try { resultOut.setResultType(ResultConstants.SQLDISCONNECT); q public void actionPerformed(ActionEvent evt) { if (!hasFocus()) { stopBlinking(); } if (blinkOn) { setOpaque(false); blinkOn = false; s private static String getBaseName( String className ) { int i = className.indexOf("$"); if ( i == -1 ) return className; return className.substring(i+1); u panel.add(UiUtilities.createHelpTextArea(mLocalizer.msg("help","No endtime defined")), cc.xy(1,1)); mTimePanel = new TimeDateChooserPanel(date); panel.add(mTimePanel, cc.xy(1,3)); w try { suiteMethod= klass.getMethod("suite"); if (! Modifier.isStatic(suiteMethod.getModifiers())) { throw new Exception(klass.getName() + ".suite() must be static"); } suite= (Test) suiteMethod.invoke(null); // static method y // ---------------------------------------------------------------- // required // ---------------------------------------------------------------- addColumn(t, "PROCEDURE_CAT", Types.VARCHAR); addColumn(t, "PROCEDURE_SCHEM", Types.VARCHAR); addColumn(t, "PROCEDURE_NAME", Types.VARCHAR, false); // not null {\ if (missionChip == null) { GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getDefaultConfiguration(); loadMissionChip(gc, color, expertMission); if (expertMission) { missionChip = expertMissionChips.get(color); } /** Swap in the value as the new top of the stack and return the old value. */ public NameSpace swap( NameSpace newTop ) { NameSpace oldTop = (NameSpace)(stack.elementAt(0)); stack.setElementAt( newTop, 0 ); return oldTop;  String classname = (String) in.readObject(); String devname = (String)in.readObject(); DeviceIf dev = DriverFactory.getInstance().createDevice(classname, devname);  String simpleName= runnerClass.getSimpleName(); InitializationError error= new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); return Request.errorReport(fTestClass, error).getRunner();  public boolean isReadOnly() throws HsqlException { Object info = getAttribute(Session.INFO_CONNECTION_READONLY); isReadOnly = ((Boolean) info).booleanValue(); return isReadOnly; } boolean response = warehouseDialog.getResponseBoolean(); remove(warehouseDialog); return response;  else if ( returnType.equals("F") ) opcode = FRETURN; else if ( returnType.equals("J") ) //long opcode = LRETURN; cv.visitInsn(opcode);  String channelId; if (version==1) { dataServiceId = (String)in.readObject(); channelId=""+in.readInt();  @Override public Description getDescription() { Description spec= Description.createSuiteDescription(getName()); List testMethods= fTestMethods; for (Method method : testMethods) spec.addChild(methodDescription(method));  while (classNames.hasNext()) { clsName = (String) classNames.next(); clsCat = ns.getCatalogName(clsName); clsSchem = ns.getSchemaName(clsName);  String[] texts = new String[messages.length]; ImageIcon[] images = new ImageIcon[messages.length]; for (int i = 0; i < messages.length; i++) { String ID = messages[i].getMessageID();  mProgramTable.changeSelection(row, 0, false, false); Program p = (Program) mProgramTableModel.getValueAt(row, 1); JPopupMenu menu = devplugin.Plugin.getPluginManager().createPluginContextMenu(p, CapturePlugin.getInstance());  /** * Add one zero if neccessary * @param number * @return */ private CharSequence addZero(int number) { StringBuilder builder = new StringBuilder(); if (number < 10) { builder.append('0'); } builder.append(Integer.toString(number));  @Override public void run(RunNotifier notifier) { TestResult result= new TestResult(); result.addListener(createAdaptingListener(notifier)); fTest.run(result);  t.checkColumnsMatch(tc.core.mainColArray, tc.core.refTable, tc.core.refColArray); session.commit(); TableWorks tableWorks = new TableWorks(session, t); w @Override public void mousePressed(MouseEvent e) { if (f.getDesktopPane() == null || f.getDesktopPane().getDesktopManager() == null) { return; } loc = SwingUtilities.convertPoint((Component) e.getSource(), e.getX(), e.getY(), null); f.getDesktopPane().getDesktopManager().beginDraggingFrame(f);  /** Translate bsh.Modifiers into ASM modifier bitflags. */ static int getASMModifiers( Modifiers modifiers ) { int mods = 0; if ( modifiers == null ) return mods; if ( modifiers.hasModifier("public") ) mods += ACC_PUBLIC; u public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); String str; if (value instanceof DeviceIf) { DeviceIf device = (DeviceIf)value;  public String compact(String message) { if (fExpected == null || fActual == null || areStringsEqual()) return Assert.format(message, fExpected, fActual); findCommonPrefix(); findCommonSuffix();  classNames = classNameSet.iterator(); while (classNames.hasNext()) { className = (String) classNames.next(); methods = iterateRoutineMethods(className, andAliases);  /** * Generates a color chip image and stores it in memory. * * @param gc The GraphicsConfiguration is needed to create images that are * compatible with the local environment. * @param c The color of the color chip to create. */ private void loadColorChip(GraphicsConfiguration gc, Color c) { BufferedImage tempImage = gc.createCompatibleImage(11, 17); Graphics g = tempImage.getGraphics(); if (c.equals(Color.BLACK)) { g.setColor(Color.WHITE);  out.writeObject(device.getDriver().getClass().getName()); out.writeObject(device.getName()); device.writeData(out); R File data = new File(Plugin.getPluginManager().getTvBrowserSettings().getTvBrowserUserHome() + File.separator + "CaptureDevices" + File.separator + mCount + ".dat"); ObjectOutputStream stream = new ObjectOutputStream(new FileOutputStream(data)); dev.writeData(stream); K private static Class[] getAnnotatedClasses(Class klass) throws InitializationError { SuiteClasses annotation= klass.getAnnotation(SuiteClasses.class); if (annotation == null) throw new InitializationError(String.format("class '%s' must have a SuiteClasses annotation", klass.getName())); return annotation.value();  for (int j = 0; j < fieldcount; j++) { int i = Column.compare(session.database.collation, a[cols[j]], b[cols[j]], coltypes[cols[j]]); if (i != 0) { return i; } } return 0;  /** * Closes all panels, changes the background and shows the main menu. */ public void returnToTitle() { // TODO: check if the GUI object knows that we're not // inGame. (Retrieve value of GUI::inGame.) If GUI thinks // we're still in the game then log an error because at this // point the GUI should have been informed. closeMenus(); removeInGameComponents(); showMainPanel(); e /** subsequent imports override earlier ones */ public void importPackage(String name) { if(importedPackages == null) importedPackages = new Vector(); // If it exists, remove it and add it at the end (avoid memory leak) if ( importedPackages.contains( name ) ) importedPackages.remove( name ); importedPackages.addElement(name);  if(dataServiceId.compareTo(cmpDataServiceId) != 0) { return false; } String country = getCountry(); String cmpCountry = cmp.getCountry(); = public void filter(Filter filter) throws NoTestsRemainException { for (Iterator iter= fTestMethods.iterator(); iter.hasNext();) { Method method= iter.next(); if (!filter.shouldRun(methodDescription(method))) iter.remove(); } if (fTestMethods.isEmpty()) throw new NoTestsRemainException(); t /* fredt - in FK constraints column lists for iColMain and iColRef have identical sets to visible columns of iMain and iRef respectively but the order of columns can be different and must be preserved */ core.mainColArray = mainCols; core.colLen = core.mainColArray.length; core.refColArray = refCols;  /** * Adds a message to the list of messages that need to be displayed on the GUI. * @param message The message to add. */ public synchronized void addMessage(GUIMessage message) { if (getMessageCount() == MESSAGE_COUNT) { messages.remove(0); } messages.add(message); freeColClient.getCanvas().repaint(0, 0, getWidth(), getHeight()); private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2) { switch(hiByte) { case 0: return ((jjbitVec0[i2] & l2) != 0L); default : if ((jjbitVec1[i1] & l1) != 0L) return true; return false; , private static Date correctTimeZone(final Date date) { Date ret=date; if(java.util.TimeZone.getDefault().useDaylightTime()){ if(java.util.TimeZone.getDefault().inDaylightTime(date)) ret.setTime(date.getTime()+1*60*60*1000); } return ret;  @Override public String getMessage() { StringBuilder builder= new StringBuilder(); if (fMessage != null) builder.append(fMessage); builder.append("arrays first differed at element ");  String getStateString() { int state = getState(); switch (state) { case DATABASE_CLOSING : return "DATABASE_CLOSING"; case DATABASE_ONLINE : return "DATABASE_ONLINE";  public boolean displayTileCursor(Tile tile, int canvasX, int canvasY) { if (currentMode == ViewMode.VIEW_TERRAIN_MODE) { Position selectedTilePos = gui.getSelectedTile(); if (selectedTilePos == null) return false; if (selectedTilePos.getX() == tile.getX() && selectedTilePos.getY() == tile.getY()) { TerrainCursor cursor = gui.getCursor(); Qprivate final int jjMoveStringLiteralDfa18_0(long old1, long active1, long old2, long active2) { if (((active1 &= old1) | (active2 &= old2)) == 0L) return jjStartNfa_0(16, 0L, old1, old2); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(17, 0L, active1, active2); M /** * Get the List of all available Channels * * @return All available Channels */ public ElgatoChannel[] getAvailableChannels() { ArrayList list = new ArrayList(); String res = null; try { res = mAppleScript.executeScript(CHANNELLIST);  private Method getParametersMethod() throws Exception { for (Method each : fKlass.getMethods()) { if (Modifier.isStatic(each.getModifiers())) { Annotation[] annotations= each.getAnnotations(); for (Annotation annotation : annotations) { if (annotation.annotationType() == Parameters.class) return each; } } } throw new Exception("No public static parameters method on class " + getName()); p Node r = x.getRight(); if (r != null) { x = r; Node l = x.getLeft();  InGameInputHandler inGameInputHandler = freeColClient.getInGameInputHandler(); freeColClient.getClient().setMessageHandler(inGameInputHandler); gui.setInGame(true);  /** * Applies this action. * * @param e The ActionEvent. */ public void actionPerformed(ActionEvent e) { final Game game = freeColClient.getGame(); final Map map = game.getMap(); Parameters p = showParametersDialog();  public ActionMenu getButtonAction() { AbstractAction action = new AbstractAction() { public void actionPerformed(ActionEvent evt) { showDialog(); } }; action.putValue(Action.NAME, mLocalizer.msg("CapturePlugin", "Capture Plugin")); action.putValue(Action.SMALL_ICON, createImageIcon("mimetypes", "video-x-generic", 16));  Description description= Description.createSuiteDescription(name); int n= ts.testCount(); for (int i= 0; i < n; i++) description.addChild(makeDescription(ts.testAt(i)));  if (expression.exprType != VALUE && expression.exprType != COLUMN && expression.exprType != FUNCTION && expression.exprType != ALTERNATIVE && expression.exprType != CASEWHEN && expression.exprType != CONVERT) { StringBuffer temp = new StringBuffer(); ddl = temp.append('(').append(ddl).append(')').toString(); } return ddl;  private synchronized void purgeOldMessagesFromMessagesToIgnore(int thisTurn) { List keysToRemove = new ArrayList(); for (Entry entry : messagesToIgnore.entrySet()) { if (entry.getValue().intValue() < thisTurn - 1) { if (logger.isLoggable(Level.FINER)) { logger.finer("Removing old model message with key " + entry.getKey() + " from ignored messages."); } keysToRemove.add(entry.getKey());    LineNumberTableLocalVariableTable  this0Lraykernel/apps/readability/applet/PortableData; getSnippets()Ljava/util/List; Signature@()Ljava/util/List;java/util/LinkedList *raykernel/apps/readability/snippet/Snippet (Ljava/lang/String;I)V addLast(Ljava/lang/Object;)VlistLjava/util/LinkedList;iILocalVariableTypeTableDLjava/util/LinkedList; SourceFilePortableData.java!  ,d YSYSYSYSYSYSYSYSYSY  SY "SY $SY &SY (SY*SY,SY.SY0SY2SY4SY6SY8SY:SYSY@SYBSYDSYFSYHSYJSYLSY NSY!PSY"RSY#TSY$VSY%XSY&ZSY'\SY(^SY)`SY*bSY+dSY,fSY-hSY.jSY/lSY0nSY1pSY2rSY3tSY4vSY5xSY6zSY7|SY8~SY9SY:SY;SY<SY=SY>SY?SY@SYASYBSYCSYDSYESYFSYGSYHSYISYJSYKSYLSYMSYNSYOSYPSYQSYRSYSSYTSYUSYVSYWSYXSYYSYZSY[SY\SY]SY^SY_SY`SYaSYbSYcSd YOYOYOYOY OYOYOYOYOYOYOYOYOY"OY#OY$OY%OY&OY'OY(OY)OY3OY4OY6OY9OY>OYAOYDOYEOYGOYLOYMOYROYUOYVOYZOY\OY`OYaOYbOYcOرJ  # (&+,2268<>BDFJJPQVW\]bahfnltrzvy   "&(*..42:7@<FCLKRPXT^Yd]j`pdvg|lqv} $*0%6(<,B3H=N@TIW ZS`UdYh_mcrmwq|sw   !&(S+  /*ݱ   +YK<*Y2־*!# %#)(#  #PK ~:x$3raykernel/apps/readability/applet/PortableData.javapackage raykernel.apps.readability.applet; import java.util.LinkedList; import java.util.List; import raykernel.apps.readability.snippet.Snippet; public class PortableData { public static final String[] snippets = { "\n" + " Object ret = body.eval(callstack, interpreter);\n" + "\n" + " boolean breakout = false;\n" + " if(ret instanceof ReturnControl)\n" + " {\n" + " switch(((ReturnControl)ret).kind )\n" + " {\n" + " case RETURN:\n" + " return ret;\n", "\n" + " if (actionList.size() == 1) {\n" + " ActionMenu menu = actionList.get(0);\n" + "\n" + " if (menu.getSubItems().length == 0) {\n" + " return null;\n" + " }\n" + "\n" + " if (menu.getSubItems().length == 1) {\n" + " Action action = menu.getSubItems()[0].getAction();\n", " private String compactString(String source) {\n" + " String result= DELTA_START + source.substring(fPrefix, source.length() - fSuffix + 1) + DELTA_END;\n" + " if (fPrefix > 0)\n" + " result= computeCommonPrefix() + result;\n" + " if (fSuffix > 0)\n" + " result= result + computeCommonSuffix();\n", " /**\n" + " * Constructor, with a argument reference to the PUBLIC User Object which\n" + " * is null if this is the SYS or PUBLIC user.\n" + " *\n" + " * The dependency upon a GranteeManager is undesirable. Hopefully we\n" + " * can get rid of this dependency with an IOC or Listener re-design.\n" + " */\n" + " Grantee(String name, Grantee inGrantee,\n" + " GranteeManager man) throws HsqlException {\n" + "\n" + " rightsMap = new IntValueHashMap();\n" + " granteeName = name;\n" + " granteeManager = man;\n", " /**\n" + " * Quits the application without any questions.\n" + " */\n" + " public void quit() {\n" + " getConnectController().quitGame(true);\n" + " if (!windowed) {\n" + " gd.setFullScreenWindow(null);\n" + " }\n" + " System.exit(0);\n", " xsp = jj_scanpos;\n" + " if (jj_scan_token(100)) {\n" + " jj_scanpos = xsp;\n" + " if (jj_scan_token(101)) return true;\n", " /**\n" + " * Attention: DO NOT USE THIS!\n" + " * Under Os/2 it has some problems with calculating the real Date!\n" + " * \n" + " * @deprecated\n" + " */\n" + " public Date(int daysSince1970) {\n" + "\n" + " long l = (long) daysSince1970 * 24 * 60 * 60 * 1000;\n" + " java.util.Date d = new java.util.Date(l);\n" + " Calendar cal = Calendar.getInstance();\n", " public TestMethodRunner(Object test, Method method, RunNotifier notifier, Description description) {\n" + " super(test.getClass(), Before.class, After.class, test);\n" + " fTest= test;\n" + " fMethod= method;\n", " /**\n" + " * Returns a vector containing the URI (type + path) for all the databases.\n" + " */\n" + " public static Vector getDatabaseURIs() {\n" + "\n" + " Vector v = new Vector();\n" + " Iterator it = databaseIDMap.values().iterator();\n" + "\n" + " while (it.hasNext()) {\n" + " Database db = (Database) it.next();\n", " private void moveUnit(KeyEvent e) {\n" + " if (!parent.isMapboardActionsEnabled()) {\n" + " return;\n" + " }\n" + " \n" + " switch (e.getKeyCode()) {\n" + " case KeyEvent.VK_ESCAPE:\n" + " // main menu\n" + " break;\n" + " case KeyEvent.VK_NUMPAD1:\n" + " case KeyEvent.VK_END:\n" + " inGameController.moveActiveUnit(Map.SW);\n", "\n" + " if ( clas == null )\n" + " throw new ClassNotFoundException(\n" + " \"Class: \" + value+ \" not found in namespace\");\n" + "\n" + " asClass = clas;\n" + " return asClass;\n", "\n" + " \n" + " btPanel.add(cancel);\n" + "\n" + " getRootPane().setDefaultButton(ok);\n" + " \n" + " panel.add(btPanel, BorderLayout.SOUTH);\n", " * @param expected expected value\n" + " * @param actual actual value\n" + " */\n" + " static public void assertEquals(String message, Object expected, Object actual) {\n" + " if (expected == null && actual == null)\n" + " return;\n" + " if (expected != null && isEquals(expected, actual))\n" + " return;\n" + " else if (expected instanceof String && actual instanceof String) {\n" + " String cleanMessage= message == null ? \"\" : message;\n", " Object removeName(String name) throws HsqlException {\n" + "\n" + " Object owner = nameList.remove(name);\n" + "\n" + " if (owner == null) {\n" + "\n" + " // should contain name\n" + " throw Trace.error(Trace.GENERAL_ERROR);\n" + " }\n" + "\n" + " return owner;\n", "\n" + " int stepSize = Math.min((option.getMaximumValue() - option.getMinimumValue()) / 10, 1000);\n" + " spinner = new JSpinner(new SpinnerNumberModel(option.getValue(), option.getMinimumValue(),\n" + " option.getMaximumValue(), Math.max(1, stepSize)));\n" + " spinner.setToolTipText(option.getShortDescription());\n", " if ( parent != null )\n" + " setStrictJava( parent.getStrictJava() );\n" + " this.sourceFileInfo = sourceFileInfo;\n" + "\n" + " BshClassManager bcm = BshClassManager.createClassManager( this );\n", " \n" + " mDevices = new Vector();\n" + " \n" + " DeviceFileHandling reader = new DeviceFileHandling();\n" + "\n" + " for (int i = 0; i < num; i++) {\n" + " String classname = (String) in.readObject();\n", " /**\n" + " * Do not use. Testing purposes only.\n" + " */\n" + " public Result runMain(String... args) {\n" + " System.out.println(\"JUnit version \" + Version.id());\n" + " List> classes= new ArrayList>();\n" + " List missingClasses= new ArrayList();\n", " /**\n" + " * temp constraint constructor\n" + " */\n" + " Constraint(HsqlName name, int[] mainCols, Table refTable, int[] refCols,\n" + " int type, int deleteAction, int updateAction) {\n" + "\n" + " core = new ConstraintCore();\n" + " constName = name;\n" + " constType = type;\n", " int eventId = active? ON : OFF;\n" + " ActionEvent blinkEvent = new ActionEvent(this,eventId,\"blink\");\n" + " \n" + " fireActionEvent(blinkEvent);\n", " else if ( isPrimitive( returnType ) ) \n" + " {\n" + " int opcode = IRETURN;\n" + " String type;\n" + " String meth;\n", " /**\n" + " * Returns the PluginPanel\n" + " * @return Panel\n" + " */\n" + " public JPanel createSettingsPanel() {\n" + " mPanel = new CapturePluginPanel(mOwner, mCloneData);\n" + " mPanel.setBorder(Borders.createEmptyBorder(Sizes.DLUY5,Sizes.DLUX5,Sizes.DLUY5,Sizes.DLUX5));\n" + " mPanel.setSelectedTab(mCurrentPanel);\n", " protected void printFailures(Result result) {\n" + " if (result.getFailureCount() == 0)\n" + " return;\n" + " if (result.getFailureCount() == 1)\n" + " getWriter().println(\"There was \" + result.getFailureCount() + \" failure:\");\n" + " else\n" + " getWriter().println(\"There were \" + result.getFailureCount() + \" failures:\");\n", " public static long getNormalisedTime(long t) {\n" + "\n" + " synchronized (tempCalDefault) {\n" + " setTimeInMillis(tempCalDefault, t);\n" + " resetToTime(tempCalDefault);\n" + "\n" + " return getTimeInMillis(tempCalDefault);\n", "\n" + " public boolean check(Unit u, PathNode p) {\n" + " if (p.getTile().getSettlement() != null && p.getTile().getSettlement().getOwner() == player\n" + " && p.getTile().getSettlement() != inSettlement) {\n" + " Settlement s = p.getTile().getSettlement();\n" + " int turns = p.getTurns();\n" + " destinations.add(new ChoiceItem(s.toString() + \" (\" + turns + \")\", s));\n", "\n" + " if ((bufpos + 1) >= len)\n" + " System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);\n" + " else\n" + " {\n" + " System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,\n" + " len - bufpos - 1);\n" + " System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);\n", " /**\n" + " * Compute the proper position for a centered window\n" + " */\n" + " private Point comuteDisplayPointCentre(Dimension dim) {\n" + " Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();\n" + " int x = (screen.width - dim.width) / 2;\n" + " int y = (screen.height - dim.height) / 2;\n", " public void filter(Filter filter) throws NoTestsRemainException {\n" + " for (Iterator iter= fRunners.iterator(); iter.hasNext();) {\n" + " Runner runner= iter.next();\n" + " if (filter.shouldRun(runner.getDescription()))\n" + " filter.apply(runner);\n" + " else\n" + " iter.remove();\n", " boolean hasReturnValue;\n" + "\n" + " outlen = parameters.length;\n" + " offset = 0;\n", " /**\n" + " * Sets the currently chosen MapTransform.\n" + " * @param mt The transform that should be applied to a\n" + " * Tile that is clicked on the map.\n" + " */\n" + " public void setMapTransform(MapTransform mt) {\n" + " currentMapTransform = mt;\n" + " MapControlsAction mca = (MapControlsAction) freeColClient.getActionManager().getFreeColAction(MapControlsAction.ID);\n" + " if (mca.getMapControls() != null) {\n" + " mca.getMapControls().update(mt);\n", " \n" + " if (iterateOverMe instanceof String)\n" + " return createEnumeration(((String)iterateOverMe).toCharArray());\n" + " \n" + " if (iterateOverMe instanceof StringBuffer)\n" + " return createEnumeration(\n" + " iterateOverMe.toString().toCharArray());\n" + "\n" + " throw new IllegalArgumentException(\n" + " \"Cannot enumerate object of type \"+iterateOverMe.getClass());\n", " /**\n" + " * Constructs a new Date object, initialized with the current date.\n" + " */\n" + " public Date() {\n" + " Calendar mCalendar = Calendar.getInstance();\n" + " mYear = mCalendar.get(Calendar.YEAR);\n" + " mMonth = mCalendar.get(Calendar.MONTH) + 1;\n", " /**\n" + " * @param contextLength the maximum length for expected and actual. When contextLength \n" + " * is exceeded, the Strings are shortened\n" + " * @param expected the expected string value\n" + " * @param actual the actual string value\n" + " */\n" + " public ComparisonCompactor(int contextLength, String expected, String actual) {\n" + " fContextLength= contextLength;\n" + " fExpected= expected;\n" + " fActual= actual;\n", "\n" + " case CompiledStatement.DELETE :\n" + " return executeDeleteStatement(cs);\n" + "\n" + " case CompiledStatement.CALL :\n" + " return executeCallStatement(cs);\n" + "\n" + " case CompiledStatement.DDL :\n" + " return executeDDLStatement(cs);\n", " /**\n" + " * Creates a new DisbandUnitAction.\n" + " * \n" + " * @param freeColClient The main controller object for the client.\n" + " */\n" + " DisbandUnitAction(FreeColClient freeColClient) {\n" + " super(freeColClient, \"unit.state.8\", null, KeyStroke.getKeyStroke('D', 0));\n" + " putValue(BUTTON_IMAGE, freeColClient.getImageLibrary().getUnitButtonImageIcon(ImageLibrary.UNIT_BUTTON_DISBAND,\n" + " 0));\n" + " putValue(BUTTON_ROLLOVER_IMAGE, freeColClient.getImageLibrary().getUnitButtonImageIcon(\n" + " ImageLibrary.UNIT_BUTTON_DISBAND, 1));\n", " Class clas = object.getClass();\n" + " Field field = Reflect.resolveJavaField( \n" + " clas, name, false/*onlyStatic*/ );\n" + " if ( field != null )\n" + " return new Variable( \n" + " name, field.getType(), new LHS( object, field ) );\n", " \n" + " for(AbstractPluginProgramFormating config : mConfigs)\n" + " if(config != null && config.isValid())\n" + " list.add(new ProgramReceiveTarget(this, config.getName(), config.getId()));\n" + " \n" + " if(list.isEmpty())\n" + " list.add(new ProgramReceiveTarget(this, DEFAULT_CONFIG.getName(), DEFAULT_CONFIG.getId()));\n" + " \n" + " return list.toArray(new ProgramReceiveTarget[list.size()]);\n", " Class expectedException(Method method) {\n" + " Test annotation= method.getAnnotation(Test.class);\n" + " if (annotation.expected() == None.class)\n" + " return null;\n" + " else\n" + " return annotation.expected();\n", " row[1] = ns.getCatalogName(row[0]);\n" + " row[2] = schema.equals(defschema) ? Boolean.TRUE\n" + " : Boolean.FALSE;\n" + "\n" + " t.insertSys(row);\n", " /**\n" + " * Handles an \"deliverGift\"-request.\n" + " * \n" + " * @param element The element (root element in a DOM-parsed XML tree) that\n" + " * holds all the information.\n" + " */\n" + " private Element deliverGift(Element element) {\n" + " Element unitElement = Message.getChildElement(element, Unit.getXMLElementTagName());\n" + "\n" + " Unit unit = (Unit) getGame().getFreeColGameObject(unitElement.getAttribute(\"ID\"));\n" + " unit.readFromXMLElement(unitElement);\n", " switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\n" + " case EQ:\n" + " t = jj_consume_token(EQ);\n" + " break;\n" + " case NE:\n" + " t = jj_consume_token(NE);\n", " public synchronized void removeProgram(Program program) {\n" + " PluginTreeNode node = findProgramTreeNode(program, false);\n" + " if (node != null) {\n" + " mChildNodes.remove(node);\n" + " if (mMarker != null) {\n" + " program.unmark(mMarker);\n", " private TestClassRunnerForParameters(Class klass, Object[] parameters, int i) {\n" + " super(klass);\n" + " fParameters= parameters;\n" + " fParameterSetNumber= i;\n", " void link(IndexRowIterator other) {\n" + "\n" + " other.next = next;\n" + " other.last = this;\n" + " next.last = other;\n", " final String heightText = Messages.message(\"height\");\n" + " \n" + " final JTextField inputWidth = new JTextField(Integer.toString(DEFAULT_WIDTH), COLUMNS);\n" + " final JTextField inputHeight = new JTextField(Integer.toString(DEFAULT_HEIGHT), COLUMNS);\n", " /**\n" + " Get the top level namespace or this namespace if we are the top.\n" + " Note: this method should probably return type bsh.This to be consistent\n" + " with getThis();\n" + " */\n" + " public This getGlobal( Interpreter declaringInterpreter )\n" + " {\n" + " if ( parent != null )\n" + " return parent.getGlobal( declaringInterpreter );\n" + " else\n" + " return getThis( declaringInterpreter );\n", " /**\n" + " * Read Settings\n" + " * @param stream\n" + " * @throws IOException\n" + " * @throws ClassNotFoundException\n" + " */\n" + " public void readData(ObjectInputStream stream) throws IOException, ClassNotFoundException {\n" + " int version = stream.readInt();\n" + " mNumber = stream.readInt();\n" + " mName = stream.readUTF();\n", " /**\n" + " * Constructs a comparison failure.\n" + " * @param message the identifying message or null\n" + " * @param expected the expected string value\n" + " * @param actual the actual string value\n" + " */\n" + " public ComparisonFailure (String message, String expected, String actual) {\n" + " super (message);\n" + " fExpected= expected;\n" + " fActual= actual;\n", " public void close() {\n" + "\n" + " if (isClosed) {\n" + " return;\n" + " }\n" + "\n" + " isClosed = true;\n" + "\n" + " try {\n" + " resultOut.setResultType(ResultConstants.SQLDISCONNECT);\n", " public void actionPerformed(ActionEvent evt) {\n" + " if (!hasFocus()) {\n" + " stopBlinking();\n" + " }\n" + "\n" + " if (blinkOn) {\n" + " setOpaque(false);\n" + " blinkOn = false;\n", " private static String getBaseName( String className ) \n" + " {\n" + " int i = className.indexOf(\"$\");\n" + " if ( i == -1 )\n" + " return className;\n" + "\n" + " return className.substring(i+1);\n", "\n" + " panel.add(UiUtilities.createHelpTextArea(mLocalizer.msg(\"help\",\"No endtime defined\")), cc.xy(1,1));\n" + " \n" + " mTimePanel = new TimeDateChooserPanel(date);\n" + " panel.add(mTimePanel, cc.xy(1,3));\n", " try {\n" + " suiteMethod= klass.getMethod(\"suite\");\n" + " if (! Modifier.isStatic(suiteMethod.getModifiers())) {\n" + " throw new Exception(klass.getName() + \".suite() must be static\");\n" + " }\n" + " suite= (Test) suiteMethod.invoke(null); // static method\n", "\n" + " // ----------------------------------------------------------------\n" + " // required\n" + " // ----------------------------------------------------------------\n" + " addColumn(t, \"PROCEDURE_CAT\", Types.VARCHAR);\n" + " addColumn(t, \"PROCEDURE_SCHEM\", Types.VARCHAR);\n" + " addColumn(t, \"PROCEDURE_NAME\", Types.VARCHAR, false); // not null\n", "\n" + " if (missionChip == null) {\n" + " GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()\n" + " .getDefaultConfiguration();\n" + " loadMissionChip(gc, color, expertMission);\n" + "\n" + " if (expertMission) {\n" + " missionChip = expertMissionChips.get(color);\n", " /**\n" + " Swap in the value as the new top of the stack and return the old\n" + " value.\n" + " */\n" + " public NameSpace swap( NameSpace newTop ) {\n" + " NameSpace oldTop = (NameSpace)(stack.elementAt(0));\n" + " stack.setElementAt( newTop, 0 );\n" + " return oldTop;\n", " \n" + " String classname = (String) in.readObject();\n" + " String devname = (String)in.readObject();\n" + " \n" + " DeviceIf dev = DriverFactory.getInstance().createDevice(classname, devname);\n", " String simpleName= runnerClass.getSimpleName();\n" + " InitializationError error= new InitializationError(String.format(\n" + " CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName));\n" + " return Request.errorReport(fTestClass, error).getRunner();\n", " public boolean isReadOnly() throws HsqlException {\n" + "\n" + " Object info = getAttribute(Session.INFO_CONNECTION_READONLY);\n" + "\n" + " isReadOnly = ((Boolean) info).booleanValue();\n" + "\n" + " return isReadOnly;\n", " \n" + " boolean response = warehouseDialog.getResponseBoolean();\n" + " remove(warehouseDialog);\n" + " return response;\n", " else if ( returnType.equals(\"F\") )\n" + " opcode = FRETURN;\n" + " else if ( returnType.equals(\"J\") ) //long\n" + " opcode = LRETURN;\n" + "\n" + " cv.visitInsn(opcode);\n", " String channelId;\n" + " \n" + " if (version==1) {\n" + " dataServiceId = (String)in.readObject();\n" + " channelId=\"\"+in.readInt();\n", " @Override\n" + " public Description getDescription() {\n" + " Description spec= Description.createSuiteDescription(getName());\n" + " List testMethods= fTestMethods;\n" + " for (Method method : testMethods)\n" + " spec.addChild(methodDescription(method));\n", "\n" + " while (classNames.hasNext()) {\n" + " clsName = (String) classNames.next();\n" + " clsCat = ns.getCatalogName(clsName);\n" + " clsSchem = ns.getSchemaName(clsName);\n", "\n" + " String[] texts = new String[messages.length];\n" + " ImageIcon[] images = new ImageIcon[messages.length];\n" + " for (int i = 0; i < messages.length; i++) {\n" + " String ID = messages[i].getMessageID();\n", "\n" + " mProgramTable.changeSelection(row, 0, false, false);\n" + "\n" + " Program p = (Program) mProgramTableModel.getValueAt(row, 1);\n" + "\n" + " JPopupMenu menu = devplugin.Plugin.getPluginManager().createPluginContextMenu(p, CapturePlugin.getInstance());\n", " /**\n" + " * Add one zero if neccessary\n" + " * @param number\n" + " * @return\n" + " */\n" + " private CharSequence addZero(int number) {\n" + " StringBuilder builder = new StringBuilder();\n" + " \n" + " if (number < 10) {\n" + " builder.append('0');\n" + " }\n" + " \n" + " builder.append(Integer.toString(number));\n", " @Override\n" + " public void run(RunNotifier notifier) {\n" + " TestResult result= new TestResult();\n" + " result.addListener(createAdaptingListener(notifier));\n" + " fTest.run(result);\n", " t.checkColumnsMatch(tc.core.mainColArray, tc.core.refTable,\n" + " tc.core.refColArray);\n" + " session.commit();\n" + "\n" + " TableWorks tableWorks = new TableWorks(session, t);\n", " @Override\n" + " public void mousePressed(MouseEvent e) {\n" + " if (f.getDesktopPane() == null || f.getDesktopPane().getDesktopManager() == null) {\n" + " return;\n" + " }\n" + " loc = SwingUtilities.convertPoint((Component) e.getSource(), e.getX(), e.getY(), null);\n" + " f.getDesktopPane().getDesktopManager().beginDraggingFrame(f);\n", " /**\n" + " Translate bsh.Modifiers into ASM modifier bitflags.\n" + " */\n" + " static int getASMModifiers( Modifiers modifiers ) \n" + " {\n" + " int mods = 0;\n" + " if ( modifiers == null )\n" + " return mods;\n" + "\n" + " if ( modifiers.hasModifier(\"public\") )\n" + " mods += ACC_PUBLIC;\n", " public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {\n" + "\n" + " JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);\n" + " \n" + " String str;\n" + " \n" + " if (value instanceof DeviceIf) {\n" + " DeviceIf device = (DeviceIf)value; \n", " public String compact(String message) {\n" + " if (fExpected == null || fActual == null || areStringsEqual())\n" + " return Assert.format(message, fExpected, fActual);\n" + "\n" + " findCommonPrefix();\n" + " findCommonSuffix();\n", "\n" + " classNames = classNameSet.iterator();\n" + "\n" + " while (classNames.hasNext()) {\n" + " className = (String) classNames.next();\n" + " methods = iterateRoutineMethods(className, andAliases);\n", " /**\n" + " * Generates a color chip image and stores it in memory.\n" + " * \n" + " * @param gc The GraphicsConfiguration is needed to create images that are\n" + " * compatible with the local environment.\n" + " * @param c The color of the color chip to create.\n" + " */\n" + " private void loadColorChip(GraphicsConfiguration gc, Color c) {\n" + " BufferedImage tempImage = gc.createCompatibleImage(11, 17);\n" + " Graphics g = tempImage.getGraphics();\n" + " if (c.equals(Color.BLACK)) {\n" + " g.setColor(Color.WHITE);\n", " \n" + " out.writeObject(device.getDriver().getClass().getName());\n" + " out.writeObject(device.getName());\n" + " \n" + " device.writeData(out);\n", " \n" + " File data = new File(Plugin.getPluginManager().getTvBrowserSettings().getTvBrowserUserHome() + File.separator + \n" + " \"CaptureDevices\" + File.separator + mCount + \".dat\");\n" + " \n" + " ObjectOutputStream stream = new ObjectOutputStream(new FileOutputStream(data));\n" + " \n" + " dev.writeData(stream);\n", " private static Class[] getAnnotatedClasses(Class klass) throws InitializationError {\n" + " SuiteClasses annotation= klass.getAnnotation(SuiteClasses.class);\n" + " if (annotation == null)\n" + " throw new InitializationError(String.format(\"class '%s' must have a SuiteClasses annotation\", klass.getName()));\n" + " return annotation.value();\n", "\n" + " for (int j = 0; j < fieldcount; j++) {\n" + " int i = Column.compare(session.database.collation, a[cols[j]],\n" + " b[cols[j]], coltypes[cols[j]]);\n" + "\n" + " if (i != 0) {\n" + " return i;\n" + " }\n" + " }\n" + "\n" + " return 0;\n", " /**\n" + " * Closes all panels, changes the background and shows the main menu.\n" + " */\n" + " public void returnToTitle() {\n" + " // TODO: check if the GUI object knows that we're not\n" + " // inGame. (Retrieve value of GUI::inGame.) If GUI thinks\n" + " // we're still in the game then log an error because at this\n" + " // point the GUI should have been informed.\n" + " closeMenus();\n" + " removeInGameComponents();\n" + " showMainPanel();\n", " /**\n" + " subsequent imports override earlier ones\n" + " */\n" + " public void importPackage(String name)\n" + " {\n" + " if(importedPackages == null)\n" + " importedPackages = new Vector();\n" + "\n" + " // If it exists, remove it and add it at the end (avoid memory leak)\n" + " if ( importedPackages.contains( name ) )\n" + " importedPackages.remove( name );\n" + "\n" + " importedPackages.addElement(name);\n", " \n" + " if(dataServiceId.compareTo(cmpDataServiceId) != 0) {\n" + " return false;\n" + " }\n" + " \n" + " String country = getCountry();\n" + " String cmpCountry = cmp.getCountry();\n", " public void filter(Filter filter) throws NoTestsRemainException {\n" + " for (Iterator iter= fTestMethods.iterator(); iter.hasNext();) {\n" + " Method method= iter.next();\n" + " if (!filter.shouldRun(methodDescription(method)))\n" + " iter.remove();\n" + " }\n" + " if (fTestMethods.isEmpty())\n" + " throw new NoTestsRemainException();\n", " /* fredt - in FK constraints column lists for iColMain and iColRef have\n" + " identical sets to visible columns of iMain and iRef respectively\n" + " but the order of columns can be different and must be preserved\n" + " */\n" + " core.mainColArray = mainCols;\n" + " core.colLen = core.mainColArray.length;\n" + " core.refColArray = refCols;\n", " /**\n" + " * Adds a message to the list of messages that need to be displayed on the GUI.\n" + " * @param message The message to add.\n" + " */\n" + " public synchronized void addMessage(GUIMessage message) {\n" + " if (getMessageCount() == MESSAGE_COUNT) {\n" + " messages.remove(0);\n" + " }\n" + " messages.add(message);\n" + "\n" + " freeColClient.getCanvas().repaint(0, 0, getWidth(), getHeight());\n", "private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2)\n" + "{\n" + " switch(hiByte)\n" + " {\n" + " case 0:\n" + " return ((jjbitVec0[i2] & l2) != 0L);\n" + " default : \n" + " if ((jjbitVec1[i1] & l1) != 0L)\n" + " return true;\n" + " return false;\n", " private static Date correctTimeZone(final Date date) {\n" + " Date ret=date;\n" + " if(java.util.TimeZone.getDefault().useDaylightTime()){\n" + " if(java.util.TimeZone.getDefault().inDaylightTime(date))\n" + " ret.setTime(date.getTime()+1*60*60*1000);\n" + " }\n" + " return ret;\n", " @Override\n" + " public String getMessage() {\n" + " StringBuilder builder= new StringBuilder();\n" + " if (fMessage != null)\n" + " builder.append(fMessage);\n" + " builder.append(\"arrays first differed at element \");\n", " String getStateString() {\n" + "\n" + " int state = getState();\n" + "\n" + " switch (state) {\n" + "\n" + " case DATABASE_CLOSING :\n" + " return \"DATABASE_CLOSING\";\n" + "\n" + " case DATABASE_ONLINE :\n" + " return \"DATABASE_ONLINE\";\n", " public boolean displayTileCursor(Tile tile, int canvasX, int canvasY) {\n" + " if (currentMode == ViewMode.VIEW_TERRAIN_MODE) {\n" + "\n" + " Position selectedTilePos = gui.getSelectedTile();\n" + " if (selectedTilePos == null)\n" + " return false;\n" + "\n" + " if (selectedTilePos.getX() == tile.getX() && selectedTilePos.getY() == tile.getY()) {\n" + " TerrainCursor cursor = gui.getCursor();\n", "private final int jjMoveStringLiteralDfa18_0(long old1, long active1, long old2, long active2)\n" + "{\n" + " if (((active1 &= old1) | (active2 &= old2)) == 0L)\n" + " return jjStartNfa_0(16, 0L, old1, old2); \n" + " try { curChar = input_stream.readChar(); }\n" + " catch(java.io.IOException e) {\n" + " jjStopStringLiteralDfa_0(17, 0L, active1, active2);\n", " /**\n" + " * Get the List of all available Channels\n" + " * \n" + " * @return All available Channels\n" + " */\n" + " public ElgatoChannel[] getAvailableChannels() {\n" + " ArrayList list = new ArrayList();\n" + "\n" + " String res = null;\n" + " try {\n" + " res = mAppleScript.executeScript(CHANNELLIST);\n", " private Method getParametersMethod() throws Exception {\n" + " for (Method each : fKlass.getMethods()) {\n" + " if (Modifier.isStatic(each.getModifiers())) {\n" + " Annotation[] annotations= each.getAnnotations();\n" + " for (Annotation annotation : annotations) {\n" + " if (annotation.annotationType() == Parameters.class)\n" + " return each;\n" + " }\n" + " }\n" + " }\n" + " throw new Exception(\"No public static parameters method on class \"\n" + " + getName());\n", "\n" + " Node r = x.getRight();\n" + "\n" + " if (r != null) {\n" + " x = r;\n" + "\n" + " Node l = x.getLeft();\n", " InGameInputHandler inGameInputHandler = freeColClient.getInGameInputHandler();\n" + "\n" + " freeColClient.getClient().setMessageHandler(inGameInputHandler);\n" + " gui.setInGame(true);\n", " /**\n" + " * Applies this action.\n" + " * \n" + " * @param e The ActionEvent.\n" + " */\n" + " public void actionPerformed(ActionEvent e) {\n" + " final Game game = freeColClient.getGame();\n" + " final Map map = game.getMap();\n" + "\n" + " Parameters p = showParametersDialog();\n", " public ActionMenu getButtonAction() {\n" + " AbstractAction action = new AbstractAction() {\n" + "\n" + " public void actionPerformed(ActionEvent evt) {\n" + " showDialog();\n" + " }\n" + " };\n" + " action.putValue(Action.NAME, mLocalizer.msg(\"CapturePlugin\", \"Capture Plugin\"));\n" + " action.putValue(Action.SMALL_ICON, createImageIcon(\"mimetypes\", \"video-x-generic\", 16));\n", " Description description= Description.createSuiteDescription(name);\n" + " int n= ts.testCount();\n" + " for (int i= 0; i < n; i++)\n" + " description.addChild(makeDescription(ts.testAt(i)));\n", "\n" + " if (expression.exprType != VALUE && expression.exprType != COLUMN\n" + " && expression.exprType != FUNCTION\n" + " && expression.exprType != ALTERNATIVE\n" + " && expression.exprType != CASEWHEN\n" + " && expression.exprType != CONVERT) {\n" + " StringBuffer temp = new StringBuffer();\n" + "\n" + " ddl = temp.append('(').append(ddl).append(')').toString();\n" + " }\n" + "\n" + " return ddl;\n", " private synchronized void purgeOldMessagesFromMessagesToIgnore(int thisTurn) {\n" + " List keysToRemove = new ArrayList();\n" + " for (Entry entry : messagesToIgnore.entrySet()) {\n" + " if (entry.getValue().intValue() < thisTurn - 1) {\n" + " if (logger.isLoggable(Level.FINER)) {\n" + " logger.finer(\"Removing old model message with key \" + entry.getKey() + \" from ignored messages.\");\n" + " }\n" + " keysToRemove.add(entry.getKey());\n", }; public static final int[] scores = { 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, }; public static List getSnippets() { LinkedList list = new LinkedList(); for (int i = 0; i < snippets.length; i++) { list.addLast(new Snippet(snippets[i], i)); } return list; } } PK w:V..Kraykernel/apps/readability/applet/ReadabilityApplet$ReadabilityAction.class1ZEraykernel/apps/readability/applet/ReadabilityApplet$ReadabilityActionjava/lang/Objectjava/awt/event/ActionListenerthis$05Lraykernel/apps/readability/applet/ReadabilityApplet;8(Lraykernel/apps/readability/applet/ReadabilityApplet;)VCode    ()VLineNumberTableLocalVariableTablethisGLraykernel/apps/readability/applet/ReadabilityApplet$ReadabilityAction;actionPerformed(Ljava/awt/event/ActionEvent;)V 3raykernel/apps/readability/applet/ReadabilityApplet access$0J(Lraykernel/apps/readability/applet/ReadabilityApplet;)Ljava/awt/TextArea;  java/awt/TextArea !"getText()Ljava/lang/String;$(raykernel/apps/readability/code/Function #& '(Ljava/lang/String;)V ) *+re5Lraykernel/apps/readability/applet/PortableEvaluator; -/.3raykernel/apps/readability/applet/PortableEvaluator 01getReadability7(Lraykernel/apps/readability/code/TrainableCodeBlock;)D 3 45access$1K(Lraykernel/apps/readability/applet/ReadabilityApplet;)Ljavax/swing/JLabel;7java/lang/StringBuilder 9 :; readabilityLjava/lang/String; =?>java/lang/String @AvalueOf&(Ljava/lang/Object;)Ljava/lang/String; 6& 6D EFappend(D)Ljava/lang/StringBuilder; 6H I"toString KMLjavax/swing/JLabel N'setTextaeLjava/awt/event/ActionEvent;sf*Lraykernel/apps/readability/code/Function;readD SourceFileReadabilityApplet.java InnerClassesReadabilityAction   4 *+ *J   E* M#Y,%N* (-,9* 26Y* 8<BCGJP RT!VDX4EEOP :Q;1RS!$TUVWX YPK w:[ 9raykernel/apps/readability/applet/ReadabilityApplet.class1u3raykernel/apps/readability/applet/ReadabilityAppletjava/applet/AppletserialVersionUIDJ ConstantValuere5Lraykernel/apps/readability/applet/PortableEvaluator; readabilityLjava/lang/String;inputLjava/awt/TextArea;outputLjavax/swing/JLabel; thisAppletLjava/applet/Applet;()VCode   Readability:  LineNumberTableLocalVariableTablethis5Lraykernel/apps/readability/applet/ReadabilityApplet;init # %3raykernel/apps/readability/applet/PortableEvaluator $ ( *java/awt/TextArea ), -(II)V / 1javax/swing/JLabel3: 05 6(Ljava/lang/String;)V 8 :java/awt/Button< Calculate 95?java/awt/BorderLayout > B CD setLayout(Ljava/awt/LayoutManager;)VFjavax/swing/JPanel E EI JKadd*(Ljava/awt/Component;)Ljava/awt/Component;MReadability MetricONorth Q JR)(Ljava/awt/Component;Ljava/lang/Object;)VTCenterVSouth X Y-setSize[Eraykernel/apps/readability/applet/ReadabilityApplet$ReadabilityAction Z] ^8(Lraykernel/apps/readability/applet/ReadabilityApplet;)V 9` abaddActionListener"(Ljava/awt/event/ActionListener;)VbLjava/awt/Button;topPanelLjavax/swing/JPanel; textPanel bottomPanel buttonPaneloutPanelcaGLraykernel/apps/readability/applet/ReadabilityApplet$ReadabilityAction;access$0J(Lraykernel/apps/readability/applet/ReadabilityApplet;)Ljava/awt/TextArea;access$1K(Lraykernel/apps/readability/applet/ReadabilityApplet;)Ljavax/swing/JLabel; SourceFileReadabilityApplet.java InnerClassesReadabilityAction! = **    !**"*$Y&'*)Y<+.*0Y2479Y;=L*>Y@AEYGMEYGNEYG:EYG:EYG:HWHW,0YL4HW-*.HW+HW*7HW*,NP*-SP*UP*ȶWZY*\:+_b!$%,'6*A,I-Q.Z/c0l2t3|5678:;<=BCHR 6cdIefQgfZ{hfcriflijfklmn%*.op%*7qrs ZtPK t:G`aa8raykernel/apps/readability/applet/ReadabilityApplet.javapackage raykernel.apps.readability.applet; import java.applet.Applet; import java.awt.BorderLayout; import java.awt.Button; import java.awt.TextArea; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JLabel; import javax.swing.JPanel; import raykernel.apps.readability.code.Function; public class ReadabilityApplet extends Applet { private static final long serialVersionUID = 1L; PortableEvaluator re; String readability = "Readability: "; private TextArea input; private JLabel output; Applet thisApplet; public void init() { thisApplet = this; re = new PortableEvaluator(); // Construct the TextFields this.input = new TextArea(8, 60); this.output = new JLabel(" "); //this.output.setEditable(false); Button b = new Button("Calculate"); // add the button to the layout this.setLayout(new BorderLayout()); JPanel topPanel = new JPanel(); JPanel textPanel = new JPanel(); JPanel bottomPanel = new JPanel(); JPanel buttonPanel = new JPanel(); JPanel outPanel = new JPanel(); bottomPanel.add(buttonPanel); bottomPanel.add(outPanel); topPanel.add(new JLabel("Readability Metric")); textPanel.add(input); buttonPanel.add(b); outPanel.add(output); this.add(topPanel, BorderLayout.NORTH); this.add(textPanel, BorderLayout.CENTER); this.add(bottomPanel, BorderLayout.SOUTH); this.setSize(500, 200); // specify that action events sent by the // button or the input TextField should be handled // by the same CapitalizerAction object ReadabilityAction ca = new ReadabilityAction(); b.addActionListener(ca); //this.input.addComponentListener(ca); // notice that ActionEvents produced by output are ignored. } class ReadabilityAction implements ActionListener { public void actionPerformed(ActionEvent ae) { String s = input.getText(); Function f = new Function(s); double read = re.getReadability(f); output.setText(readability + read); } } } PK w:J:Kraykernel/apps/readability/applet/PortableSnippetScoreFeatureDetector.class1DEraykernel/apps/readability/applet/PortableSnippetScoreFeatureDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetector()VCode  LineNumberTableLocalVariableTablethisGLraykernel/apps/readability/applet/PortableSnippetScoreFeatureDetector; featureNames()[Ljava/lang/String; snippetscore raykernel/util/Common makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)V*raykernel/apps/readability/snippet/Snippet"java/lang/IllegalArgumentException!(Can only run score detector on snippets! # $(Ljava/lang/String;)V &('.raykernel/apps/readability/applet/PortableData )*scores[I , -. getNumber()I0$raykernel/ml/feature/BinClassFeature 2 ? /6 7(Ljava/lang/String;Z)V 9 :; setFeature!(Lraykernel/ml/feature/Feature;)Vblock Lraykernel/ml/feature/Trainable;s,Lraykernel/apps/readability/snippet/Snippet;scoreF SourceFile(PortableSnippetScoreFeatureDetector.java! /*    0   @+ Y "+M%,+.F,/Y*12%358  ? *@@<=*>? @ABCPK zt:9kJraykernel/apps/readability/applet/PortableSnippetScoreFeatureDetector.javapackage raykernel.apps.readability.applet; import raykernel.apps.readability.snippet.Snippet; import raykernel.ml.feature.BinClassFeature; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.Trainable; import raykernel.util.Common; public class PortableSnippetScoreFeatureDetector implements FeatureDetector { public String[] featureNames() { return Common.makeSingletonArray("snippetscore"); } public void runDetector(Trainable block) { if (!(block instanceof Snippet)) throw new IllegalArgumentException("Can only run score detector on snippets!"); Snippet s = (Snippet) block; float score = (float) PortableData.scores[s.getNumber()]; s.setFeature(new BinClassFeature(featureNames()[0], score > 0.5)); } } PK w:=/7raykernel/apps/readability/misc/BugCountEvaluator.class1;1raykernel/apps/readability/misc/BugCountEvaluatorjava/lang/Object.raykernel/apps/readability/misc/BlockEvaluatorbug_feature_nameLjava/lang/String;(Ljava/lang/String;)VCode  ()V  LineNumberTableLocalVariableTablethis3Lraykernel/apps/readability/misc/BugCountEvaluator; evaluateBlock.(Lraykernel/apps/readability/code/CodeBlock;)F )raykernel/apps/readability/code/CodeBlock iterator()Ljava/util/Iterator;  java/util/Iterator !"next()Ljava/lang/Object;$(raykernel/apps/readability/code/CodeLine #& '( getFeature2(Ljava/lang/String;)Lraykernel/ml/feature/Feature; *,+raykernel/ml/feature/Feature -.value()F 0 12hasNext()Zb+Lraykernel/apps/readability/code/CodeBlock;bugsFl*Lraykernel/apps/readability/code/CodeLine; SourceFileBugCountEvaluator.java!  F * *+     2 E+:#N$-*%)bE/$&0*2234056789:PK t:z6raykernel/apps/readability/misc/BugCountEvaluator.javapackage raykernel.apps.readability.misc; import raykernel.apps.readability.code.CodeBlock; import raykernel.apps.readability.code.CodeLine; public class BugCountEvaluator implements BlockEvaluator { String bug_feature_name; public BugCountEvaluator(String bug_feature_name) { this.bug_feature_name = bug_feature_name; } public float evaluateBlock(CodeBlock b) { float bugs = 0; for (CodeLine l : b) { bugs += l.getFeature(bug_feature_name).value(); } return bugs; } } PK w:#R4raykernel/apps/readability/misc/BlockEvaluator.class1 .raykernel/apps/readability/misc/BlockEvaluatorjava/lang/Object evaluateBlock.(Lraykernel/apps/readability/code/CodeBlock;)F SourceFileBlockEvaluator.javaPK t:()VCode  LineNumberTableLocalVariableTablethis;Lraykernel/apps/readability/misc/BasicReadibilityEvaluator; evaluateBlock.(Lraykernel/apps/readability/code/CodeBlock;)F )raykernel/apps/readability/code/CodeBlock iterator()Ljava/util/Iterator; java/util/Iterator next()Ljava/lang/Object;(raykernel/apps/readability/code/CodeLine ! "#toString()Ljava/lang/String;%// ')(java/lang/String *+contains(Ljava/lang/CharSequence;)Z - ./hasNext()Zb+Lraykernel/apps/readability/code/CodeBlock;ifsFl*Lraykernel/apps/readability/code/CodeLine; SourceFileBasicReadibilityEvaluator.java! /*    4 E+:N- $&$ bE,$  $(2 *44012234567PK t:y>raykernel/apps/readability/misc/BasicReadibilityEvaluator.javapackage raykernel.apps.readability.misc; import raykernel.apps.readability.code.CodeBlock; import raykernel.apps.readability.code.CodeLine; public class BasicReadibilityEvaluator implements BlockEvaluator { public float evaluateBlock(CodeBlock b) { float ifs = 0; for (CodeLine l : b) { if (l.toString().contains("//")) { ifs++; } } return ifs; } } PK L:C3" 4raykernel/apps/readability/misc/CodeFileLoader.class1w.raykernel/apps/readability/misc/CodeFileLoaderjava/lang/Object()VCode  LineNumberTableLocalVariableTablethis0Lraykernel/apps/readability/misc/CodeFileLoader;attachAuxVersions9(Ljava/util/Collection;Ljava/io/File;Ljava/lang/String;)V Signaturee(Ljava/util/Collection;Ljava/io/File;Ljava/lang/String;)VfilesLjava/util/Collection; aux_vers_dirLjava/io/File;typeLjava/lang/String;LocalVariableTypeTableBLjava/util/Collection; getCodeFiles'(Ljava/io/File;I)Ljava/util/Collection;S(Ljava/io/File;I)Ljava/util/Collection;java "!raykernel/io/FileFinder #$findAll2(Ljava/io/File;Ljava/lang/String;)Ljava/util/List;&java/util/LinkedList % )+*java/util/List ,-iterator()Ljava/util/Iterator; /10java/util/Iterator 23next()Ljava/lang/Object;5 java/io/File7(raykernel/apps/readability/code/CodeFile 69 :(Ljava/io/File;)V %< =>add(Ljava/lang/Object;)Z %@ ABsize()I /D EFhasNext()Zsrc_dir max_filesILjava/util/List;blocksLjava/util/LinkedList;fcb*Lraykernel/apps/readability/code/CodeFile; Ljava/util/List;BLjava/util/LinkedList; getSimpleName"(Ljava/io/File;)Ljava/lang/String; 4U VWgetName()Ljava/lang/String;Y$ []\java/lang/String ^_contains(Ljava/lang/CharSequence;)Z [a bcindexOf(I)Ie.class [g hiendsWith(Ljava/lang/String;)Z [k lBlengthn.java [p qr substring(II)Ljava/lang/String;nameend SourceFileCodeFileLoader.java!/*   Q    O*M%Y'N,(:,.4:6Y8:-;W-? C- & &18@!CM% >OGOHIHJ@KL&M1NOHP@KQ RSK*TL+XZ +$`=/+df+jd=+mf +jd=+j=+o & +/13!5,759?=D@ >KMFstI)tI<tIDtIuvPK L:3raykernel/apps/readability/misc/CodeFileLoader.javapackage raykernel.apps.readability.misc; import java.io.File; import java.util.Collection; import java.util.LinkedList; import java.util.List; import raykernel.apps.readability.code.CodeFile; public class CodeFileLoader { public static void attachAuxVersions(Collection files, File aux_vers_dir, String type) { } public static Collection getCodeFiles(File src_dir, int max_files) { List files = raykernel.io.FileFinder.findAll(src_dir, "java"); LinkedList blocks = new LinkedList(); for (File f : files) { //read in code blocks CodeFile cb = new CodeFile(f); blocks.add(cb); if (blocks.size() >= max_files) { break; } } return blocks; } public static String getSimpleName(File f) { String name = f.getName(); int end; if (name.contains("$")) { end = name.indexOf('$'); } else if (name.endsWith(".class")) { end = name.length() - 6; } else if (name.endsWith(".java")) { end = name.length() - 5; } else { end = name.length(); } return name.substring(0, end); } } PK w::<raykernel/apps/readability/detectors/FunctionExtractor.class16raykernel/apps/readability/detectors/FunctionExtractor#org/eclipse/jdt/core/dom/ASTVisitorparser$Lorg/eclipse/jdt/core/dom/ASTParser; codeFileModeZcurrentCodeFile*Lraykernel/apps/readability/code/CodeFile; currentFileLjava/lang/String; extractedLjava/util/LinkedList; SignatureBLjava/util/LinkedList;()VCode "org/eclipse/jdt/core/dom/ASTParser  newParser'(I)Lorg/eclipse/jdt/core/dom/ASTParser;  LineNumberTableLocalVariableTablegetAllFunctions/(Ljava/util/Collection;I)Ljava/util/Collection;(Ljava/util/Collection;I)Ljava/util/Collection; " #%java/util/Vector $" (*)java/util/Collection +,iterator()Ljava/util/Iterator; .0/java/util/Iterator 12next()Ljava/lang/Object;4(raykernel/apps/readability/code/CodeFile 6 78 getFunctions<(Lraykernel/apps/readability/code/CodeFile;)Ljava/util/List; :<;java/util/List =>addAll(Ljava/util/Collection;)Z :@ ABsize()I .D EFhasNext()Z code_filesLjava/util/Collection;maxIfe8Lraykernel/apps/readability/detectors/FunctionExtractor; functionsLjava/util/List;fLocalVariableTypeTableBLjava/util/Collection;;)(Ljava/util/Collection;I)Ljava/util/List;e(Ljava/util/Collection;I)Ljava/util/List;V java/io/File X 7Y (Ljava/io/File;)Ljava/util/List;filesLjava/io/File;&Ljava/util/Collection; " _ thish(Lraykernel/apps/readability/code/CodeFile;)Ljava/util/List; c ejava/util/LinkedList d" h  3j klgetFile()Ljava/io/File; n op getString"(Ljava/io/File;)Ljava/lang/String; r tvujava/lang/String wx toCharArray()[C z {| setSource([C)V ~  createASTO(Lorg/eclipse/core/runtime/IProgressMonitor;)Lorg/eclipse/jdt/core/dom/ASTNode;(org/eclipse/jdt/core/dom/CompilationUnit accept((Lorg/eclipse/jdt/core/dom/ASTVisitor;)Vfileast*Lorg/eclipse/jdt/core/dom/CompilationUnit;L(Ljava/io/File;)Ljava/util/List;java/lang/StringBuffer "java/io/BufferedReaderjava/io/FileReader #(Ljava/io/File;)V #(Ljava/io/Reader;)Vjava/lang/StringBuilder readLine()Ljava/lang/String; t valueOf&(Ljava/lang/Object;)Ljava/lang/String; #(Ljava/lang/String;)V append-(Ljava/lang/String;)Ljava/lang/StringBuilder; toString ,(Ljava/lang/String;)Ljava/lang/StringBuffer; Fready close java/lang/System errLjava/io/PrintStream;Could not load file: U getAbsolutePath java/io/PrintStream println java/io/IOExceptionreaderLjava/io/BufferedReader;contentLjava/lang/StringBuffer;eLjava/io/IOException;visit/(Lorg/eclipse/jdt/core/dom/MethodDeclaration;)Z *org/eclipse/jdt/core/dom/MethodDeclaration BgetStartPosition t charAt(I)C  getParent$()Lorg/eclipse/jdt/core/dom/ASTNode;(org/eclipse/jdt/core/dom/TypeDeclaration getName'()Lorg/eclipse/jdt/core/dom/SimpleName; #org/eclipse/jdt/core/dom/SimpleName  getPackage/()Lorg/eclipse/jdt/core/dom/PackageDeclaration; +org/eclipse/jdt/core/dom/PackageDeclaration !()Lorg/eclipse/jdt/core/dom/Name; org/eclipse/jdt/core/dom/Name B getLength 3 extractFunction.(II)Lraykernel/apps/readability/code/Function;(raykernel/apps/readability/code/Function. t  substring(II)Ljava/lang/String;  #9(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V d   add(Ljava/lang/Object;)Z java/lang/Exceptionmeth,Lorg/eclipse/jdt/core/dom/MethodDeclaration;starttypedec*Lorg/eclipse/jdt/core/dom/TypeDeclaration;typenpack*Lraykernel/apps/readability/code/Function; SourceFileFunctionExtractor.java!    ,   MY!M$Y&N*':)-3:-,59W-? C-"!'#4$>&A!K*4MGHMIJEKL=MN'O PMGQ=MR STMY!M$Y&N*':)-U:-,W9W-? C-".02'445>7A2K;4MZHMIJEKL=MN'O[PMZ\=MR#< *]*^D= F  `L78aC*^*+b*dYfg**+imq*qsy}M,**g"JK MN!P.Q9S>U C`LC 9 7Y@*^*b*dYfg**+mq*qsy}M,**g"Z[ ]^`+a6c;e @`L@[6 opdYNYY+M-Y,W,,:Y+-ǰAD& koqs6q=vDxFz_}4d`Ld[,\Fy+=*qd *qd +N-:-::*^*b++`:=YY+*q++`:*gWN) F#&)1:CPWm\ `LJ1:z CqPd jO OPK ;v:fs;raykernel/apps/readability/detectors/FunctionExtractor.javapackage raykernel.apps.readability.detectors; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.Collection; import java.util.LinkedList; import java.util.List; import java.util.Vector; import org.eclipse.jdt.core.dom.AST; import org.eclipse.jdt.core.dom.ASTParser; import org.eclipse.jdt.core.dom.ASTVisitor; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.MethodDeclaration; import org.eclipse.jdt.core.dom.TypeDeclaration; import raykernel.apps.readability.code.CodeFile; import raykernel.apps.readability.code.Function; public class FunctionExtractor extends ASTVisitor { private static ASTParser parser = ASTParser.newParser(AST.JLS3); public static Collection getAllFunctions(Collection code_files, int max) { FunctionExtractor fe = new FunctionExtractor(); List functions = new Vector(); for (CodeFile f : code_files) { functions.addAll(fe.getFunctions(f)); if (functions.size() > max) { break; } } return functions; } public static List getAllFunctions(Collection files, int max) { FunctionExtractor fe = new FunctionExtractor(); List functions = new Vector(); for (File f : files) { functions.addAll(fe.getFunctions(f)); if (functions.size() > max) { break; } } return functions; } private boolean codeFileMode = false; private CodeFile currentCodeFile; private String currentFile; private LinkedList extracted; private FunctionExtractor() { } private List getFunctions(CodeFile file) { codeFileMode = true; currentCodeFile = file; extracted = new LinkedList(); currentFile = getString(file.getFile()); parser.setSource(currentFile.toCharArray()); CompilationUnit ast = (CompilationUnit) parser.createAST(null); ast.accept(this); return extracted; } private List getFunctions(File file) { codeFileMode = false; currentCodeFile = null; extracted = new LinkedList(); currentFile = getString(file); parser.setSource(currentFile.toCharArray()); CompilationUnit ast = (CompilationUnit) parser.createAST(null); ast.accept(this); return extracted; } private String getString(File file) { BufferedReader reader; StringBuffer content = new StringBuffer(); try { reader = new BufferedReader(new FileReader(file)); while (reader.ready()) { content.append(reader.readLine() + "\n"); } reader.close(); } catch (IOException e) { System.err.println("Could not load file: " + file.getAbsolutePath()); } return content.toString(); } public boolean visit(MethodDeclaration meth) { int start = meth.getStartPosition(); while (true) { if (currentFile.charAt(start - 1) == ' ' || currentFile.charAt(start - 1) == '\t') { start--; } else { break; } } try { TypeDeclaration typedec = (TypeDeclaration) meth.getParent(); String type = typedec.getName().toString(); CompilationUnit n = (CompilationUnit) typedec.getParent(); String pack = n.getPackage().getName().toString(); Function f; //create new function from methodDec if (codeFileMode) { f = currentCodeFile.extractFunction(start, meth.getStartPosition() + meth.getLength()); } else { f = new Function(pack + "." + type, meth.getName().toString(), currentFile.substring(start, meth .getStartPosition() + meth.getLength())); } extracted.add(f); } catch (Exception e) { } return false; } } PK w:D>raykernel/apps/readability/detectors/NumKeyWordsDetector.class1Z8raykernel/apps/readability/detectors/NumKeyWordsDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetector()VCode  LineNumberTableLocalVariableTablethis:Lraykernel/apps/readability/detectors/NumKeyWordsDetector; featureName()Ljava/lang/String;keywords featureNames()[Ljava/lang/String;   raykernel/util/Common makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)V!2raykernel/apps/readability/code/TrainableCodeBlock # $%iterator()Ljava/util/Iterator; ')(java/util/Iterator *+next()Ljava/lang/Object;-(raykernel/apps/readability/code/CodeLine /101raykernel/apps/readability/code/CodeLineProcessor 23getWords<(Lraykernel/apps/readability/code/CodeLine;)Ljava/util/List; 5#6java/util/List8java/lang/String /: ;< isKeyWord(Ljava/lang/String;)Z '> ?@hasNext()ZB)raykernel/ml/feature/StandardValueFeature AD E(Ljava/lang/String;F)V ,G HI setFeature!(Lraykernel/ml/feature/Feature;)Vb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;l*Lraykernel/apps/readability/code/CodeLine;wordsLjava/util/List;countIwordLjava/lang/String;LocalVariableTypeTable$Ljava/util/List; SourceFileNumKeyWordsDetector.java! /*    -   2*     l+ M,":V&,N-.:64:&7:9=-AY*CF= .  "":$B&E"O*ak- HllJKgLMHNOBPQ"?RS: TUV BPWXYPK :v:s{=raykernel/apps/readability/detectors/NumKeyWordsDetector.javapackage raykernel.apps.readability.detectors; import java.util.List; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.CodeLineProcessor; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; public class NumKeyWordsDetector implements FeatureDetector { public String featureName() { return "keywords"; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; for (CodeLine l : block) { List words = CodeLineProcessor.getWords(l); int count = 0; for (String word : words) { if (CodeLineProcessor.isKeyWord(word)) { count++; } } l.setFeature(new StandardValueFeature(featureName(), count)); } } } PK w: p ?raykernel/apps/readability/detectors/AvgLineValueDetector.class1{9raykernel/apps/readability/detectors/AvgLineValueDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetectorfd&Lraykernel/ml/feature/FeatureDetector;fNameLjava/lang/String; ignoreBlanksZ)(Lraykernel/ml/feature/FeatureDetector;)VCode  ()V      featureNames()[Ljava/lang/String;  LineNumberTableLocalVariableTablethis;Lraykernel/apps/readability/detectors/AvgLineValueDetector;detector*(Lraykernel/ml/feature/FeatureDetector;Z)V(Ljava/lang/String;)V%java/lang/StringBuilder'avg $) # $+ ,-append-(Ljava/lang/String;)Ljava/lang/StringBuilder; $/ 01toString()Ljava/lang/String; 354raykernel/util/Common 67makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)V;2raykernel/apps/readability/code/TrainableCodeBlock = 89 :? @Aiterator()Ljava/util/Iterator; CEDjava/util/Iterator FGnext()Ljava/lang/Object;I(raykernel/apps/readability/code/CodeLine H/ LNMjava/lang/String O1trim LQ RSlength()I HU VW getFeature2(Ljava/lang/String;)Lraykernel/ml/feature/Feature; Y[Zraykernel/ml/feature/Feature \]value()F C_ `ahasNext()Z :c dSsizef)raykernel/ml/feature/StandardValueFeature eh i(Ljava/lang/String;F)V :k lm setFeature!(Lraykernel/ml/feature/Feature;)Vb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;totalFl*Lraykernel/apps/readability/code/CodeLine;fLraykernel/ml/feature/Feature;score SourceFileAvgLineValueDetector.java!  k#****+**2 "# #! "~(****+***2! #$%'& ( (!(  #a****+*( *+,  A$Y&(**.20  89++:M* *,< F,>:?BH:*JKP*T: %XbF^%,bn8,eY$Y&(**.gj:57 9=>-@BBEEPGUI]>gNpPQH nopqyrs-0tuP vwp!xsyzPK t:G&>raykernel/apps/readability/detectors/AvgLineValueDetector.javapackage raykernel.apps.readability.detectors; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.Feature; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; /** * Adapts a line wise detector to operate on a whole block. * * Avg value (not counting blank lines) * * @author buse * */ public class AvgLineValueDetector implements FeatureDetector { FeatureDetector fd = null; String fName; boolean ignoreBlanks = true; public AvgLineValueDetector(FeatureDetector detector) { this.fd = detector; fName = fd.featureNames()[0]; } public AvgLineValueDetector(FeatureDetector detector, boolean ignoreBlanks) { this.fd = detector; this.ignoreBlanks = ignoreBlanks; fName = fd.featureNames()[0]; } public AvgLineValueDetector(String fName) { this.fName = fName; ignoreBlanks = false; } public String[] featureNames() { return Common.makeSingletonArray("avg " + fName); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; if (fd != null) { fd.runDetector(block); } //total scores float total = 0; for (CodeLine l : block) { if (ignoreBlanks && l.toString().trim().length() == 0) //if blank, and we are ignoring them { continue; } Feature f = l.getFeature(fName); if (f != null) { total += f.value(); } } //divide by lines float score = total / block.size(); block.setFeature(new StandardValueFeature("avg " + fName, score)); } } PK w:z;;@raykernel/apps/readability/detectors/MaxWordLengthDetector.class1e:raykernel/apps/readability/detectors/MaxWordLengthDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetector()VCode  LineNumberTableLocalVariableTablethisisNumber(Ljava/lang/String;)Z 1@ A> isKeyWord 9C DElength()I )G HIhasNext()ZK)raykernel/ml/feature/StandardValueFeature JM N(Ljava/lang/String;F)V P QR setFeature!(Lraykernel/ml/feature/Feature;)Vb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;maxWordLjava/lang/String; maxLengthIl*Lraykernel/apps/readability/code/CodeLine;wordsLjava/util/List;wordlenLocalVariableTypeTable$Ljava/util/List; SourceFileMaxWordLengthDetector.java! /*    -   2*   V + M"N6,$:`(.:0:6: 7 (9:;#?B6    6N FF,JY*LO B "'$?&O(R+Y-`/d0g$q {58 \ STUVWX YZ Q[\'J]^?(_XY`Z a 'J]bcdPK ;v:e55?raykernel/apps/readability/detectors/MaxWordLengthDetector.javapackage raykernel.apps.readability.detectors; import java.util.List; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.CodeLineProcessor; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; public class MaxWordLengthDetector implements FeatureDetector { public String featureName() { return "maxwordlength"; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; String maxWord = ""; //keep track of this for fun int maxLength = 0; for (CodeLine l : block) { List words = CodeLineProcessor.getWords(l); for (String word : words) { if (CodeLineProcessor.isNumber(word) || CodeLineProcessor.isKeyWord(word)) { continue; } int len = word.length(); if (len > maxLength) { maxLength = len; maxWord = word; } } } block.setFeature(new StandardValueFeature(featureName(), maxLength)); //io.Out.println("max word = " + maxWord + " - " + maxLength); } }PK w:;:raykernel/apps/readability/detectors/JavaDocDetector.class1=4raykernel/apps/readability/detectors/JavaDocDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetector()VCode  LineNumberTableLocalVariableTablethis6Lraykernel/apps/readability/detectors/JavaDocDetector; featureName()Ljava/lang/String;javaDoc featureNames()[Ljava/lang/String;   raykernel/util/Common makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)V!2raykernel/apps/readability/code/TrainableCodeBlock#;raykernel/apps/readability/detectors/RegularFeatureDetector "% &(Ljava/lang/String;)V(/\*\*(?:.|[\n\r])*?\*/ *,+java/util/regex/Pattern -.compile-(Ljava/lang/String;)Ljava/util/regex/Pattern; "0 12 addPattern(Ljava/util/regex/Pattern;)V "4 b Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;commentDetector=Lraykernel/apps/readability/detectors/RegularFeatureDetector; SourceFileJavaDocDetector.java! /*    -   2*   x + M"Y*$N-')/-,3  *  56789:;()VCode  LineNumberTableLocalVariableTablethis ?< isKeyWord 7A BClength()I 'E FGhasNext()ZI)raykernel/ml/feature/StandardValueFeature HK L(Ljava/lang/String;F)V N OP setFeature!(Lraykernel/ml/feature/Feature;)Vb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock; totalWordsF totalLengthl*Lraykernel/apps/readability/code/CodeLine;wordsLjava/util/List;wordLjava/lang/String;LocalVariableTypeTable$Ljava/util/List; SourceFileAvgWordLengthDetector.java! /*    -   2*   > + M F 8,":Z&,:.:4: 1 &7:9=% bF@b8 DD,HY*%nJM : "&$>&N(Q+U,`$j t03 RQRSTUV ~WVKXY&DZ[>"\]^ &DZ_`aPK ;v:Bem?raykernel/apps/readability/detectors/AvgWordLengthDetector.javapackage raykernel.apps.readability.detectors; import java.util.List; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.CodeLineProcessor; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; public class AvgWordLengthDetector implements FeatureDetector { public String featureName() { return "avg identifier length"; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; float totalWords = 0; float totalLength = 0; for (CodeLine l : block) { List words = CodeLineProcessor.getWords(l); for (String word : words) { if (CodeLineProcessor.isNumber(word) || CodeLineProcessor.isKeyWord(word)) { continue; } totalWords++; totalLength += word.length(); } } block.setFeature(new StandardValueFeature(featureName(), totalLength / totalWords)); //io.Out.println("avg word len = " + totalLength/totalWords); } } PK w:=AA:raykernel/apps/readability/detectors/DensityDetector.class1Y4raykernel/apps/readability/detectors/DensityDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetector()VCode  LineNumberTableLocalVariableTablethis6Lraykernel/apps/readability/detectors/DensityDetector; featureName()Ljava/lang/String;density featureNames()[Ljava/lang/String;   raykernel/util/Common makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)V!2raykernel/apps/readability/code/TrainableCodeBlock # $%iterator()Ljava/util/Iterator; ')(java/util/Iterator *+next()Ljava/lang/Object;-(raykernel/apps/readability/code/CodeLine / 01getLines(II)Ljava/util/Iterator; ,3 4toString 687java/lang/String 9:length()I '< =>hasNext()Z@)raykernel/ml/feature/StandardValueFeature ?B C(Ljava/lang/String;F)V ,E FG setFeature!(Lraykernel/ml/feature/Feature;)Vb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;startIendl*Lraykernel/apps/readability/code/CodeLine;totalFlinesLjava/util/Iterator;LocalVariableTypeTable@Ljava/util/Iterator; SourceFileDensityDetector.java! /*    -   2*    l+ M>6,":P&,: 8,.:&,25b8;?Y*AD; 2   !##,$/&E$O)ak, RllHIgJKdLM aNM AOP#>QR,5STU ,5SVWXPK ;v:7a9raykernel/apps/readability/detectors/DensityDetector.javapackage raykernel.apps.readability.detectors; import java.util.Iterator; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; public class DensityDetector implements FeatureDetector { public String featureName() { return "density"; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; int start = -2; int end = 2; for (CodeLine l : block) { float total = 0; Iterator lines = block.getLines(start, end); while (lines.hasNext()) { total += lines.next().toString().length(); } l.setFeature(new StandardValueFeature(featureName(), total)); } } }PK w:1':raykernel/apps/readability/detectors/NumNumsDetector.class1Z4raykernel/apps/readability/detectors/NumNumsDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetector()VCode  LineNumberTableLocalVariableTablethis6Lraykernel/apps/readability/detectors/NumNumsDetector; featureName()Ljava/lang/String;numbers featureNames()[Ljava/lang/String;   raykernel/util/Common makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)V!2raykernel/apps/readability/code/TrainableCodeBlock # $%iterator()Ljava/util/Iterator; ')(java/util/Iterator *+next()Ljava/lang/Object;-(raykernel/apps/readability/code/CodeLine /101raykernel/apps/readability/code/CodeLineProcessor 23getWords<(Lraykernel/apps/readability/code/CodeLine;)Ljava/util/List; 5#6java/util/List8java/lang/String /: ;<isNumber(Ljava/lang/String;)Z '> ?@hasNext()ZB)raykernel/ml/feature/StandardValueFeature AD E(Ljava/lang/String;F)V ,G HI setFeature!(Lraykernel/ml/feature/Feature;)Vb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;l*Lraykernel/apps/readability/code/CodeLine;wordsLjava/util/List;countIwordLjava/lang/String;LocalVariableTypeTable$Ljava/util/List; SourceFileNumNumsDetector.java! /*    -   2*     l+ M,":V&,N-.:64:&7:9=-AY*CF= . !"#:%B'E#O,ak/ HllJKgLMHNOBPQ"?RS: TUV BPWXYPK ;v:1H  9raykernel/apps/readability/detectors/NumNumsDetector.javapackage raykernel.apps.readability.detectors; import java.util.List; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.CodeLineProcessor; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; public class NumNumsDetector implements FeatureDetector { public String featureName() { return "numbers"; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; for (CodeLine l : block) { List words = CodeLineProcessor.getWords(l); int count = 0; for (String word : words) { if (CodeLineProcessor.isNumber(word)) { count++; } } l.setFeature(new StandardValueFeature(featureName(), count)); } } }PK w:Araykernel/apps/readability/detectors/NearestFeatureDetector.class1f;raykernel/apps/readability/detectors/NearestFeatureDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetectorMAXDISTI ConstantValue2detector&Lraykernel/ml/feature/FeatureDetector;nameLjava/lang/String;ceil_inc(I)ICodeLineNumberTableLocalVariableTablei;(Lraykernel/ml/feature/FeatureDetector;Ljava/lang/String;)V  ()V   this=Lraykernel/apps/readability/detectors/NearestFeatureDetector; featureName()Ljava/lang/String; featureNames()[Ljava/lang/String; % ! ')(raykernel/util/Common *+makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)V/2raykernel/apps/readability/code/TrainableCodeBlock 1 ,- .3 45iterator()Ljava/util/ListIterator; 798java/util/ListIterator :;next()Ljava/lang/Object;=(raykernel/apps/readability/code/CodeLine ? "# <A BC getFeature2(Ljava/lang/String;)Lraykernel/ml/feature/Feature; EGFraykernel/ml/feature/Feature HIvalue()FK)raykernel/ml/feature/StandardValueFeature JM N(Ljava/lang/String;F)V <P QR setFeature!(Lraykernel/ml/feature/Feature;)V T  7V WXhasNext()Zb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;iterLjava/util/ListIterator;distLastCommentcl*Lraykernel/apps/readability/code/CodeLine;LocalVariableTypeTableDLjava/util/ListIterator; SourceFileNearestFeatureDetector.java!  ? 2  Y**+*,!# $%    !/*) "#2*$&. ,-e+.M*,0,2N26C-6<:*>2@D 6JY*LOS6-U2 368:=?&A>CAFTH[=dc>eeYZ`[\Q]^M_&5`ab Q]cdePK ;v:@raykernel/apps/readability/detectors/NearestFeatureDetector.javapackage raykernel.apps.readability.detectors; import java.util.ListIterator; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; /** * Creates a Nearest-Feautre Decector from a regular Feature Detector * * @author rlb7g * */ public class NearestFeatureDetector implements FeatureDetector { static final int MAXDIST = 50; static int ceil_inc(int i) { if (i == MAXDIST) return i; return ++i; } FeatureDetector detector; String name; public NearestFeatureDetector(FeatureDetector detector, String name) { this.detector = detector; this.name = name; } public String featureName() { return name; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; //first run the original detector detector.runDetector(block); ListIterator iter = block.iterator(); int distLastComment = MAXDIST; //forward while (iter.hasNext()) { CodeLine cl = iter.next(); if (cl.getFeature(detector.featureNames()[0]).value() > 0) { distLastComment = 0; } cl.setFeature(new StandardValueFeature(name, distLastComment)); distLastComment = ceil_inc(distLastComment); } /* distLastComment = MAXDIST; //reverse while( iter.hasPrevious() ) { CodeLine cl = iter.previous(); //if this line has a comment if( cl.getFeature(detector.featureName()).value() > 0 ) { distLastComment = 0; } float current = cl.getFeature(name).value(); if( distLastComment < current ) cl.setFeature( new StandardValueFeature(name, distLastComment) ); distLastComment = ceil_inc(distLastComment); } */ } } PK w:  Draykernel/apps/readability/detectors/MaxOccurencesOfSingleWord.class1a>raykernel/apps/readability/detectors/MaxOccurencesOfSingleWordjava/lang/Object$raykernel/ml/feature/FeatureDetector()VCode  LineNumberTableLocalVariableTablethis@Lraykernel/apps/readability/detectors/MaxOccurencesOfSingleWord; featureName()Ljava/lang/String;max word featureNames()[Ljava/lang/String;   raykernel/util/Common makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)V!2raykernel/apps/readability/code/TrainableCodeBlock#raykernel/util/WordCounter " & '(iterator()Ljava/util/Iterator; *,+java/util/Iterator -.next()Ljava/lang/Object;0(raykernel/apps/readability/code/CodeLine 2431raykernel/apps/readability/code/CodeLineProcessor 56getWords<(Lraykernel/apps/readability/code/CodeLine;)Ljava/util/List; 8&9java/util/List;java/lang/String "= >? countWord(Ljava/lang/String;)V *A BChasNext()ZE)raykernel/ml/feature/StandardValueFeature "G HI getMaxVal()I DK L(Ljava/lang/String;F)V N OP setFeature!(Lraykernel/ml/feature/Feature;)Vb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;counterLraykernel/util/WordCounter;l*Lraykernel/apps/readability/code/CodeLine;wordsLjava/util/List;wLjava/lang/String;LocalVariableTypeTable$Ljava/util/List; SourceFileMaxOccurencesOfSingleWord.java! /*    -   2*     p+ M"Y$N,%:>)/:1:7:)::-<@@,DY*-FJM *  "")$A&G$Q [*o. HppQRkST cUV"/WX)(YZA[\] )(Y^_`PK ;v:XCraykernel/apps/readability/detectors/MaxOccurencesOfSingleWord.javapackage raykernel.apps.readability.detectors; import java.util.List; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.CodeLineProcessor; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; import raykernel.util.WordCounter; public class MaxOccurencesOfSingleWord implements FeatureDetector { public String featureName() { return "max word"; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; WordCounter counter = new WordCounter(); for (CodeLine l : block) { List words = CodeLineProcessor.getWords(l); for (String w : words) { counter.countWord(w); } } block.setFeature(new StandardValueFeature(featureName(), counter.getMaxVal())); //io.Out.println("max word: " + counter.getMaxWord() + " - " + counter.getMaxVal() ); } }PK w:\ߠfDraykernel/apps/readability/detectors/MaxOccurencesOfSingleChar.class1S>raykernel/apps/readability/detectors/MaxOccurencesOfSingleCharjava/lang/Object$raykernel/ml/feature/FeatureDetector()VCode  LineNumberTableLocalVariableTablethis@Lraykernel/apps/readability/detectors/MaxOccurencesOfSingleChar; featureName()Ljava/lang/String;max char featureNames()[Ljava/lang/String;   raykernel/util/Common makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)V!2raykernel/apps/readability/code/TrainableCodeBlock#raykernel/util/CharCounter " & '(iterator()Ljava/util/Iterator; *,+java/util/Iterator -.next()Ljava/lang/Object;0(raykernel/apps/readability/code/CodeLine /2 3toString "5 67count(Ljava/lang/String;)V *9 :;hasNext()Z=)raykernel/ml/feature/StandardValueFeature "? @A getMaxVal()I <C D(Ljava/lang/String;F)V F GH setFeature!(Lraykernel/ml/feature/Feature;)Vb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;counterLraykernel/util/CharCounter;l*Lraykernel/apps/readability/code/CodeLine; SourceFileMaxOccurencesOfSingleChar.java! /*    -   2*   J+ M"Y$N,%:)/:-148,BE  "+5"I% 4JJIJEKL =MN" OPQRPK t:Craykernel/apps/readability/detectors/MaxOccurencesOfSingleChar.javapackage raykernel.apps.readability.detectors; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.CharCounter; import raykernel.util.Common; public class MaxOccurencesOfSingleChar implements FeatureDetector { public String featureName() { return "max char"; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; CharCounter counter = new CharCounter(); for (CodeLine l : block) { counter.count(l.toString()); } block.setFeature(new StandardValueFeature(featureName(), counter.getMaxVal())); //io.Out.println("max char: " + counter.getMaxChar() + " - " + counter.getMaxVal() ); } } PK w:,8raykernel/apps/readability/detectors/BloatDetector.class1N2raykernel/apps/readability/detectors/BloatDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetectorccd8Lraykernel/apps/readability/detectors/CharCountDetector;dcddd6Lraykernel/apps/readability/detectors/DensityDetector;id5Lraykernel/apps/readability/detectors/IndentDetector;lld9Lraykernel/apps/readability/detectors/LineLengthDetector;()VCode  3raykernel/apps/readability/detectors/IndentDetector   7raykernel/apps/readability/detectors/LineLengthDetector    4raykernel/apps/readability/detectors/DensityDetector  # %6raykernel/apps/readability/detectors/CharCountDetector $' (([C)V *  , LineNumberTableLocalVariableTablethis4Lraykernel/apps/readability/detectors/BloatDetector; featureName()Ljava/lang/String;4bloat featureNames()[Ljava/lang/String; 8 12 :<;raykernel/util/Common =>makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)VB2raykernel/apps/readability/code/TrainableCodeBlock D ?@ D D $Db Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock; SourceFileBloatDetector.java!  L**Y*Y*Y!"*$YY,U&)*$YY.U&+-%8K. L/012-3-". /0562*79-'. /0?@.+AM*,C*,E*",F*),G*+,G-+- ./0%1-3. ./0.HI)JKLMPK t:$з7raykernel/apps/readability/detectors/BloatDetector.javapackage raykernel.apps.readability.detectors; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.Trainable; import raykernel.util.Common; /** * Detects features associated with "code bloat" * * @author rlb7g * */ public class BloatDetector implements FeatureDetector { CharCountDetector ccd; CharCountDetector dcd; DensityDetector dd; IndentDetector id; LineLengthDetector lld; public BloatDetector() { id = new IndentDetector(); lld = new LineLengthDetector(); dd = new DensityDetector(); ccd = new CharCountDetector(','); dcd = new CharCountDetector('.'); } public String featureName() { return "bloat"; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; id.runDetector(block); lld.runDetector(block); dd.runDetector(block); ccd.runDetector(block); dcd.runDetector(block); } } PK w:-@=raykernel/apps/readability/detectors/LineLengthDetector.class1S7raykernel/apps/readability/detectors/LineLengthDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetector()VCode  LineNumberTableLocalVariableTablethis9Lraykernel/apps/readability/detectors/LineLengthDetector; featureName()Ljava/lang/String; line length featureNames()[Ljava/lang/String;   raykernel/util/Common makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)V!2raykernel/apps/readability/code/TrainableCodeBlock # $%iterator()Ljava/util/ListIterator; ')(java/util/Iterator *+next()Ljava/lang/Object;-(raykernel/apps/readability/code/CodeLine/)raykernel/ml/feature/StandardValueFeature ,1 2toString 465java/lang/String 7trim 49 :;length()I .= >(Ljava/lang/String;F)V ,@ AB setFeature!(Lraykernel/ml/feature/Feature;)V 'D EFhasNext()Zb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;iterLjava/util/Iterator;l*Lraykernel/apps/readability/code/CodeLine;LocalVariableTypeTable@Ljava/util/Iterator; SourceFileLineLengthDetector.java! /*    -   2*   >+ M,"N*-&,:.Y*038<?-Cӱ    4=# 4>>GH9IJ 4KLMNO  4KPQRPK ;v:lXX<raykernel/apps/readability/detectors/LineLengthDetector.javapackage raykernel.apps.readability.detectors; import java.util.Iterator; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; public class LineLengthDetector implements FeatureDetector { public String featureName() { return "line length"; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; Iterator iter = block.iterator(); while (iter.hasNext()) { CodeLine l = iter.next(); l.setFeature(new StandardValueFeature(featureName(), l.toString().trim().length())); } } } PK w:(<raykernel/apps/readability/detectors/WordCountDetector.class1S6raykernel/apps/readability/detectors/WordCountDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetector()VCode  LineNumberTableLocalVariableTablethis8Lraykernel/apps/readability/detectors/WordCountDetector; featureName()Ljava/lang/String;idents featureNames()[Ljava/lang/String;   raykernel/util/Common makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)V!2raykernel/apps/readability/code/TrainableCodeBlock # $%iterator()Ljava/util/Iterator; ')(java/util/Iterator *+next()Ljava/lang/Object;-(raykernel/apps/readability/code/CodeLine /101raykernel/apps/readability/code/CodeLineProcessor 23getWords<(Lraykernel/apps/readability/code/CodeLine;)Ljava/util/List;5)raykernel/ml/feature/StandardValueFeature 798java/util/List :;size()I 4= >(Ljava/lang/String;F)V ,@ AB setFeature!(Lraykernel/ml/feature/Feature;)V 'D EFhasNext()Zb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;l*Lraykernel/apps/readability/code/CodeLine;wordsLjava/util/List;LocalVariableTypeTable$Ljava/util/List; SourceFileWordCountDetector.java! /*    -   2*   A+ M,":+&,N-.:-4Y*6<?Cѱ  6@# 4AAGH<IJKLMNO MPQRPK ;v:#;raykernel/apps/readability/detectors/WordCountDetector.javapackage raykernel.apps.readability.detectors; import java.util.List; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.CodeLineProcessor; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; public class WordCountDetector implements FeatureDetector { public String featureName() { return "idents"; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; for (CodeLine l : block) { List words = CodeLineProcessor.getWords(l); l.setFeature(new StandardValueFeature(featureName(), words.size())); } } } PK w:躭G G ;raykernel/apps/readability/detectors/FunctionDetector.class1v5raykernel/apps/readability/detectors/FunctionDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetector()VCode  LineNumberTableLocalVariableTablethis7Lraykernel/apps/readability/detectors/FunctionDetector;netDepthChange(Ljava/lang/String;)I java/lang/String charAt(I)C  length()IsLjava/lang/String;retIi featureName()Ljava/lang/String;$fun featureNames()[Ljava/lang/String; ( !" *,+raykernel/util/Common -.makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)V22raykernel/apps/readability/code/TrainableCodeBlock 14 56iterator()Ljava/util/ListIterator; 8:9java/util/ListIterator ;<next()Ljava/lang/Object;>(raykernel/apps/readability/code/CodeLine =@ A"toString C E)raykernel/ml/feature/StandardValueFeatureGdepth DI J(Ljava/lang/String;F)V =L MN setFeature!(Lraykernel/ml/feature/Feature;)VPclass 8R SThasNext()Z 8V W<previous =Y Z[ getFeature2(Ljava/lang/String;)Lraykernel/ml/feature/Feature; ]_^raykernel/ml/feature/Feature `avalue()F 8c dT hasPreviousb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;F class_lenfun_leniterLjava/util/ListIterator;l*Lraykernel/apps/readability/code/CodeLine;curr_class_len curr_fun_lenLocalVariableTypeTableDLjava/util/ListIterator; SourceFileFunctionDetector.java! /*     .<= *{*}* " "!,& .,( !" -# + %& 2*') 0 /0 S +1M F 8 8,3:z7=:%?BbF% 8 8 %  8%  b8%  b8DYF%HKDYOHKDY#HKQ 8 8sU=:OX\8#X\8   8  88  8DYOHKDY#HKb '467 8 :=?"@.B4D7E=GCIFLLNRPXR^VmW}X=[\_acdfhkmpruwz{_ p efghGi ji kilm"knodnoXpiLqi r lstuPK ;v:dٰ:raykernel/apps/readability/detectors/FunctionDetector.javapackage raykernel.apps.readability.detectors; import java.util.ListIterator; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; /** * I belive this is theroetically impossible to do with regular expressions * * @author rlb7g * */ public class FunctionDetector implements FeatureDetector { public static int netDepthChange(String s) { int ret = 0; for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == '{') { ret++; } if (s.charAt(i) == '}') { ret--; } } return ret; } public String featureName() { return "fun"; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; float depth = 0; float class_len = 0; float fun_len = 0; ListIterator iter = block.iterator(); //forward while (iter.hasNext()) { CodeLine l = iter.next(); depth += netDepthChange(l.toString()); if (depth == 0) { class_len = 0; fun_len = 0; } else if (depth == 1) { fun_len = 0; } if (depth > 0) { class_len++; if (depth > 1) { fun_len++; } } l.setFeature(new StandardValueFeature("depth", depth)); l.setFeature(new StandardValueFeature("class", class_len)); l.setFeature(new StandardValueFeature("fun", fun_len)); } class_len = 0; fun_len = 0; //reverse while (iter.hasPrevious()) { CodeLine l = iter.previous(); float curr_class_len = l.getFeature("class").value(); float curr_fun_len = l.getFeature("fun").value(); if (curr_class_len == 0) { class_len = 0; } if (curr_fun_len == 0) { fun_len = 0; } if (curr_class_len > class_len) { class_len = curr_class_len; } if (curr_fun_len > fun_len) { fun_len = curr_fun_len; } l.setFeature(new StandardValueFeature("class", class_len)); l.setFeature(new StandardValueFeature("fun", fun_len)); } } } PK w:rߣ  Araykernel/apps/readability/detectors/RegularFeatureDetector.class1k;raykernel/apps/readability/detectors/RegularFeatureDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetectornameLjava/lang/String;patternsLjava/util/LinkedList; Signature1Ljava/util/LinkedList;(Ljava/util/regex/Pattern;)VCode  ()Vjava/util/LinkedList     addPattern java/util/regex/Pattern  toString()Ljava/lang/String; " LineNumberTableLocalVariableTablethis=Lraykernel/apps/readability/detectors/RegularFeatureDetector;pLjava/util/regex/Pattern;(Ljava/lang/String;)V + ,-add(Ljava/lang/Object;)Z featureName featureNames()[Ljava/lang/String; 2 . 465raykernel/util/Common 78makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)V<2raykernel/apps/readability/code/TrainableCodeBlock ;> ?@iterator()Ljava/util/ListIterator; BDCjava/util/Iterator EFnext()Ljava/lang/Object;H(raykernel/apps/readability/code/CodeLineJ#raykernel/ml/feature/RegularFeature IL M(Ljava/lang/String;Z)V GO PQ setFeature!(Lraykernel/ml/feature/Feature;)V BS TUhasNext()Z W ?X()Ljava/util/Iterator; ;Z [\ linesMatching/(Ljava/util/regex/Pattern;)Ljava/util/Iterator;b Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;iterLjava/util/Iterator;l*Lraykernel/apps/readability/code/CodeLine; patern_iterLocalVariableTypeTable@Ljava/util/Iterator;/Ljava/util/Iterator; SourceFileRegularFeatureDetector.java!    a**Y*+*+!#$%&'( )U**Y*+!# !"$%&B *+*W# & '$ %& '(. /*!#+$ %&/02*13#0$ %&9:L+;M,=N-AG:IY*!KN-R*V:>A:,YN-AG:IY*!KN-RR#B57 8 :;)82?;@>BJDQETG_HpEy@L$R%&]^_` zabcd;IebJ/'(_cdf zag;IehijPK ;v:tvPP@raykernel/apps/readability/detectors/RegularFeatureDetector.javapackage raykernel.apps.readability.detectors; import java.util.Iterator; import java.util.LinkedList; import java.util.regex.Pattern; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.RegularFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; public class RegularFeatureDetector implements FeatureDetector { //Name of this set of patterns String name; //the pattern thid detector is looking for LinkedList patterns; RegularFeatureDetector(Pattern p) { patterns = new LinkedList(); addPattern(p); name = p.toString(); } public RegularFeatureDetector(String name) { patterns = new LinkedList(); this.name = name; } public void addPattern(Pattern p) { patterns.add(p); } public String featureName() { return name; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; //first set all to false Iterator iter = block.iterator(); while (iter.hasNext()) { CodeLine l = iter.next(); l.setFeature(new RegularFeature(name, false)); } //for each pattern Iterator patern_iter = patterns.iterator(); while (patern_iter.hasNext()) { Pattern p = patern_iter.next(); iter = block.linesMatching(p); while (iter.hasNext()) { CodeLine l = iter.next(); l.setFeature(new RegularFeature(name, true)); } } } } PK w:p\{T T Araykernel/apps/readability/detectors/PercentOfLinesDetector.class1;raykernel/apps/readability/detectors/PercentOfLinesDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetectorfd&Lraykernel/ml/feature/FeatureDetector; ignoreBlanksZ predicateLraykernel/util/Predicate; SignatureFLraykernel/util/Predicate;*(Lraykernel/ml/feature/FeatureDetector;Z)VCode  ()V     LineNumberTableLocalVariableTablethis=Lraykernel/apps/readability/detectors/PercentOfLinesDetector;(Lraykernel/util/Predicate;Z)VJ(Lraykernel/util/Predicate;Z)VLocalVariableTypeTable featureName()Ljava/lang/String;%java/lang/StringBuilder' percent wtih $) *(Ljava/lang/String;)V , -. featureNames()[Ljava/lang/String; $0 12append-(Ljava/lang/String;)Ljava/lang/StringBuilder; $4 5#toString 7 "# 9;:raykernel/util/Common <=makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)VA2raykernel/apps/readability/code/TrainableCodeBlock C >? @E FGiterator()Ljava/util/Iterator; IKJjava/util/Iterator LMnext()Ljava/lang/Object;O(raykernel/apps/readability/code/CodeLine N4 RTSjava/lang/String U#trim RW XYlength()I N[ \] getFeature2(Ljava/lang/String;)Lraykernel/ml/feature/Feature; _a`raykernel/ml/feature/Feature bcvalue()F egfraykernel/util/Predicate hi getBoolean(Ljava/lang/Object;)Z Ik lmhasNext()Zo)raykernel/ml/feature/StandardValueFeature nq r(Ljava/lang/String;F)V @t uv setFeature!(Lraykernel/ml/feature/Feature;)Vb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;countAllIcountHasFeaturel*Lraykernel/apps/readability/code/CodeLine;fLraykernel/ml/feature/Feature;percentF SourceFilePercentOfLinesDetector.java!  t*****+*     *****+* !"#   !  "#E$Y&(*+2/3' -.2*68, >?^+@M*,B>6,D:pHN:*PQVL*+2Z:*^ **djn8,nY*6psF02457)9>;A>S@iBoDFI7LNORwxyz{|}|)a~S7PK t:"tt@raykernel/apps/readability/detectors/PercentOfLinesDetector.javapackage raykernel.apps.readability.detectors; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.Feature; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; import raykernel.util.Predicate; /** * Percent of lines in the block satisfying the predicate or with feature * * @author buse * */ public class PercentOfLinesDetector implements FeatureDetector { FeatureDetector fd = null; boolean ignoreBlanks = false; Predicate predicate = null; public PercentOfLinesDetector(FeatureDetector fd, boolean ignoreBlanks) { this.fd = fd; this.ignoreBlanks = ignoreBlanks; } public PercentOfLinesDetector(Predicate predicate, boolean ignoreBlanks) { this.predicate = predicate; this.ignoreBlanks = ignoreBlanks; } public String featureName() { return "percent wtih " + fd.featureNames()[0]; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; fd.runDetector(block); int countAll = 0; int countHasFeature = 0; for (CodeLine l : block) { if (ignoreBlanks && l.toString().trim().length() == 0) //if blank, and we are ignoring them { continue; } Feature f = l.getFeature(fd.featureNames()[0]); if (f != null && fd != null && f.value() > 0) { countHasFeature++; } else if (predicate != null && predicate.getBoolean(l)) { countHasFeature++; } countAll++; } float percent = (float) countHasFeature / (float) countAll; block.setFeature(new StandardValueFeature(featureName(), percent)); } } PK w:dQ44<raykernel/apps/readability/detectors/BlankLineDetector.class1Q6raykernel/apps/readability/detectors/BlankLineDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetector()VCode  LineNumberTableLocalVariableTablethis8Lraykernel/apps/readability/detectors/BlankLineDetector; featureName()Ljava/lang/String; blank lines featureNames()[Ljava/lang/String;   raykernel/util/Common makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)V!2raykernel/apps/readability/code/TrainableCodeBlock # $%iterator()Ljava/util/Iterator; ')(java/util/Iterator *+next()Ljava/lang/Object;-(raykernel/apps/readability/code/CodeLine ,/ 0toString 243java/lang/String 5trim 27 89length()I;)raykernel/ml/feature/StandardValueFeature := >(Ljava/lang/String;Z)V ,@ AB setFeature!(Lraykernel/ml/feature/Feature;)V 'D EFhasNext()Zb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;l*Lraykernel/apps/readability/code/CodeLine;blankZ SourceFileBlankLineDetector.java! /*    -   2*   I+ M,":3&,N-.166-:Y*<?Cɱ ->H 4IIGHDIJ%KL-MNOPPK t:E22;raykernel/apps/readability/detectors/BlankLineDetector.javapackage raykernel.apps.readability.detectors; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; public class BlankLineDetector implements FeatureDetector { public String featureName() { return "blank lines"; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; for (CodeLine l : block) { boolean blank = l.toString().trim().length() == 0; l.setFeature(new StandardValueFeature(featureName(), blank)); } } } PK w:?  >raykernel/apps/readability/detectors/SubstrCountDetector.class1u8raykernel/apps/readability/detectors/SubstrCountDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetectornameLjava/lang/String;strs[Ljava/lang/String;([Ljava/lang/String;)VCode  ()V  java/lang/StringBuffer  (Ljava/lang/String;)V '  append,(Ljava/lang/String;)Ljava/lang/StringBuffer;!' # $%toString()Ljava/lang/String; ' LineNumberTableLocalVariableTablethis:Lraykernel/apps/readability/detectors/SubstrCountDetector;tmpnameLjava/lang/StringBuffer;scount(Ljava/lang/String;)I 243java/lang/String 56indexOf(Ljava/lang/String;I)I 28 9:length()IIstr lastFound featureName featureNames()[Ljava/lang/String; B >% DFEraykernel/util/Common GHmakeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)VL2raykernel/apps/readability/code/TrainableCodeBlock KN OPiterator()Ljava/util/ListIterator; RTSjava/util/Iterator UVnext()Ljava/lang/Object;X(raykernel/apps/readability/code/CodeLineZ)raykernel/ml/feature/StandardValueFeature W# ] /0 Y_ `(Ljava/lang/String;F)V Wb cd setFeature!(Lraykernel/ml/feature/Feature;)V Rf ghhasNext()Zb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;iterLjava/util/Iterator;l*Lraykernel/apps/readability/code/CodeLine;LocalVariableTypeTable@Ljava/util/Iterator; SourceFileSubstrCountDetector.java!   M**+YM+Y:66 2N,W,-W, W*,"&(*  &-3:D L")*M*+M :,-&./0 G=*Y:66/2N6+-16-7`6(. &(*.$0)2,6/78,;(E<)4G*+G.E/;#< =;>% /*&(A) *+?@ 2*AC(F) *+IJ <+KM,MN(-QW:YY*&*[\^a-eձ(JL M OP2M;S)4<*+<ij7kl 2mnopq  2mrstPK ;v:.mm=raykernel/apps/readability/detectors/SubstrCountDetector.javapackage raykernel.apps.readability.detectors; import java.util.Iterator; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; public class SubstrCountDetector implements FeatureDetector { String name; String[] strs; public SubstrCountDetector(String... strs) { this.strs = strs; //only figure out the name once StringBuffer tmpname = new StringBuffer(""); for (String s : strs) { tmpname.append(" '"); tmpname.append(s); tmpname.append("'"); } name = tmpname.toString(); } int count(String s) { int count = 0; for (String str : strs) //for each string we're looking for { int lastFound = 0; while (true) { lastFound = s.indexOf(str, lastFound); //find next occurance if (lastFound < 0) //keep going til we dont find another { break; } else { count++; //found one lastFound += str.length(); } } } return count; } public String featureName() { return name; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; Iterator iter = block.iterator(); while (iter.hasNext()) { CodeLine l = iter.next(); l.setFeature(new StandardValueFeature(name, count(l.toString()))); } } } PK w:X?raykernel/apps/readability/detectors/MaxLineValueDetector.class1f9raykernel/apps/readability/detectors/MaxLineValueDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetectorfd&Lraykernel/ml/feature/FeatureDetector;)(Lraykernel/ml/feature/FeatureDetector;)VCode  ()V  LineNumberTableLocalVariableTablethis;Lraykernel/apps/readability/detectors/MaxLineValueDetector; featureName()Ljava/lang/String;java/lang/StringBuildermax  (Ljava/lang/String;)V  ! featureNames()[Ljava/lang/String; # $%append-(Ljava/lang/Object;)Ljava/lang/StringBuilder; ' (toString *  ,.-raykernel/util/Common /0makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)V42raykernel/apps/readability/code/TrainableCodeBlock 6 12 38 9:iterator()Ljava/util/Iterator; <>=java/util/Iterator ?@next()Ljava/lang/Object;B(raykernel/apps/readability/code/CodeLine AD EF getFeature2(Ljava/lang/String;)Lraykernel/ml/feature/Feature; HJIraykernel/ml/feature/Feature KLvalue()F <N OPhasNext()ZR)raykernel/ml/feature/StandardValueFeature QT U(Ljava/lang/String;F)V 3W XY setFeature!(Lraykernel/ml/feature/Feature;)Vb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;maxFl*Lraykernel/apps/readability/code/CodeLine;fLraykernel/ml/feature/Feature; SourceFileMaxLineValueDetector.java!  O* **+  CY*"&  ! 2*)+ 12 h+3M*,5 F,7:6;A:*2C:G% GFM,QY*)%SV. "$&&(8*=,G.M&W3g4>hhZ[c\]W^_&'`a8bcdePK t:׵bb>raykernel/apps/readability/detectors/MaxLineValueDetector.javapackage raykernel.apps.readability.detectors; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.Feature; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; public class MaxLineValueDetector implements FeatureDetector { FeatureDetector fd = null; public MaxLineValueDetector(FeatureDetector fd) { this.fd = fd; } public String featureName() { return "max " + fd.featureNames(); } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; fd.runDetector(block); float max = 0; for (CodeLine l : block) { Feature f = l.getFeature(fd.featureNames()[0]); if (f != null) { if (f.value() > max) { max = f.value(); } } } block.setFeature(new StandardValueFeature(featureName(), max)); } } PK w: Eraykernel/apps/readability/detectors/FunctionReturnTypeDetector.class1?raykernel/apps/readability/detectors/FunctionReturnTypeDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetector()VCode  LineNumberTableLocalVariableTablethisALraykernel/apps/readability/detectors/FunctionReturnTypeDetector;getFloatForReturnType(Ljava/lang/String;)Fvoid java/lang/String equals(Ljava/lang/Object;)Zbooleanintfloat!char#double@@typeLjava/lang/String; getRetType&(Ljava/lang/String;)Ljava/lang/String;*java/util/StringTokenizer, ()/\* ). /'(Ljava/lang/String;Ljava/lang/String;)V )1 23 nextToken()Ljava/lang/String;5public7private9 protected;static )= >? hasMoreTokens()Zdef tokenizerLjava/util/StringTokenizer;tokennetDepthChange(Ljava/lang/String;)I G HIcharAt(I)C K LMlength()IsretIi featureNameTret_type featureNames()[Ljava/lang/String; X R3 Z\[raykernel/util/Common ]^makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)Vb2raykernel/apps/readability/code/TrainableCodeBlock ad efiterator()Ljava/util/ListIterator; hjijava/util/ListIterator klnext()Ljava/lang/Object;n(raykernel/apps/readability/code/CodeLine mK mq r3toString t '( v DEx)raykernel/ml/feature/StandardValueFeature z  w| }(Ljava/lang/String;F)V m  setFeature!(Lraykernel/ml/feature/Feature;)V h ?hasNextb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;depthcurr_retiterLjava/util/ListIterator;l*Lraykernel/apps/readability/code/CodeLine;tmpLocalVariableTypeTableDLjava/util/ListIterator; SourceFileFunctionReturnTypeDetector.java! /*    {=* *'***  *" $   /8: =%& '( K)Y*+-LM/+0M,4!,6,8,: +<,, . ! #%'0(9*<#C.G/I1 K@& @AB >C&DE .<= *F{*F}*J "68:<?A!8,E .N&,OP(QPR3 -S J UV 2*WY O _` B+aM>:,c:igm:ops::pu`>wY*Wy{~wY*W {~ BSUV XZ\^-a7b<d@hKkPmhqyZu R}P z&tZ7 & tPK ;v:oa  Draykernel/apps/readability/detectors/FunctionReturnTypeDetector.javapackage raykernel.apps.readability.detectors; import java.util.ListIterator; import java.util.StringTokenizer; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; public class FunctionReturnTypeDetector implements FeatureDetector { static float getFloatForReturnType(String type) { if (type.equals("void")) return 0; if (type.equals("boolean") || type.equals("int") || type.equals("float") || type.equals("char") || type.equals("double")) return 1; return 3; } //this uses tokenizers, but it would be better (probably) to go //ahead and use regexps public static String getRetType(String def) { StringTokenizer tokenizer = new StringTokenizer(def, " \t()/\\*"); String token = null; while (tokenizer.hasMoreTokens()) { token = tokenizer.nextToken(); if (!token.equals("public") && !token.equals("private") && !token.equals("protected") && !token.equals("static")) { break; } } if (token == null) return null; return token; } static int netDepthChange(String s) { int ret = 0; for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == '{') { ret++; } if (s.charAt(i) == '}') { ret--; } } return ret; } public String featureName() { return "ret_type"; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; int depth = 0; String curr_ret = null; ListIterator iter = block.iterator(); while (iter.hasNext()) { CodeLine l = iter.next(); if (depth == 1 && l.length() > 3) //inside a class { //look for a function declairation String tmp = getRetType(l.toString()); if (tmp != null) { curr_ret = tmp; } } depth += netDepthChange(l.toString()); //depth >= 2 => we are inside a function if (depth >= 2) { l.setFeature(new StandardValueFeature(featureName(), getFloatForReturnType(curr_ret))); } else { l.setFeature(new StandardValueFeature(featureName(), 0)); } } } } PK w:qQ?raykernel/apps/readability/detectors/BasicCommentDetector.class1d9raykernel/apps/readability/detectors/BasicCommentDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetector()VCode  LineNumberTableLocalVariableTablethis;Lraykernel/apps/readability/detectors/BasicCommentDetector; featureName()Ljava/lang/String;comment featureNames()[Ljava/lang/String;   raykernel/util/Common makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)V!2raykernel/apps/readability/code/TrainableCodeBlock # $%iterator()Ljava/util/Iterator; ')(java/util/Iterator *+next()Ljava/lang/Object;-(raykernel/apps/readability/code/CodeLine ,/ 0toString 2 34updateCommentStatus(Ljava/lang/String;Z)Z 687java/lang/String 9trim;// 6= >? startsWith(Ljava/lang/String;)ZA*/ 6C DEcontains(Ljava/lang/CharSequence;)ZG)raykernel/ml/feature/StandardValueFeature FI J(Ljava/lang/String;Z)V ,L MN setFeature!(Lraykernel/ml/feature/Feature;)V 'P QRhasNext()Zb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock; inCommentZl*Lraykernel/apps/readability/code/CodeLine;\/*sLjava/lang/String;currentstartend SourceFileBasicCommentDetector.java! /*    -   2*   l+ M>,":T&,:*.1>.5:<.@B6FY*HKO "'!O"ak% >llSTgUVeWXEYZOX34 '+[B>+@B6   )*,-/#0%2 4'']^'_X `XaXbcPK t:G>raykernel/apps/readability/detectors/BasicCommentDetector.javapackage raykernel.apps.readability.detectors; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; public class BasicCommentDetector implements FeatureDetector { public String featureName() { return "comment"; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; boolean inComment = false; for (CodeLine l : block) { inComment = updateCommentStatus(l.toString(), inComment); boolean comment = l.toString().trim().startsWith("//") || inComment || l.toString().contains("*/"); l.setFeature(new StandardValueFeature(featureName(), comment)); } } boolean updateCommentStatus(String s, boolean current) { boolean start = s.contains("/*"); boolean end = s.contains("*/"); if (start && !end) return true; if (!start && end) return false; return current; } }PK :s  Craykernel/apps/readability/detectors/ReadabilityDetectorSuite.class1a=raykernel/apps/readability/detectors/ReadabilityDetectorSuitejava/lang/Objectdsuite$Lraykernel/ml/feature/DetectorSuite;()VCode  LineNumberTableLocalVariableTable  this?Lraykernel/apps/readability/detectors/ReadabilityDetectorSuite;getDefaultSuite&()Lraykernel/ml/feature/DetectorSuite;"raykernel/ml/feature/DetectorSuite 9raykernel/apps/readability/detectors/AvgLineValueDetector7raykernel/apps/readability/detectors/LineLengthDetector   )(Lraykernel/ml/feature/FeatureDetector;)V ! "add$6raykernel/apps/readability/detectors/WordCountDetector #'8raykernel/apps/readability/detectors/NumKeyWordsDetector &*4raykernel/apps/readability/detectors/NumNumsDetector )-3raykernel/apps/readability/detectors/IndentDetector ,0:raykernel/apps/readability/detectors/AvgWordLengthDetector /39raykernel/apps/readability/detectors/BasicCommentDetector 266raykernel/apps/readability/detectors/BlankLineDetector 5 9 :*(Lraykernel/ml/feature/FeatureDetector;Z)V<9raykernel/apps/readability/detectors/MaxLineValueDetector ;?:raykernel/apps/readability/detectors/MaxWordLengthDetector >B6raykernel/apps/readability/detectors/CharCountDetector AD E([C)VG8raykernel/apps/readability/detectors/SubstrCountDetectorIjava/lang/StringK==M<O> FQ R([Ljava/lang/String;)VTifVforXwhileZ>raykernel/apps/readability/detectors/MaxOccurencesOfSingleChar Y]>raykernel/apps/readability/detectors/MaxOccurencesOfSingleWord \ SourceFileReadabilityDetectorSuite.java!  )    /*     .  YK*YY *Y#Y% *Y&Y( *Y)Y+ *Y,Y. */Y1 *Y2Y4 *Y5Y78 *;YY= *;Y#Y%= *;Y&Y(= *;Y)Y+= *;Y,Y.= *>Y@ *YAYY.UC *YAYY,UC *YAYY(UY{UC *YAYY UC *YAYY+UY*UY%UY/UY-UC *YAYY=UC *YFYHYJSYLSYNSP *YFYHYSSP *YFYHYUSYWSP *YY[ *\Y^ * v $6HZlw!"$%'(*+5/T0n123457!8,: _`PK :Iʁ Braykernel/apps/readability/detectors/ReadabilityDetectorSuite.javapackage raykernel.apps.readability.detectors; import raykernel.ml.feature.DetectorSuite; /** * A Wrapper around a set of FeatureDetectors * * @author rlb7g * */ public class ReadabilityDetectorSuite { private static DetectorSuite dsuite = null; public static DetectorSuite getDefaultSuite() { if (dsuite != null) return dsuite; DetectorSuite dsuite = new DetectorSuite(); dsuite.add(new AvgLineValueDetector(new LineLengthDetector())); //avg line length (chars) dsuite.add(new AvgLineValueDetector(new WordCountDetector())); //avg line length (words) dsuite.add(new AvgLineValueDetector(new NumKeyWordsDetector())); dsuite.add(new AvgLineValueDetector(new NumNumsDetector())); dsuite.add(new AvgLineValueDetector(new IndentDetector())); //average indentation dsuite.add(new AvgWordLengthDetector()); //avg word length dsuite.add(new AvgLineValueDetector(new BasicCommentDetector())); //comment density *** dsuite.add(new AvgLineValueDetector(new BlankLineDetector(), false)); dsuite.add(new MaxLineValueDetector(new LineLengthDetector())); //max line length (chars) dsuite.add(new MaxLineValueDetector(new WordCountDetector())); //max line length (words) dsuite.add(new MaxLineValueDetector(new NumKeyWordsDetector())); //*** dsuite.add(new MaxLineValueDetector(new NumNumsDetector())); //*** dsuite.add(new MaxLineValueDetector(new IndentDetector())); //max indentation *** dsuite.add(new MaxWordLengthDetector()); //max word length *** dsuite.add(new AvgLineValueDetector(new CharCountDetector('.'))); dsuite.add(new AvgLineValueDetector(new CharCountDetector(','))); //dsuite.add( new AvgLineValueDetector( new CharCountDetector( '.',',' ))); dsuite.add(new AvgLineValueDetector(new CharCountDetector('(', '{'))); // punct dsuite.add(new AvgLineValueDetector(new CharCountDetector(' '))); // spaces dsuite.add(new AvgLineValueDetector(new CharCountDetector('+', '*', '%', '/', '-'))); // math dsuite.add(new AvgLineValueDetector(new CharCountDetector('='))); // assign *** dsuite.add(new AvgLineValueDetector(new SubstrCountDetector("==", "<", ">"))); // compare dsuite.add(new AvgLineValueDetector(new SubstrCountDetector("if"))); // compare dsuite.add(new AvgLineValueDetector(new SubstrCountDetector("for", "while"))); // compare *** dsuite.add(new MaxOccurencesOfSingleChar()); //max single char *** dsuite.add(new MaxOccurencesOfSingleWord()); //max single word return dsuite; } } PK w:U <raykernel/apps/readability/detectors/CharCountDetector.class1y6raykernel/apps/readability/detectors/CharCountDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetectorchars[CnameLjava/lang/String;([C)VCode  ()V  java/lang/StringBuffer  (Ljava/lang/String;)V '  append,(Ljava/lang/String;)Ljava/lang/StringBuffer; ! "(C)Ljava/lang/StringBuffer;$' & '(toString()Ljava/lang/String; * LineNumberTableLocalVariableTablethis8Lraykernel/apps/readability/detectors/CharCountDetector;tmpnameLjava/lang/StringBuffer;cCcount(Ljava/lang/String;)I 687java/lang/String 9:charAt(I)C 6< =>length()IsiI featureName featureNames()[Ljava/lang/String; F B( HJIraykernel/util/Common KLmakeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)VP2raykernel/apps/readability/code/TrainableCodeBlock OR STiterator()Ljava/util/ListIterator; VXWjava/util/Iterator YZnext()Ljava/lang/Object;\(raykernel/apps/readability/code/CodeLine^)raykernel/ml/feature/StandardValueFeature [& a 34 ]c d(Ljava/lang/String;F)V [f gh setFeature!(Lraykernel/ml/feature/Feature;)V Vj klhasNext()Zb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;iterLjava/util/Iterator;l*Lraykernel/apps/readability/code/CodeLine;LocalVariableTypeTable@Ljava/util/Iterator; SourceFileCharCountDetector.java!   U**+YM+Y:66 4>,W, W,#W*,%)*,%)+.  !&#-$3%:!D(L*T,,*U-.UB/0&1234 E=>7*Y:6646+5  +;+. 01357(9+:.58>;3CA,4E-.E? C@AA3A12B( /*)+F, -.CD 2*EG+K, -.MN <+OM,QN(-U[:]Y*)*_`be-iձ+OQ R TU2R;X,4<-.<mn7op 2qrstu  2qvwxPK ;v:.bb;raykernel/apps/readability/detectors/CharCountDetector.javapackage raykernel.apps.readability.detectors; import java.util.Iterator; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; /** * Count the number of occurences of some character in each line We could extend * this to strings. Done without too much overhead like you would get using * regular expressions. * * @author rlb7g * */ public class CharCountDetector implements FeatureDetector { char[] chars; String name; public CharCountDetector(char... chars) { this.chars = chars; //only figure out the name once StringBuffer tmpname = new StringBuffer(""); for (char c : chars) { tmpname.append(" '"); tmpname.append(c); tmpname.append("'"); } name = tmpname.toString(); name = tmpname.toString(); } int count(String s) { int i = 0; int count = 0; while (i < s.length()) { for (char c : chars) { if (s.charAt(i) == c) { count++; break; //found a match for this char } } i++; } return count; } public String featureName() { return name; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; Iterator iter = block.iterator(); while (iter.hasNext()) { CodeLine l = iter.next(); l.setFeature(new StandardValueFeature(name, count(l.toString()))); } } } PK w:|9raykernel/apps/readability/detectors/IndentDetector.class1]3raykernel/apps/readability/detectors/IndentDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetector()VCode  LineNumberTableLocalVariableTablethis5Lraykernel/apps/readability/detectors/IndentDetector; featureName()Ljava/lang/String;indent featureNames()[Ljava/lang/String;   raykernel/util/Common makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; leadingBlanks(Ljava/lang/String;)I !#"java/lang/String $%charAt(I)C !' ()length()IsLjava/lang/String;iIblanks runDetector#(Lraykernel/ml/feature/Trainable;)V22raykernel/apps/readability/code/TrainableCodeBlock 14 56iterator()Ljava/util/ListIterator; 8:9java/util/Iterator ;<next()Ljava/lang/Object;>(raykernel/apps/readability/code/CodeLine@)raykernel/ml/feature/StandardValueFeature =B CtoString E  ?G H(Ljava/lang/String;F)V =J KL setFeature!(Lraykernel/ml/feature/Feature;)V 8N OPhasNext()Zb Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;iterLjava/util/Iterator;l*Lraykernel/apps/readability/code/CodeLine;LocalVariableTypeTable@Ljava/util/Iterator; SourceFileIndentDetector.java! /*    -   2*   1=>#+  +  +& *  "$!&$-'/0 *11*+/,--.-/0 <+1M,3N(-7=:?Y**ADFI-Mձ 46 7 9:27;= 4<<QR7ST 2UVWXY  2UZ[\PK ;v:xx8raykernel/apps/readability/detectors/IndentDetector.javapackage raykernel.apps.readability.detectors; import java.util.Iterator; import raykernel.apps.readability.code.CodeLine; import raykernel.apps.readability.code.TrainableCodeBlock; import raykernel.ml.feature.FeatureDetector; import raykernel.ml.feature.StandardValueFeature; import raykernel.ml.feature.Trainable; import raykernel.util.Common; public class IndentDetector implements FeatureDetector { public String featureName() { return "indent"; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } int leadingBlanks(String s) { int i = 0; int blanks = 0; while (i < s.length()) { if (s.charAt(i) == ' ') { blanks++; } else if (s.charAt(i) == '\t') { blanks += 4; //might add more than just 1? } else { break; } i++; } return blanks; } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; Iterator iter = block.iterator(); while (iter.hasNext()) { CodeLine l = iter.next(); l.setFeature(new StandardValueFeature(featureName(), leadingBlanks(l.toString()))); } } } PK w:^̕:raykernel/apps/readability/detectors/CommentDetector.class1=4raykernel/apps/readability/detectors/CommentDetectorjava/lang/Object$raykernel/ml/feature/FeatureDetector()VCode  LineNumberTableLocalVariableTablethis6Lraykernel/apps/readability/detectors/CommentDetector; featureName()Ljava/lang/String;comment featureNames()[Ljava/lang/String;   raykernel/util/Common makeSingletonArray'(Ljava/lang/String;)[Ljava/lang/String; runDetector#(Lraykernel/ml/feature/Trainable;)V!2raykernel/apps/readability/code/TrainableCodeBlock#;raykernel/apps/readability/detectors/RegularFeatureDetector "% &(Ljava/lang/String;)V((/\*(?:.|[\n\r])*?\*/)|(//.*) *,+java/util/regex/Pattern -.compile-(Ljava/lang/String;)Ljava/util/regex/Pattern; "0 12 addPattern(Ljava/util/regex/Pattern;)V "4 b Lraykernel/ml/feature/Trainable;block4Lraykernel/apps/readability/code/TrainableCodeBlock;commentDetector=Lraykernel/apps/readability/detectors/RegularFeatureDetector; SourceFileCommentDetector.java! /*    -   2*   v+ M"Y$N-')/-,3  !#% *56789:; * */ public class CommentDetector implements FeatureDetector { public String featureName() { return "comment"; } public String[] featureNames() { return Common.makeSingletonArray(featureName()); } public void runDetector(Trainable b) { TrainableCodeBlock block = (TrainableCodeBlock) b; RegularFeatureDetector commentDetector = new RegularFeatureDetector("comment"); commentDetector.addPattern(Pattern.compile("(/\\*(?:.|[\\n\\r])*?\\*/)|(//.*)")); commentDetector.runDetector(block); } } PK w:tĿ}HH*raykernel/experiment/BenchmarkRunner.class1P$raykernel/experiment/BenchmarkRunnerjava/lang/Object()VCode  LineNumberTableLocalVariableTablethis&Lraykernel/experiment/BenchmarkRunner;main([Ljava/lang/String;)Vraykernel/experiment/Benchmark  (Ljava/lang/String;)V  run#(Lraykernel/experiment/Benchmark;)V   loadDefault"()Lraykernel/experiment/Benchmark;args[Ljava/lang/String; java/lang/StringBuilder"java  % &' getMainClass()Ljava/lang/String; ) *+append-(Ljava/lang/String;)Ljava/lang/StringBuilder;- / 0' getArgString 2 3'toString5 java/io/File7)C:/Users/buse/workspace/pathfreq/benchbin 4 :<;raykernel/util/Runner => runCommand#(Ljava/lang/String;Ljava/io/File;)D@ Time(s) = B *C(D)Ljava/lang/StringBuilder; EGFraykernel/io/Out HIprintln(Ljava/lang/Object;)V benchmark Lraykernel/experiment/Benchmark;timeD SourceFileBenchmarkRunner.java!/*   R*Y*2      @Y!#*$(,(*.(14Y689HY?#'A1D #(,? @JK,LMNOPK ;v:w88)raykernel/experiment/BenchmarkRunner.javapackage raykernel.experiment; import java.io.File; import raykernel.util.Runner; public class BenchmarkRunner { public static void main(String[] args) { if (args.length > 0) { run(new Benchmark(args[0])); } else { run(Benchmark.loadDefault()); } } public static void run(Benchmark benchmark) { double time = Runner.runCommand("java " + benchmark.getMainClass() + " " + benchmark.getArgString(), new File( "C:/Users/buse/workspace/pathfreq/benchbin")); raykernel.io.Out.println("Time(s) = " + time); } } PK w:C)3'raykernel/experiment/BenchmarkOld.class1N!raykernel/experiment/BenchmarkOldjava/lang/ObjectbinDirLjava/io/File;mainDirnameLjava/lang/String;oldDirsrcDir(Ljava/io/File;)VCode  ()Vdefault     java/io/Filejava/lang/StringBuilder    append-(Ljava/lang/Object;)Ljava/lang/StringBuilder;"/src $ %-(Ljava/lang/String;)Ljava/lang/StringBuilder; ' ()toString()Ljava/lang/String; + ,(Ljava/lang/String;)V . 0/bin 2 4/old 6 LineNumberTableLocalVariableTablethis#Lraykernel/experiment/BenchmarkOld;dir#(Ljava/io/File;Ljava/lang/String;)V > ?,setNamesrc getBinDir()Ljava/io/File; getMainDirgetName getOldDir getSrcDirH Benchmark: + K D) SourceFileBenchmarkOld.java!    j***+*YY+!#&*-*YY+/#&*1*YY+3#&*57 -Ki8j9:j; <c***+-*,=7 8 9:@ AB/*178 9:CB/*7$8 9:D)/*7)8 9:EB/*57.8 9:FB/*-738 9:?,>*+7 8989: ()AYGI*J#&7=8 9:LMPK t:/ii&raykernel/experiment/BenchmarkOld.javapackage raykernel.experiment; import java.io.File; public class BenchmarkOld { File binDir; File mainDir; private String name = "default"; File oldDir; File srcDir; public BenchmarkOld(File dir) { mainDir = dir; srcDir = new File(dir + "/src"); binDir = new File(dir + "/bin"); oldDir = new File(dir + "/old"); } public BenchmarkOld(File src, String name) { srcDir = src; this.setName(name); } public File getBinDir() { return binDir; } public File getMainDir() { return mainDir; } public String getName() { return name; } public File getOldDir() { return oldDir; } public File getSrcDir() { return srcDir; } public void setName(String name) { this.name = name; } public String toString() { return "Benchmark: " + mainDir.getName(); } } PK w:ZTtt$raykernel/experiment/Benchmark.class1raykernel/experiment/Benchmarkjava/lang/ObjectdescFileLjava/lang/String;tagsLraykernel/util/TagFile; loadDefault"()Lraykernel/experiment/Benchmark;Code 1C:/Users/buse/workspace/pathfreq/bench/simple.txt  (Ljava/lang/String;)VLineNumberTableLocalVariableTable(Ljava/io/File;)V  ()Vraykernel/util/TagFile     !  java/io/File "#getAbsolutePath()Ljava/lang/String; % this Lraykernel/experiment/Benchmark;fLjava/io/File; getArgs()Ljava/util/List; Signature&()Ljava/util/List;0args 2 34 getValues$(Ljava/lang/String;)Ljava/util/List;6java/util/LinkedList 5Ljava/util/List;LocalVariableTypeTable$Ljava/util/List; getArgString=java/lang/StringBuffer < @ +, BDCjava/util/List EFiterator()Ljava/util/Iterator; HJIjava/util/Iterator KLnext()Ljava/lang/Object;Njava/lang/StringPjava/lang/StringBuilder MR STvalueOf&(Ljava/lang/Object;)Ljava/lang/String; OW OY Z[append-(Ljava/lang/String;)Ljava/lang/StringBuilder; O] ^#toString <` Za,(Ljava/lang/String;)Ljava/lang/StringBuffer; Hc dehasNext()Z <]bufLjava/lang/StringBuffer;arggetBaseDirectory()Ljava/io/File; monraykernel/config/Config pkgetBenchDirectory r s#getName uwvraykernel/util/Tools xy getSubDir0(Ljava/io/File;Ljava/lang/String;)Ljava/io/File; getBinDir | jk~bin getClassName"(Ljava/io/File;)Ljava/lang/String;  zk  #getPath M length()I M  lastIndexOf(I)I M  substring(II)Ljava/lang/String;\. M replaceD(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;path getClasspath m #getClassPathDelimiter java_lib_dir m get&(Ljava/lang/String;)Ljava/lang/String;  getJars O O Z-(Ljava/lang/Object;)Ljava/lang/StringBuilder;  k getLibDir getDescFile  eexists   listFiles()[Ljava/io/File; r.jar M endsWith(Ljava/lang/String;)Zdirlib getMainClassmain  getValuename getOldDirold getProperties8(Ljava/lang/String;)Ljava/util/List;tag getProperty getSrcDirsrcgetTargetClasses()Ljava/util/Collection;,()Ljava/util/Collection;targets targetfilter B (I)Ljava/lang/Object;class raykernel/io/FileFinder findAll2(Ljava/io/File;Ljava/lang/String;)Ljava/util/List;   M  startsWith java/util/Collection add(Ljava/lang/Object;)ZLjava/util/Collection;filterfiles*Ljava/util/Collection; Ljava/util/List;getWorkingDirectory m k hasPropertyisMember'(Lraykernel/apps/docinf/code/JMethod;)Z "raykernel/apps/docinf/code/JMethod # getPackagepackages  4 M contains(Ljava/lang/CharSequence;)Zm$Lraykernel/apps/docinf/code/JMethod;pack appPackage SourceFileBenchmark.java!  * Y  Y**Y+*+$&'() ]**YY+**+$ "#$&'(+,-. j*/1L+ 5Y7+( )*,&' 089  0:;# EL*?AN%-GMM+OY,QUVX\_W-b+f13573@8 E&'=ghijk 5 l*qt=  &'zk 4 *{}tB  &' q'+M,*`,.M,M,GIK%M '&''()"# L+OYQU*Y*X\_W*+OY*X\_W*#+OYQU**X\_W+fRT0V7XS[Z]z`&'wgh# /*$d &' `M+R+K+Y:6642N-,OY-QUX\_W,fjln)p5rQn[v*`&'`)Xgh)(()k 4 *{t{  &'# 4 *¶İ  &'s# 4 *Ƕİ  &'k 4 *{ʸt  &'4- = *+1 &'  = *+İ &' k 4 *{Ѹt  &'- **ֶ1LM*ض1*ض1MM+T*ݸN5Y7L-A:-G:*:, , +Wb+6 +/9AX`mv>&' x v9G8X()`9 x9Gk 5 *qt  &' C*+1&' 7+M*A:GMN,-b!)+5*7&'7 2 !    PK ;v:b#raykernel/experiment/Benchmark.javapackage raykernel.experiment; import java.io.File; import java.util.Collection; import java.util.LinkedList; import java.util.List; import raykernel.apps.docinf.code.JMethod; import raykernel.config.Config; import raykernel.util.TagFile; import raykernel.util.Tools; public class Benchmark { public static Benchmark loadDefault() { return new Benchmark("C:/Users/buse/workspace/pathfreq/bench/simple.txt"); } String descFile; TagFile tags; public Benchmark(File f) { tags = new TagFile(f); descFile = f.getAbsolutePath(); } public Benchmark(String f) { tags = new TagFile(new File(f)); descFile = f; } public List getArgs() { List args = tags.getValues("args"); if (args == null) return new LinkedList(); return args; } public String getArgString() { StringBuffer buf = new StringBuffer(); for (String arg : getArgs()) { buf.append(arg + " "); } return buf.toString(); } private File getBaseDirectory() { return Tools.getSubDir(Config.getBenchDirectory(), getName()); } public File getBinDir() { return Tools.getSubDir(getBaseDirectory(), "bin"); } String getClassName(File f) { String path = f.getAbsolutePath(); path = path.substring(getBinDir().getPath().length() + 1, path.lastIndexOf('.')); path = path.replace("\\", "."); return path; } public String getClasspath() { StringBuffer buf = new StringBuffer(); buf.append(Config.getClassPathDelimiter() + getJars(new File(Config.get("java_lib_dir")))); if (getBinDir() != null) { buf.append(getBinDir() + Config.getClassPathDelimiter()); } if (getLibDir() != null) { buf.append(Config.getClassPathDelimiter() + getJars(getLibDir())); } return buf.toString(); } public String getDescFile() { return this.descFile; } public String getJars(File dir) { StringBuffer buf = new StringBuffer(); if (dir != null && dir.exists()) { for (File f : dir.listFiles()) { if (f.getName().endsWith(".jar")) { buf.append(f.getAbsolutePath() + Config.getClassPathDelimiter()); } } } return buf.toString(); } public File getLibDir() { return Tools.getSubDir(getBaseDirectory(), "lib"); } public String getMainClass() { return tags.getValue("main"); } public String getName() { return tags.getValue("name"); } public File getOldDir() { return Tools.getSubDir(getBaseDirectory(), "old"); } public List getProperties(String tag) { return tags.getValues(tag); } public String getProperty(String tag) { return tags.getValue(tag); } public File getSrcDir() { return Tools.getSubDir(getBaseDirectory(), "src"); } public Collection getTargetClasses() { Collection targets = tags.getValues("targets"); String filter = null; if (tags.getValues("targetfilter") != null) { filter = tags.getValues("targetfilter").get(0); } if (targets == null) //need to seach { List files = raykernel.io.FileFinder.findAll(getBinDir(), "class"); targets = new LinkedList(); for (File f : files) { String name = getClassName(f); if (filter == null || name.startsWith(filter)) { targets.add(name); } } } return targets; } public File getWorkingDirectory() { return Tools.getSubDir(Config.getWorkingDirectory(), getName()); } public boolean hasProperty(String tag) { return tags.getValues(tag) != null; } public boolean isMember(JMethod m) { String pack = m.getPackage(); //io.Out.println("is " + pack + " in " + getProperties("packages") + "?"); for (String appPackage : this.getProperties("packages")) { if (pack.contains(appPackage)) { return true; } } return false; } } PK w:&,a a raykernel/io/Out.class1raykernel/io/Outjava/lang/ObjectDEBUGLjava/lang/String; ConstantValueDEFAULT ERROR  EXCEPTION ()VCode  LineNumberTableLocalVariableTablethisLraykernel/io/Out;debug(Ljava/lang/String;)V raykernel/config/Config  debugMode()Z ! "#println'(Ljava/lang/String;Ljava/lang/String;)Vlineerrorstring exception*(Ljava/lang/String;Ljava/lang/Throwable;)V*java/lang/StringBuilder ,.-java/lang/String /0valueOf&(Ljava/lang/Object;)Ljava/lang/String; )2 4 : )6 78append-(Ljava/lang/String;)Ljava/lang/StringBuilder; ): 7;-(Ljava/lang/Object;)Ljava/lang/StringBuilder; )= >?toString()Ljava/lang/String;eLjava/lang/Throwable; getCaller DFEjava/lang/Thread GH currentThread()Ljava/lang/Thread; DJ KL getStackTrace ()[Ljava/lang/StackTraceElement; NPOjava/lang/StackTraceElement Q? getClassNameS: NU V? getMethodNameframes[Ljava/lang/StackTraceElement;callerLjava/lang/StackTraceElement;print ]_^java/lang/System `aoutLjava/io/PrintStream; cedjava/io/PrintStream [g[i] key cl "(Ljava/lang/Object;)Vo print_caller q rs getBoolean(Ljava/lang/String;)Z u B? =oLjava/lang/Object;z | [#verbose} SourceFileOut.java!      /*  ?  *    $ %5 *   & '(U)Y*+135+9<  &@A B?e)CIK*2L)Y+M+1R5+T5< " $"WX YZ [#p0* \+b"\)Yf1*5h5+5<b*+-/.0j0$ "+\k 23 "mUnpt*v  *v 78:; wx "#P*)Y++1y5<{ ?@j$ }mE~p t*v DEF wxPK Tv:G-graykernel/io/Out.javapackage raykernel.io; import raykernel.config.Config; public class Out { public static final String DEBUG = "DEBUG"; public static final String DEFAULT = "DEFAULT"; public static final String ERROR = "ERROR"; public static final String EXCEPTION = "EXCEPTION"; public static void debug(String line) { if (Config.debugMode()) { println(DEBUG, line); } } public static void error(String string) { println(ERROR, string); } public static void exception(String string, Throwable e) { println(EXCEPTION, string + " : " + e); } public static String getCaller() { StackTraceElement[] frames = Thread.currentThread().getStackTrace(); StackTraceElement caller = frames[3]; return caller.getClassName() + ":" + caller.getMethodName(); } public static void print(String key, String line) { if (key == DEFAULT) System.out.print(line); else System.out.print("[" + key + "] " + line); } public static void println() { System.out.println(); } public static void println(Object o) { if (Config.getBoolean("print_caller")) println(getCaller(), o.toString()); else println(DEFAULT, o.toString()); } public static void println(String key, String line) { print(key, line + "\n"); } public static void verbose(Object o) { if (Config.getBoolean("verbose")) println(getCaller(), o.toString()); } } PK w:6)XTT&raykernel/io/FileExtensionFilter.class16 raykernel/io/FileExtensionFilterjava/lang/Objectjava/io/FileFilterexnLjava/lang/String;(Ljava/lang/String;)VCode  ()V.java  java/lang/StringBuilder.   append-(Ljava/lang/String;)Ljava/lang/StringBuilder;   toString()Ljava/lang/String;LineNumberTableLocalVariableTablethis"Lraykernel/io/FileExtensionFilter;accept(Ljava/io/File;)Z (*) java/io/File + getName -/.java/lang/String 01endsWith(Ljava/lang/String;)ZfLjava/io/File; SourceFileFileExtensionFilter.java!  _* **Y+!  "#$%& @ +'*,!" #$ 2345PK t:`|IBB%raykernel/io/FileExtensionFilter.javapackage raykernel.io; import java.io.File; import java.io.FileFilter; public class FileExtensionFilter implements FileFilter { String exn = ".java"; public FileExtensionFilter(String exn) { this.exn = "." + exn; } public boolean accept(File f) { return f.getName().endsWith(exn); } } PK w:raykernel/io/FileFinder.class1@raykernel/io/FileFinderjava/lang/Object()VCode  LineNumberTableLocalVariableTablethisLraykernel/io/FileFinder;findAll4(Ljava/io/File;Ljava/io/FileFilter;)Ljava/util/List; SignatureD(Ljava/io/File;Ljava/io/FileFilter;)Ljava/util/List;  java/io/File  listFiles%(Ljava/io/FileFilter;)[Ljava/io/File;raykernel/io/DirectoryFilter  java/util/LinkedList   !add(Ljava/lang/Object;)Z #  % &'addAll(Ljava/util/Collection;)Z directoryLjava/io/File;filterLjava/io/FileFilter; javaFiles[Ljava/io/File; directoriessrcsLjava/util/LinkedList;fdLocalVariableTypeTable&Ljava/util/LinkedList;2(Ljava/io/File;Ljava/lang/String;)Ljava/util/List;B(Ljava/io/File;Ljava/lang/String;)Ljava/util/List;8 raykernel/io/FileExtensionFilter 7: ;(Ljava/lang/String;)VexnLjava/lang/String; SourceFileFileFinder.java!/*    v*+M*YNY:,),Y:662:W---Y:662:+"$W 2 3;E I"]$i"s( Hv()v*+p,-d.-[/031)] 2)3 [/4 56A *7Y+9" -  () <=>?PK t:BXiiraykernel/io/FileFinder.javapackage raykernel.io; import java.io.File; import java.io.FileFilter; import java.util.LinkedList; import java.util.List; public class FileFinder { /** * Recursively find all java files * * @param directory * @return */ public static List findAll(File directory, FileFilter filter) { File[] javaFiles = directory.listFiles(filter); File[] directories = directory.listFiles(new DirectoryFilter()); LinkedList srcs = new LinkedList(); if (javaFiles != null) { for (File f : javaFiles) { srcs.add(f); } } if (directories != null) { for (File d : directories) { srcs.addAll(findAll(d, filter)); } } return srcs; } public static List findAll(File directory, String exn) { return findAll(directory, new FileExtensionFilter(exn)); } } PK w:Qsr"raykernel/io/DirectoryFilter.class1raykernel/io/DirectoryFilterjava/lang/Objectjava/io/FileFilter()VCode  LineNumberTableLocalVariableTablethisLraykernel/io/DirectoryFilter;accept(Ljava/io/File;)Z  java/io/File  isDirectory()ZfLjava/io/File; SourceFileDirectoryFilter.java! /*    9+  PK t:!raykernel/io/DirectoryFilter.javapackage raykernel.io; import java.io.File; import java.io.FileFilter; public class DirectoryFilter implements FileFilter { public boolean accept(File f) { return f.isDirectory(); } } PK w:mdzFHH!raykernel/io/JavaFileFilter.class1$raykernel/io/JavaFileFilterjava/lang/Objectjava/io/FileFilter()VCode  LineNumberTableLocalVariableTablethisLraykernel/io/JavaFileFilter;accept(Ljava/io/File;)Z  java/io/File getName()Ljava/lang/String;.java java/lang/String endsWith(Ljava/lang/String;)ZfLjava/io/File; SourceFileJavaFileFilter.java! /*    > +    !"#PK t:$ raykernel/io/JavaFileFilter.javapackage raykernel.io; import java.io.File; import java.io.FileFilter; public class JavaFileFilter implements FileFilter { public boolean accept(File f) { return f.getName().endsWith(".java"); } } PK w:zraykernel/io/Console.class1Araykernel/io/Consolejava/lang/ObjectbufferLjava/io/BufferedReader;readerLjava/io/InputStreamReader;()VCode  LineNumberTableLocalVariableTablethisLraykernel/io/Console;pause java/lang/System outLjava/io/PrintStream; Press Enter to continue . . . java/io/PrintStream  print(Ljava/lang/String;)V " $java/io/InputStreamReader & '(inLjava/io/InputStream; #* +(Ljava/io/InputStream;)V-java/io/BufferedReader ,/ 0(Ljava/io/Reader;)V 2  ,4 56readLine()Ljava/lang/String; 8 9:exit(I)V<java/lang/ExceptioneLjava/lang/Exception; SourceFile Console.java!  /*     8!#Y%)!,Y!.113WK7/2;" (237 3=>?@PK t:qraykernel/io/Console.javapackage raykernel.io; import java.io.BufferedReader; import java.io.InputStreamReader; public class Console { static BufferedReader buffer; static InputStreamReader reader; public static void pause() { System.out.print("\nPress Enter to continue . . . "); try { if (reader == null) { reader = new InputStreamReader(System.in); buffer = new BufferedReader(reader); } buffer.readLine(); } catch (Exception e) { System.exit(0); } } } PK w:fj>uu raykernel/io/JavaSrcFinder.class18raykernel/io/JavaSrcFinderjava/lang/Object()VCode  LineNumberTableLocalVariableTablethisLraykernel/io/JavaSrcFinder;findAll (Ljava/io/File;)Ljava/util/List; Signature0(Ljava/io/File;)Ljava/util/List;raykernel/io/JavaFileFilter   java/io/File  listFiles%(Ljava/io/FileFilter;)[Ljava/io/File;raykernel/io/DirectoryFilter  java/util/LinkedList  " #$add(Ljava/lang/Object;)Z &  ( )*addAll(Ljava/util/Collection;)Z directoryLjava/io/File; javaFiles[Ljava/io/File; directoriessrcsLjava/util/LinkedList;fdLocalVariableTypeTable&Ljava/util/LinkedList; SourceFileJavaSrcFinder.java!/*   o*YL*YMY N+Y:662:-!W,Y:662:-%'W- *   4;EYcm! >o+, c-.W/. O0142,Y 3,4  O0567PK t:Gnnraykernel/io/JavaSrcFinder.javapackage raykernel.io; import java.io.File; import java.util.LinkedList; import java.util.List; public class JavaSrcFinder { /** * Recursively find all java files * * @param directory * @return */ public static List findAll(File directory) { File[] javaFiles = directory.listFiles(new JavaFileFilter()); File[] directories = directory.listFiles(new DirectoryFilter()); LinkedList srcs = new LinkedList(); for (File f : javaFiles) { srcs.add(f); } for (File d : directories) { srcs.addAll(findAll(d)); } return srcs; } } PK w:BLL'raykernel/ml/validate/StraightVal.class1i!raykernel/ml/validate/StraightValjava/lang/Object classFeatureLjava/lang/String;estimateFeatureresultsLjava/util/Vector; Signature4Ljava/util/Vector; scoreTotalF totalCountI trainingSetLjava/util/List;2Ljava/util/List;7(Ljava/util/List;Ljava/lang/String;Ljava/lang/String;)VZ(Ljava/util/List<+Lraykernel/ml/feature/Trainable;>;Ljava/lang/String;Ljava/lang/String;)VCode  ()Vjava/util/Vector     "  $  &  ( LineNumberTableLocalVariableTablethis#Lraykernel/ml/validate/StraightVal;pathsLocalVariableTypeTable3Ljava/util/List<+Lraykernel/ml/feature/Trainable;>; getResults()Ljava/util/Vector;6()Ljava/util/Vector; printStats5java/lang/StringBuilder7average score = 49 :(Ljava/lang/String;)V 4< =>append(F)Ljava/lang/StringBuilder; 4@ ABtoString()Ljava/lang/String; DFEraykernel/io/Out GHprintln(Ljava/lang/Object;)Vrun KMLjava/util/List NOiterator()Ljava/util/Iterator; QSRjava/util/Iterator TUnext()Ljava/lang/Object;Wraykernel/ml/feature/TrainableYraykernel/ml/validate/LineStat X[ \G(Lraykernel/ml/feature/Trainable;Ljava/lang/String;Ljava/lang/String;)V ^ _`add(Ljava/lang/Object;)Z Qb cdhasNext()Zt Lraykernel/ml/feature/Trainable; SourceFileStraightVal.java!     )**Y* *!*+#*,%*-')"#(**)+,)-)). )-/01 2/*)* +,3K4Y68**!n;?C) #$* +,Iy9*#JM%,PVL*XY+*'*%Z]W,aر))+/)8.*9+,efghPK ;v:^"a&raykernel/ml/validate/StraightVal.javapackage raykernel.ml.validate; import java.util.List; import java.util.Vector; import raykernel.ml.feature.Trainable; public class StraightVal { String classFeature; String estimateFeature; Vector results = new Vector(); float scoreTotal = 0; int totalCount = 0; List trainingSet; public StraightVal(List paths, String classFeature, String estimateFeature) { trainingSet = (List) paths; this.classFeature = classFeature; this.estimateFeature = estimateFeature; } public Vector getResults() { return results; } public void printStats() { raykernel.io.Out.println("average score = " + scoreTotal / totalCount); } public void run() { // record data from run for (Trainable t : trainingSet) { results.add(new LineStat(t, estimateFeature, classFeature)); } } } PK w:k&raykernel/ml/validate/SnippetVal.class1 raykernel/ml/validate/SnippetValjava/lang/Object classifierLweka/classifiers/Classifier; classNameLjava/lang/String;numFoldsI otherFeatures[Ljava/lang/String;resultsLjava/util/Map; SignatureCLjava/util/Map;snippetsLjava/util/List;3Ljava/util/List<+Lraykernel/ml/feature/Trainable;>;I(Ljava/util/List;Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/String;)Vl(Ljava/util/List<+Lraykernel/ml/feature/Trainable;>;Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/String;)VCode  ()V      "$#java/lang/Class %& newInstance()Ljava/lang/Object;(weka/classifiers/Classifier *  ,.-java/lang/System /0errLjava/io/PrintStream;2!could not instantiate classifier! 465java/io/PrintStream 78println(Ljava/lang/String;)V ,: ;<exit(I)V>java/util/HashMap = A Cjava/lang/ExceptionLineNumberTableLocalVariableTablethis"Lraykernel/ml/validate/SnippetVal;Ljava/lang/Class;eLjava/lang/Exception;LocalVariableTypeTable getAllButB(Ljava/util/List;Lraykernel/ml/feature/Trainable;)Ljava/util/List;(Ljava/util/List;Lraykernel/ml/feature/Trainable;)Ljava/util/List;Pjava/util/LinkedList O SUTjava/util/List VWiterator()Ljava/util/Iterator; Y[Zjava/util/Iterator \&next^raykernel/ml/feature/Trainable O` abadd(Ljava/lang/Object;)Z Yd efhasNext()ZtrainingSnippetsleaveOut Lraykernel/ml/feature/Trainable;retLjava/util/LinkedList;s2Ljava/util/List;8Ljava/util/LinkedList;getTrainingSet()Ljava/util/List;4()Ljava/util/List; ]s tu getFeature2(Ljava/lang/String;)Lraykernel/ml/feature/Feature; wyxraykernel/ml/feature/Feature z{value()F printResults actual guess raykernel/io/Out 7(Ljava/lang/Object;)V  java/util/Map keySet()Ljava/util/Set; U java/util/Set get&(Ljava/lang/Object;)Ljava/lang/Object;java/lang/Double  doubleValue()Djava/lang/StringBuilder java/lang/String valueOf(F)Ljava/lang/String; 8 append-(Ljava/lang/String;)Ljava/lang/StringBuilder; (D)Ljava/lang/StringBuilder; toString()Ljava/lang/String;tguessDactualFrun  op  LMraykernel/ml/core/Trainer >(Ljava/util/Collection;Ljava/lang/String;[Ljava/lang/String;)V trainClassifier (Lweka/classifiers/Classifier;)Vraykernel/ml/core/Evaluator o()Lweka/core/Instances; Z(Lweka/classifiers/Classifier;Lweka/core/Instances;Ljava/lang/String;[Ljava/lang/String;)V  runDetector#(Lraykernel/ml/feature/Trainable;)V  getScoreFor#(Lraykernel/ml/feature/Trainable;)F (D)Ljava/lang/Double; put8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;isnippettrainLraykernel/ml/core/Trainer;Lraykernel/ml/core/Evaluator; SourceFileSnippetVal.java! <**-**+*,!'):+139*=Y?@"BD*  ""$$&,'0*;0E><FG<<H<< $ IJK <LMN8OYQN+R:X]:, -_Wc-D468%:,66>E48FG8g8hi0jk liK8gm0jnopqCOYQL*RN&-X]M,*rv| +,_W-c+DCEG2I8EAME CFG;jkliK ;jn}f~*@MH,X]L*@+J+*rv8Y),cDRT!V2WAY\Te[E*fFG!;i2*A.*L=*R:gX]N*+-:Y**:*)Y*)**:-*@--΍ҹWcD. _ad f(h;kDn^pdryduEHFGg}  Yi(Q;>^IKgm(QmPK 4v:2 %raykernel/ml/validate/SnippetVal.javapackage raykernel.ml.validate; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import raykernel.ml.core.Evaluator; import raykernel.ml.core.Trainer; import raykernel.ml.feature.Trainable; import weka.classifiers.Classifier; public class SnippetVal { Classifier classifier; String className; int numFolds; String[] otherFeatures; Map results; //average scores private final List snippets; public SnippetVal(List snippets, Class classifier, String className, String... otherFeatures) { this.className = className; this.otherFeatures = otherFeatures; this.snippets = snippets; try { this.classifier = (Classifier) classifier.newInstance(); } catch (Exception e) { System.err.println("could not instantiate classifier!"); System.exit(0); } results = new HashMap(); //results.setSize(101); //for( int i=0; i getAllBut(List trainingSnippets, Trainable leaveOut) { LinkedList ret = new LinkedList(); for (Trainable s : trainingSnippets) { if (s != leaveOut) { ret.add(s); } } return ret; } private List getTrainingSet() { LinkedList ret = new LinkedList(); for (Trainable s : snippets) { if (s.getFeature(className).value() != -1) { ret.add(s); } } return ret; } public void printResults() { raykernel.io.Out.println("actual\tguess"); for (Trainable t : results.keySet()) { double guess = results.get(t); float actual = t.getFeature(className).value(); raykernel.io.Out.println(actual + "\t" + guess); } } public void run() { List trainingSnippets = getTrainingSet(); int i = 0; //for each of the snippets for (Trainable snippet : snippets) { List train = getAllBut(trainingSnippets, snippet); Trainer t = new Trainer(train, className, otherFeatures); //train t.trainClassifier(classifier); //run evaluator Evaluator e = new Evaluator(classifier, t.getTrainingSet(), className, otherFeatures); e.runDetector(snippet); results.put(snippet, (double) e.getScoreFor(snippet)); } } } PK w: $C C !raykernel/ml/validate/Stats.class1Iraykernel/ml/validate/Statsjava/lang/Object()VCode  LineNumberTableLocalVariableTablethisLraykernel/ml/validate/Stats;getAverageScore(Ljava/util/Collection;)F Signature;(Ljava/util/Collection;)F java/util/Collection iterator()Ljava/util/Iterator; java/util/Iterator next()Ljava/lang/Object;raykernel/ml/validate/LineStat ! "#getScore()F % &'hasNext()ZresultsLjava/util/Collection;sumF line_countstat Lraykernel/ml/validate/LineStat;LocalVariableTypeTable8Ljava/util/Collection;getAvgBugScore 3 4'isBugnumgetAvgNonBugScore getNumBugs(Ljava/util/Collection;)I;(Ljava/util/Collection;)IbugsI getPctCorrect(Ljava/util/Collection;F)F<(Ljava/util/Collection;F)Fcutoffcorrecttotal getPrecisionac getRecallb SourceFile Stats.java!/*   3 D E*:N$ bE#- bD$#$n    % / *3()1*+/,+ -./ 3(0 1: D E*: N-2#- bD$ bE$#$n "!( ,6$ *:()8*+65+-./ :(0 6: D E*: N-2#- bD$ bE$#$n ")*,.!0(1,,65 *:()8*+65+-./ :(0 789+<*N-M,2-$ :<>@ <)D +()):; -./ +(0 <=>[=>*:?:2 # 2 #$n * IJLN-P3RETHWKLUZ 4[()[?+Y@;WA;0-./ [(0 B=>P=>*:*: #2 $` `n . ghjl%n-p3t6j@{F|H~ 4P()P?+NC;LD;-./ P(0 E=>H=>*:*:2 # $`n & #-36@ 4H()H?+FC;DF;-./ H(0GHPK t:2l raykernel/ml/validate/Stats.javapackage raykernel.ml.validate; import java.util.Collection; public class Stats { public static float getAverageScore(Collection results) { float sum = 0; float line_count = 0; for (LineStat stat : results) { line_count++; sum += stat.getScore(); } return sum / line_count; } public static float getAvgBugScore(Collection results) { float sum = 0; float num = 0; for (LineStat stat : results) { if (stat.isBug()) { sum += stat.getScore(); num++; } } return sum / num; } public static float getAvgNonBugScore(Collection results) { float sum = 0; float num = 0; for (LineStat stat : results) { if (!stat.isBug()) { sum += stat.getScore(); num++; } } return sum / num; } public static int getNumBugs(Collection results) { int bugs = 0; for (LineStat stat : results) { if (stat.isBug()) { bugs++; } } return bugs; } public static float getPctCorrect(Collection results, float cutoff) { int correct = 0; int total = 0; for (LineStat stat : results) { if (stat.isBug() && stat.getScore() > cutoff) { correct++; } else if (!stat.isBug() && stat.getScore() <= cutoff) { correct++; } total++; } return (float) correct / (float) total; } /** * * A: number of bug lines above cutoff C: number of non-bug lines above * cutoff * * precision = A/(A+C) * */ public static float getPrecision(Collection results, float cutoff) { int a = 0; int c = 0; for (LineStat stat : results) { if (stat.getScore() > cutoff) { if (stat.isBug()) { a++; } else { c++; } } } //io.Out.println("a=" + a + " c=" + c); if (a + c == 0) return 0; return (float) a / (a + c); } /** * * A: number of bug lines above cutoff B: number of bug lines below cutoff * * recall = A/(A+B) * */ public static float getRecall(Collection results, float cutoff) { int a = 0; int b = 0; for (LineStat stat : results) { if (stat.isBug()) { if (stat.getScore() > cutoff) { a++; } else { b++; } } } //io.Out.println("a=" + a + " b=" + b); return (float) a / (a + b); } } PK w:`$raykernel/ml/validate/Analyzer.class1raykernel/ml/validate/Analyzerjava/lang/Object getPctCorrect(Ljava/util/Collection;F)F Signature<(Ljava/util/Collection;F)FCode  java/util/Collection iterator()Ljava/util/Iterator; java/util/Iterator next()Ljava/lang/Object;raykernel/ml/validate/LineStat  isBug()Z  getScore()F ! "hasNextLineNumberTableLocalVariableTableresultsLjava/util/Collection;cutoffFcorrectItotalstat Lraykernel/ml/validate/LineStat;LocalVariableTypeTable8Ljava/util/Collection;()V 3 01this Lraykernel/ml/validate/Analyzer;getAvgBestFmeasure(Ljava/util/Vector;)FK(Ljava/util/Vector;>;)F : ;java/util/Vector = >?getBestFmeasure(Ljava/util/Collection;)FnameLjava/util/Vector;countrunStatsHLjava/util/Vector;>;getAvgKendallsTau((Ljava/util/Vector;Ljava/lang/String;I)F^(Ljava/util/Vector;>;Ljava/lang/String;I)F I JFgetTau rankFeatureLjava/lang/String;bins4Ljava/util/Vector;;(Ljava/util/Collection;)F=L RTSraykernel/ml/validate/Stats U getPrecision RW X getRecall57interval best_fmeasiprfmeasstopJ(Ljava/util/Vector;Ljava/lang/String;I)Fcjava/util/LinkedList b3 f gh getTrainable"()Lraykernel/ml/feature/Trainable; jlkjava/util/List mnadd(Ljava/lang/Object;)Z :p qrget(I)Ljava/lang/Object; t uvgetScoreFeature()Ljava/lang/String; xzyraykernel/stats/Sorter {| sortByFeature%(Ljava/util/List;Ljava/lang/String;)V~java/lang/StringBuilder sorting by: } 0(Ljava/lang/String;)V } append-(Ljava/lang/String;)Ljava/lang/StringBuilder; and } vtoString raykernel/io/Out println(Ljava/lang/Object;)V raykernel/stats/KendallsTau computeDistance$(Ljava/util/List;Ljava/util/List;I)D estFeature sortCorrectLjava/util/List; sortByEvall2Ljava/util/List;printScoreRatio(Ljava/util/Collection;)V;(Ljava/util/Collection;)V R ?getAvgBugScore R ?getAvgNonBugScoreAvgBugScore = } (F)Ljava/lang/StringBuilder;AvgNonBugScore = Ratio = bugnon printScoresls SourceFile Analyzer.java!  [=>* :?:# # n#* -3!E#H&KU)$4[%&['(Y)*W+*0,-. [%/01 3*2# ,.$ 45678 4 E F+9: :$* 8 8+9:"::*,Hb8 b8 n#@ACE(F.C8I$H>45>@A>KL>M*;+(8B(CA.>@DCN>?O  RPE F 8A+Q8+V8 jjbn8%FY8$b8 %#6 QUW YZ^*b1d4g8i@kCWPr$\ R45R%&OZ(M[(H\(0]((^(*_(8 `(. R%/JFa AbYd:bYd:+9:):eiWeiW +osw,w}Y+os,#* z {}'4A}K[a$H45CALM* '-. CN  F+E+F}Y$}Y%}Y$%n# 0E$*F45F%&A( <(. F%/ ~"+ N-M,- #!$ "45"%&-. "%/PK t:EA #raykernel/ml/validate/Analyzer.javapackage raykernel.ml.validate; import java.util.Collection; import java.util.LinkedList; import java.util.List; import java.util.Vector; import raykernel.ml.feature.Trainable; import raykernel.stats.KendallsTau; import raykernel.stats.Sorter; /** * * Methods of or analyssis of the results * * @author rlb7g * */ public class Analyzer { public static float getPctCorrect(Collection results, float cutoff) { int correct = 0; int total = 0; for (LineStat stat : results) { if (stat.isBug() && stat.getScore() > cutoff) { correct++; } else if (!stat.isBug() && stat.getScore() <= cutoff) { correct++; } total++; } return (float) correct / (float) total; } public Analyzer() { } public float getAvgBestFmeasure(Vector> name) { float total = 0; float count = 0; for (Collection runStats : name) { total += getBestFmeasure(runStats); count++; } return total / count; } public float getAvgKendallsTau(Vector> name, String rankFeature, int bins) { float total = 0; float count = 0; for (Vector runStats : name) { total += getTau(runStats, rankFeature, bins); count++; } return total / count; } public float getBestFmeasure(Collection results) { //float interval = Stats.getAverageScore( results ) / 10; //if( interval < 0.05 ) float interval = (float) 0.05; //float interval = (float) 0.1; float best_fmeas = 0; for (float i = 0; i < 1; i += interval) { float p = Stats.getPrecision(results, i); float r = Stats.getRecall(results, i); //float fmeas = Stats.getPctCorrect(results, i); float fmeas = (2 * p * r) / (p + r); //io.Out.println( "[cutoff=" + i + "] [prec=" + p + "] [recall=" + r + "] [fmeas = " + fmeas + "]"); if (fmeas > best_fmeas) { best_fmeas = fmeas; } float stop = (float) 0.000001; if (fmeas < stop) { break; } } //io.Out.println("best fmeas = " + best_fmeas + " @ cutoff = " + best_cutoff ); return best_fmeas; //return Stats.getPctCorrect(results, best_cutoff); } //will change order of runstats public float getTau(Vector runStats, String estFeature, int bins) { List sortCorrect = new LinkedList(); List sortByEval = new LinkedList(); for (LineStat l : runStats) { sortCorrect.add(l.getTrainable()); sortByEval.add(l.getTrainable()); } Sorter.sortByFeature(sortCorrect, runStats.get(0).getScoreFeature()); Sorter.sortByFeature(sortByEval, estFeature); raykernel.io.Out.println("sorting by: " + runStats.get(0).getScoreFeature() + " and " + estFeature); return (float) KendallsTau.computeDistance(sortCorrect, sortByEval, bins); } public void printScoreRatio(Collection results) { float bug = Stats.getAvgBugScore(results); float non = Stats.getAvgNonBugScore(results); raykernel.io.Out.println("AvgBugScore = " + bug); raykernel.io.Out.println("AvgNonBugScore = " + non); raykernel.io.Out.println("Ratio = " + (bug / non)); } public void printScores(Collection results) { for (LineStat ls : results) { raykernel.io.Out.println(ls); } } } PK w:#V\ #raykernel/ml/validate/WekaVal.class1qraykernel/ml/validate/WekaValjava/lang/Object classifierLweka/classifiers/Classifier; classNameLjava/lang/String; otherFeatures[Ljava/lang/String; trainingSetLjava/util/Collection; Signature8Ljava/util/Collection;O(Ljava/util/Collection;Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/String;)VCode  ()V     java/lang/Class   newInstance()Ljava/lang/Object;"weka/classifiers/Classifier $  &('java/lang/System )*errLjava/io/PrintStream;,!could not instantiate classifier! .0/java/io/PrintStream 12println(Ljava/lang/String;)V 465java/lang/Exception 7printStackTraceLineNumberTableLocalVariableTablethisLraykernel/ml/validate/WekaVal;Ljava/lang/Class;eLjava/lang/Exception; runCrossVal()F BDCraykernel/ml/core/Trainer EFextractInstancesR(Ljava/util/Collection;Ljava/lang/String;[Ljava/lang/String;)Lweka/core/Instances;Hweka/classifiers/Evaluation GJ K(Lweka/core/Instances;)VMjava/util/Random L GP QRcrossValidateModel[(Lweka/classifiers/Classifier;Lweka/core/Instances;ILjava/util/Random;[Ljava/lang/Object;)V GT UVfMeasure(I)DeTestLweka/classifiers/Evaluation;insLweka/core/Instances;exrunStraightVal+(Ljava/util/Collection;Ljava/lang/String;)D B_ `>(Ljava/util/Collection;Ljava/lang/String;[Ljava/lang/String;)V Bb cdtrainClassifier (Lweka/classifiers/Classifier;)V Gf gh evaluateModelI(Lweka/classifiers/Classifier;Lweka/core/Instances;[Ljava/lang/Object;)[D validationSetbugNametLraykernel/ml/core/Trainer; train_inseval_ins SourceFile WekaVal.java!   2**-**+*,!#:%+-3"48&  !"#$%,&1(9>2:;2 2<22 $ =>?@=***AMGY,IL+*#, LYNO+SN-3 5648.23/<6?7A;D9*=:;WX-YZ7[>\]cBY***^N-*#a***A:+,*A:GYI:*#eWS:38YZ48* ILP-Q8UCVSXZ]\_aa9Rc:;ci cjOklCWX-6mZ8+nZ\[>opPK 4v:SZd2 2 "raykernel/ml/validate/WekaVal.javapackage raykernel.ml.validate; import java.util.Collection; import java.util.Random; import raykernel.ml.core.Trainer; import raykernel.ml.feature.Trainable; import weka.classifiers.Classifier; import weka.classifiers.Evaluation; import weka.core.Instances; public class WekaVal { private Classifier classifier; private final String className; private final String[] otherFeatures; private final Collection trainingSet; public WekaVal(Collection trainingSet, Class classifier, String className, String... otherFeatures) { this.className = className; //this.bugName = className; this.otherFeatures = otherFeatures; this.trainingSet = trainingSet; //this.validationSet = validationSet; try { this.classifier = (Classifier) classifier.newInstance(); } catch (Exception e) { System.err.println("could not instantiate classifier!"); e.printStackTrace(); } } public float runCrossVal() { //Weka Evaluator Evaluation eTest; Instances ins = Trainer.extractInstances(trainingSet, className, otherFeatures); try { eTest = new Evaluation(ins); eTest.crossValidateModel(classifier, ins, 10, new Random()); //String summary = eTest.toSummaryString(); //io.Out.println(summary); //io.Out.println("prec = " + eTest.precision(0) ); //io.Out.println("recal = " + eTest.recall(0) ); //io.Out.println("fmeas = " + eTest.fMeasure(0) ); return (float) eTest.fMeasure(1); //return (float) eTest.pctCorrect(); } catch (Exception ex) { ex.printStackTrace(); } return 0; } public double runStraightVal(Collection validationSet, String bugName) { Trainer t = new Trainer(trainingSet, className, otherFeatures); //train t.trainClassifier(classifier); //Weka Evaluator Evaluation eTest; Instances train_ins = Trainer.extractInstances(trainingSet, className, otherFeatures); Instances eval_ins = Trainer.extractInstances(validationSet, bugName, otherFeatures); try { eTest = new Evaluation(train_ins); eTest.evaluateModel(classifier, eval_ins); return eTest.fMeasure(1); //String summary = eTest.toSummaryString(); //io.Out.println(summary); } catch (Exception ex) { ex.printStackTrace(); } return 0; } } PK w:;`$raykernel/ml/validate/CrossVal.class1raykernel/ml/validate/CrossValjava/lang/Object classifierLweka/classifiers/Classifier; classNameLjava/lang/String;filesLjava/util/List;numFoldsI otherFeatures[Ljava/lang/String;resultsLjava/util/Vector; SignatureHLjava/util/Vector;>;J(Ljava/util/List;ILjava/lang/Class;Ljava/lang/String;[Ljava/lang/String;)VCode  ()V      "!java/lang/Class #$ newInstance()Ljava/lang/Object;&weka/classifiers/Classifier (  *,+java/lang/System -.errLjava/io/PrintStream;0!could not instantiate classifier! 243java/io/PrintStream 56println(Ljava/lang/String;)V *8 9:exit(I)V < >java/lang/ExceptionLineNumberTableLocalVariableTablethis Lraykernel/ml/validate/CrossVal;Ljava/lang/Class;eLjava/lang/Exception;getOrderedResults()Ljava/util/Vector;J()Ljava/util/Vector;>; J  getResults6()Ljava/util/Vector;Njava/util/Vector M MQ RSiterator()Ljava/util/Iterator; UWVjava/util/Iterator X$next MZ [\addAll(Ljava/util/Collection;)Z U^ _`hasNext()ZretrunLocalVariableTypeTable4Ljava/util/Vector; Mf : hjiraykernel/util/Permute klrandomPartition$(Ljava/util/List;I)[Ljava/util/List;nraykernel/ml/core/ValidationSet m mq rssetValidationData(Ljava/util/List;)V mu vsaddTrainingBlocks Mx yzadd(Ljava/lang/Object;)Z M| }~get(I)Ljava/lang/Object; m getTrainingData()Ljava/util/List;raykernel/ml/core/Trainer >(Ljava/util/Collection;Ljava/lang/String;[Ljava/lang/String;)V trainClassifier (Lweka/classifiers/Classifier;)Vraykernel/ml/core/Evaluator getTrainingSet()Lweka/core/Instances; Z(Lweka/classifiers/Classifier;Lweka/core/Instances;Ljava/lang/String;[Ljava/lang/String;)V m getValidationData Qjava/util/Listraykernel/ml/feature/Trainable  runDetector#(Lraykernel/ml/feature/Trainable;)Vraykernel/ml/validate/LineStat  featureNames()[Ljava/lang/String; G(Lraykernel/ml/feature/Trainable;Ljava/lang/String;Ljava/lang/String;)V validations partition[Ljava/util/List;iv!Lraykernel/ml/core/ValidationSet;jsettLraykernel/ml/core/Trainer;Lraykernel/ml/core/Evaluator;f Lraykernel/ml/feature/Trainable;5Ljava/util/Vector;2Ljava/util/List; SourceFile CrossVal.java! 7*****-%':)/17*+; #=?* $( )*.#0%2-41768@H7AB7 7 7C77 % DEFGH/*I?<@ ABKGL.MYOL*IPN-TMM+,YW-]+?ACE#C,H@ .AB&abc&adbdb _MY*eL*;*gM>?mYo:,2p6 ,2t*+wW**MYOI>*IMYOwW*>+{m:Y**:*'Y*'**:+{m:T:]+{m:2T:*I{MY2*wW]ʄ*5?rN PRT&U.X4Z:\CXO`VRacleqgekmoruwyw}&I}Sk^@ _AB SGG &01 n b  D&#c SPK 4v:*6 #raykernel/ml/validate/CrossVal.javapackage raykernel.ml.validate; import java.util.List; import java.util.Vector; import raykernel.ml.core.Evaluator; import raykernel.ml.core.Trainer; import raykernel.ml.core.ValidationSet; import raykernel.ml.feature.Trainable; import raykernel.util.Permute; import weka.classifiers.Classifier; public class CrossVal { Classifier classifier; String className; private final List files; int numFolds; String[] otherFeatures; Vector> results; //average scores /** * For K-fold cross validation, we partition the files into K groups. We * select one group that we will do the evaluation on, Then we train on the * other K-1. Repeat so each group is used for validation once. * * Average everthing in the end. * * @param files * @param numFolds */ @SuppressWarnings("unchecked") public CrossVal(List