diff --git a/src/main/java/edu/isi/karma/cleaning/ANode.java b/src/main/java/edu/isi/karma/cleaning/ANode.java index a4c17d4..1ec7bed 100755 --- a/src/main/java/edu/isi/karma/cleaning/ANode.java +++ b/src/main/java/edu/isi/karma/cleaning/ANode.java @@ -47,13 +47,15 @@ public void addChild(ANode a) // all constant node and same content public boolean isvalid() { - if(orgPos.size()<= 1) + if(orgPos.size()<= 1){ return true; + } for(int i=1; i vec) { HashMap d = new HashMap(); int score = 0; for (int i = 0; i < vec.size(); i++) { - if (d.containsKey(vec.get(i).text)) + if (d.containsKey(vec.get(i).text)){ continue; + } for (int j = 0; j < vec.size(); j++) { if (vec.get(j).text.compareTo(vec.get(i).text) == 0 && i != j && vec.get(j).text.compareTo(" ") != 0) { diff --git a/src/main/java/edu/isi/karma/cleaning/Feature1.java b/src/main/java/edu/isi/karma/cleaning/Feature1.java index 2d8ceb5..457a9d2 100755 --- a/src/main/java/edu/isi/karma/cleaning/Feature1.java +++ b/src/main/java/edu/isi/karma/cleaning/Feature1.java @@ -35,12 +35,14 @@ public Feature1(String tar,Vector xNodes) public double computerScore() { double res = 0.0; - if(xNodes == null) + if(xNodes == null){ return 0.0; + } for(TNode x:xNodes) { - if(x.text.compareTo(target)==0) + if(x.text.compareTo(target)==0){ res += 1; + } } return res; } diff --git a/src/main/java/edu/isi/karma/cleaning/Feature2.java b/src/main/java/edu/isi/karma/cleaning/Feature2.java index 697ffcb..4637f58 100755 --- a/src/main/java/edu/isi/karma/cleaning/Feature2.java +++ b/src/main/java/edu/isi/karma/cleaning/Feature2.java @@ -36,12 +36,14 @@ public Feature2(int type,Vector xNodes) public double computerScore() { double res = 0.0; - if(xNodes == null) + if(xNodes == null){ return 0.0; + } for(TNode x:xNodes) { - if(x.type == type) + if(x.type == type){ res += 1; + } } return res; } diff --git a/src/main/java/edu/isi/karma/cleaning/Loop.java b/src/main/java/edu/isi/karma/cleaning/Loop.java index 99079bd..d06f256 100755 --- a/src/main/java/edu/isi/karma/cleaning/Loop.java +++ b/src/main/java/edu/isi/karma/cleaning/Loop.java @@ -29,8 +29,9 @@ public Loop mergewith(Loop a) if(this.looptype == a.looptype) { Segment segment = this.loopbody.mergewith(a.loopbody); - if(segment == null) + if(segment == null){ return null; + } Loop l = new Loop(segment, looptype); return l; } @@ -42,8 +43,9 @@ public Loop mergewith(Loop a) public Loop mergewith(Segment a) { Segment segment = this.loopbody.mergewith(a); - if(segment == null) + if(segment == null){ return null; + } Loop l = new Loop(segment, looptype); return l; } @@ -74,9 +76,9 @@ public GrammarTreeNode mergewith(GrammarTreeNode a) { else if(a.getNodeType().compareTo("Segment")==0) { return this.mergewith((Segment)a); - } - else + }else{ return null; + } } public String getNodeType() { diff --git a/src/main/java/edu/isi/karma/cleaning/MultipleStringAlign.java b/src/main/java/edu/isi/karma/cleaning/MultipleStringAlign.java index 9352600..8145690 100755 --- a/src/main/java/edu/isi/karma/cleaning/MultipleStringAlign.java +++ b/src/main/java/edu/isi/karma/cleaning/MultipleStringAlign.java @@ -65,16 +65,18 @@ public void generateChildren(ANode a) length.add(e[2]-e[1]); } ANode aNode = new ANode(orgPos, tarPos, length, a.exps); - if(aNode.isvalid()) + if(aNode.isvalid()){ a.addChild(aNode); + } } } // iteratively generate the combinations public void getCrossIndex(Vector indexs,Vector> configs) { int k = indexs.size(); int[] com = new int[k]; - for (int i = 0; i < k; i++) - com[i] = 0; + for (int i = 0; i < k; i++){ + com[i] = 0; + } while (com[k - 1] < indexs.get(k-1)) { Vector res = new Vector(); for (int i = 0; i < k; i++) @@ -84,15 +86,17 @@ public void getCrossIndex(Vector indexs,Vector> configs) { } configs.add(res); int t = k - 1; - while (t != 0 && com[t] == indexs.get(t)-1) - t--; + while (t != 0 && com[t] == indexs.get(t)-1){ + t--; + } com[t]++; if(t==0 && com[t] >= indexs.get(0)) { break; } - for (int i = t + 1; i < k; i++) - com[i] = 0; + for (int i = t + 1; i < k; i++){ + com[i] = 0; + } } } //{[orgstartPos, orgendPos ], ...} @@ -105,8 +109,9 @@ public Vector findNext(String org, String tar, int pos) segs.add(elem); return segs; } - if (pos >= tar.length()) + if (pos >= tar.length()){ return segs; + } String tmp = ""; tmp += tar.charAt(pos); // identify the const string @@ -118,8 +123,9 @@ public Vector findNext(String org, String tar, int pos) tvec+= tar.charAt(cnt); cnt++; tmp = ""; - if(cnt >= tar.length()) + if(cnt >= tar.length()){ break; + } tmp += tar.charAt(cnt); q = org.indexOf(tmp); } diff --git a/src/main/java/edu/isi/karma/cleaning/OutlierDetector.java b/src/main/java/edu/isi/karma/cleaning/OutlierDetector.java index 0f9ffa4..6f6cc88 100755 --- a/src/main/java/edu/isi/karma/cleaning/OutlierDetector.java +++ b/src/main/java/edu/isi/karma/cleaning/OutlierDetector.java @@ -39,8 +39,9 @@ public OutlierDetector() } public double getDistance(double[] x,double[] y) { - if(x.length != y.length) + if(x.length != y.length){ return Double.MAX_VALUE; + } double value = 0.0; for(int i = 0; i testdata,double[] meanVector, // pid: [{rawstring, code}] public void buildMeanVector(HashMap> data) { - if(data == null) + if(data == null){ return; + } for(String key:data.keySet()) { Vector vs = data.get(key); diff --git a/src/main/java/edu/isi/karma/cleaning/Position.java b/src/main/java/edu/isi/karma/cleaning/Position.java index 80986b1..4121ae3 100755 --- a/src/main/java/edu/isi/karma/cleaning/Position.java +++ b/src/main/java/edu/isi/karma/cleaning/Position.java @@ -27,8 +27,9 @@ public Position(Vector absPos, Vector lcxt, this.absPosition = absPos; this.orgStrings.addAll(orgStrings); this.tarStrings.addAll(tarStrings); - if (itInterpretor == null) + if (itInterpretor == null){ itInterpretor = new Interpretor(); + } // occurance of a reg pattern this.counters.add(-1); this.counters.add(1); @@ -56,7 +57,9 @@ public void getString(Vector x, int cur, String path, Double value, if (!smap.keySet().contains(path)) { String res = UtilTools.escape(path); if (!smap.containsKey(res) && res.length() != 0) + { smap.put(res, value); // store the string of all sizes + } } } if (x == null || x.size() == 0) { @@ -67,16 +70,18 @@ public void getString(Vector x, int cur, String path, Double value, if (!smap.keySet().contains(path)) { String res = UtilTools.escape(path); if (!smap.containsKey(res) && res.length() != 0) + { smap.put(res, value); // store the string of all sizes + } } } return; } TNode t = x.get(cur); if (t.text.compareTo("ANYTOK") != 0 && t.text.length() > 0) { - if (!isleft) + if (!isleft){ getString(x, cur + 1, path + t.text, value + 2, smap, false); - else { + }else { getString(x, cur - 1, t.text + path, value + 2, smap, true); } } @@ -102,9 +107,9 @@ public void getString(Vector x, int cur, String path, Double value, } else { s += "" + t.getType(); } - if (!isleft) + if (!isleft){ getString(x, cur + 1, path + s, value + 1, smap, false); - else { + }else { getString(x, cur - 1, s + path, value + 1, smap, true); } } @@ -113,9 +118,9 @@ public void getString(Vector x, int cur, String path, Double value, public Vector mergeCNXT(Vector a, Vector b, String option) { Vector xNodes = new Vector(); - if (a == null || b == null) + if (a == null || b == null){ return null; - else { + }else { int leng = Math.min(a.size(), b.size()); if (option.compareTo(Segment.LEFTPOS) == 0) { for (int i = 1; i <= leng; i++) { @@ -161,14 +166,16 @@ public Vector mergeCNXT(Vector a, Vector b, } } } - if (xNodes.size() == 0) + if (xNodes.size() == 0){ return null; + } return xNodes; } public Position mergewith(Position b) { - if (this == null || b == null) + if (this == null || b == null){ return null; + } Vector tmpIntegers = new Vector(); tmpIntegers.addAll(this.absPosition); tmpIntegers.retainAll(b.absPosition); @@ -184,8 +191,9 @@ public Position mergewith(Position b) { // this.leftContextNodes = g_lcxtNodes; // this.rightContextNodes = g_rcxtNodes; if (tmpIntegers.size() == 0 && g_lcxtNodes == null - && g_rcxtNodes == null) + && g_rcxtNodes == null){ return null; + } boolean loop = this.isinloop || b.isinloop; Vector aStrings = new Vector(); @@ -251,9 +259,9 @@ public double getScore() { if (this.rightContextNodes != null) { rsize = rightContextNodes.size(); } - if (lsize == 0 && rsize == 0) + if (lsize == 0 && rsize == 0){ return 1; - else { + }else { for (int i = 0; i < lsize; i++) { if (leftContextNodes.get(i).text.compareTo("ANYTOK") != 0 && leftContextNodes.get(i).type != TNode.ANYTYP) { @@ -277,21 +285,25 @@ public void emptyState() { public Vector rules = new Vector(); public String toProgram() { - if (curState >= rules.size()) + if (curState >= rules.size()){ return "null"; + } String rule = rules.get(curState); - if (!isinloop) + if (!isinloop){ rule = rule.replace("counter", counters.get(1) + ""); + } curState++; return rule; } public String getRule(int index) { - if (index >= rules.size()) + if (index >= rules.size()){ return "null"; + } String rule = rules.get(index); - if (!isinloop) + if (!isinloop){ rule = rule.replace("counter", counters.get(1) + ""); + } return rule; } @@ -322,23 +334,27 @@ public String VerifySpace(int itercnt) { ProgramRule programRule = new ProgramRule(tmpRule); String val = programRule.transform(this.orgStrings .get(j)); - if(val.indexOf("None")!= -1) + if(val.indexOf("None")!= -1){ break; + } r += val+","; cnt ++; } - if(r.length()<=1) + if(r.length()<=1){ return "null"; + } if (this.tarStrings.get(j).compareTo(r.substring(0,r.length()-1)) != 0) { isvalid = false; break; } } if (isvalid) { - if(itercnt == 0) + if(itercnt == 0){ return rule; - else + } + else { itercnt--; // valid number - 1 + } } } else { @@ -353,10 +369,11 @@ public String VerifySpace(int itercnt) { } } if (isValid) { - if(itercnt == 0) + if(itercnt == 0){ return rule; - else + }else{ itercnt--; + } } } } @@ -384,8 +401,9 @@ public void createTotalOrderVector() { String negString = ""; for (String a : lMap.keySet()) { for (String b : rMap.keySet()) { - if (a.compareTo(b) == 0 && a.compareTo("ANY") == 0) + if (a.compareTo(b) == 0 && a.compareTo("ANY") == 0){ continue; + } Double key = lMap.get(a) + rMap.get(b); reString = String.format( "indexOf(value,\'%s\',\'%s\',counter)", a, b); diff --git a/src/main/java/edu/isi/karma/cleaning/ProgSynthesis.java b/src/main/java/edu/isi/karma/cleaning/ProgSynthesis.java index ed6c2b4..9090f41 100755 --- a/src/main/java/edu/isi/karma/cleaning/ProgSynthesis.java +++ b/src/main/java/edu/isi/karma/cleaning/ProgSynthesis.java @@ -100,8 +100,9 @@ public void mergePartitions(Vector pars) { } } } - if (pos[0] != -1 && pos[1] != -1) + if (pos[0] != -1 && pos[1] != -1){ UpdatePartitions(pos[0], pos[1], pars); + } } public void UpdatePartitions(int i, int j, Vector pars) { @@ -136,8 +137,9 @@ public Collection producePrograms(Vector pars) { long startTime = System.currentTimeMillis(); while (i < prog_cnt) { ProgramRule r = prog.toProgram1(); - if (r == null) + if (r == null){ return null; + } String xString = ""; int termCnt = 0; boolean findRule = true; @@ -157,9 +159,10 @@ public Collection producePrograms(Vector pars) { for (Partition p : prog.partitions) { if (p.label.compareTo(xString) == 0) { String newRule = p.toProgram(); - if (ConfigParameters.debug == 1) + if (ConfigParameters.debug == 1){ System.out.println("updated Rule: " + p.label + ": " + newRule); + } if (newRule.contains("null")) { findRule = false; break; @@ -169,8 +172,9 @@ public Collection producePrograms(Vector pars) { } termCnt++; } - if (findRule) + if (findRule){ rules.add(r); + } this.ruleNo += termCnt; // accumulate the no of rules while the i++; } diff --git a/src/main/java/edu/isi/karma/cleaning/Program.java b/src/main/java/edu/isi/karma/cleaning/Program.java index b220f32..7850a59 100755 --- a/src/main/java/edu/isi/karma/cleaning/Program.java +++ b/src/main/java/edu/isi/karma/cleaning/Program.java @@ -13,11 +13,13 @@ public Program(Vector pars) for(int i=0;i1) + if(partitions.size()>1){ this.learnClassifier(); + } } public void learnClassifier() { @@ -73,11 +75,13 @@ public ProgramRule toProgram1() { continue; } String rule = p.toProgram(); - if(rule.contains("null")) + if(rule.contains("null")){ return null; + } pr.addRule(p.label, rule); - if(ConfigParameters.debug == 1) + if(ConfigParameters.debug == 1){ System.out.println(pr.getStringRule(p.label)); + } score += p.getScore(); } score = score/this.partitions.size(); @@ -96,10 +100,12 @@ public ProgramRule toProgram1() { return pr; } String s = partitions.get(0).toProgram(); - if(s.contains("null")) + if(s.contains("null")){ return null; - if(ConfigParameters.debug == 1) + } + if(ConfigParameters.debug == 1){ System.out.println(""+s); + } score = this.partitions.get(0).getScore(); pr.addRule(partitions.get(0).label, s); return pr; diff --git a/src/main/java/edu/isi/karma/cleaning/ProgramRule.java b/src/main/java/edu/isi/karma/cleaning/ProgramRule.java index f6cc413..14a6111 100755 --- a/src/main/java/edu/isi/karma/cleaning/ProgramRule.java +++ b/src/main/java/edu/isi/karma/cleaning/ProgramRule.java @@ -30,8 +30,9 @@ public String transform(String value) } public void initInterpretor() { - if(itInterpretor == null) + if(itInterpretor == null){ itInterpretor = new Interpretor(); + } } public InterpreterType getRuleForValue(String value) { @@ -42,8 +43,9 @@ public InterpreterType getRuleForValue(String value) public String getClassForValue(String value) { String labelString = "attr_0"; - if(value.length() == 0) + if(value.length() == 0){ return labelString; + } if(pClassifier != null) { labelString = pClassifier.getLabel(value); diff --git a/src/main/java/edu/isi/karma/cleaning/RecordDistiller.java b/src/main/java/edu/isi/karma/cleaning/RecordDistiller.java index 1cb6540..f148800 100755 --- a/src/main/java/edu/isi/karma/cleaning/RecordDistiller.java +++ b/src/main/java/edu/isi/karma/cleaning/RecordDistiller.java @@ -216,8 +216,9 @@ public static void main(String[] args) int id = 0; HashMap id2String = new HashMap(); while ((pair = cr.readNext()) != null) { - if (pair == null || pair.length <= 1) + if (pair == null || pair.length <= 1){ break; + } Ruler ruler = new Ruler(); ruler.setNewInput(pair[0]); distiller.readRecord(""+id, ruler.vec); diff --git a/src/main/java/edu/isi/karma/cleaning/Ruler.java b/src/main/java/edu/isi/karma/cleaning/Ruler.java index 86db644..3a0d322 100755 --- a/src/main/java/edu/isi/karma/cleaning/Ruler.java +++ b/src/main/java/edu/isi/karma/cleaning/Ruler.java @@ -132,15 +132,16 @@ public int evalPos(String input,Vector t, String option) if(option.compareTo("from_beginning")==0) { int pos = Ruler.Search(vec,t, 0); - if(pos == -1) + if(pos == -1){ return -1; + } if(incld) { return pos; } else { - if(pos0) { return pos-1; @@ -148,9 +149,9 @@ public int evalPos(String input,Vector t, String option) else { return 0; } - - else + }else{ return vec.size()-1; + } } } @@ -159,21 +160,24 @@ public int evalPos(String input,Vector t, String option) Vector tmpvec = (Vector)this.vec.clone(); Collections.reverse(tmpvec); int pos = Ruler.Search(tmpvec,t, 0); - if(pos == -1) + if(pos == -1){ return -1; + } if(incld) { - if(this.vec.size()- pos-1>=0 && this.vec.size()- pos-1 <= vec.size()) + if(this.vec.size()- pos-1>=0 && this.vec.size()- pos-1 <= vec.size()){ return this.vec.size()- pos-1; - else + }else{ return 0; + } } else { - if(this.vec.size()- pos>=0 && this.vec.size()- pos <= vec.size()) + if(this.vec.size()- pos>=0 && this.vec.size()- pos <= vec.size()){ return this.vec.size()- pos; - else + }else{ return 0; + } } } } @@ -282,16 +286,17 @@ public String print() for(int i =0;i"; } return res; diff --git a/src/main/java/edu/isi/karma/cleaning/Section.java b/src/main/java/edu/isi/karma/cleaning/Section.java index 9707079..f837d6e 100755 --- a/src/main/java/edu/isi/karma/cleaning/Section.java +++ b/src/main/java/edu/isi/karma/cleaning/Section.java @@ -18,11 +18,12 @@ public Section(Position[] p,Vector orgStrings,Vector tarStrings, pair = p; this.orgStrings = orgStrings; this.tarStrings = tarStrings; - if(itInterpretor==null) + if(itInterpretor==null){ itInterpretor = new Interpretor(); - if(supermode == 0) + } + if(supermode == 0){ this.createTotalOrderVector(); - else + }else { this.reiniteRules(); } @@ -65,9 +66,9 @@ public GrammarTreeNode mergewith(GrammarTreeNode a) { Section sec = (Section)a; Position x = this.pair[0].mergewith(sec.pair[0]); Position y = this.pair[1].mergewith(sec.pair[1]); - if(x== null || y == null) + if(x== null || y == null){ return null; - else + }else { Position[] pa = {x,y}; boolean loop = this.isinloop || sec.isinloop; @@ -166,8 +167,9 @@ public void emptyState() { } public String getRule(long index) { - if(index > this.rules.size()) + if(index > this.rules.size()){ return "null"; + } String rule = ""; int[] loc = this.rules.get(((int)index)); pair[0].isinloop = this.isinloop; diff --git a/src/main/java/edu/isi/karma/cleaning/Segment.java b/src/main/java/edu/isi/karma/cleaning/Segment.java index b89fc47..ee07bab 100755 --- a/src/main/java/edu/isi/karma/cleaning/Segment.java +++ b/src/main/java/edu/isi/karma/cleaning/Segment.java @@ -59,8 +59,9 @@ public Segment(int start, int end, Vector mapping,Vector orgNodes, else { repString += tarNodes.get(this.start).getType(); - if(end >start+1) + if(end >start+1){ repString += tarNodes.get(this.end-1).getType(); + } } this.createTotalOrderVector(); } @@ -97,8 +98,9 @@ public Vector getRightCxt(int c, Vector x) Vector res = new Vector(); while(i=x.size()) + if((c+i)>=x.size()){ break; + } res.add(x.get(c+i)); i++; } @@ -248,8 +250,9 @@ public Segment mergewith(Segment s) } } } - if(newSections.size() ==0) + if(newSections.size() ==0){ return null; + } boolean loop = this.isinloop || s.isinloop; Segment res = new Segment(newSections,loop); return res; @@ -367,8 +370,9 @@ public String toProgram() { while(curState indexs,Vector> configs) { int k = indexs.size(); int[] com = new int[k]; - for (int i = 0; i < k; i++) - com[i] = 0; + for (int i = 0; i < k; i++){ + com[i] = 0; + } while (com[k - 1] < indexs.get(k-1)) { Vector res = new Vector(); for (int i = 0; i < k; i++) @@ -75,15 +76,17 @@ public void getCrossIndex(Vector indexs,Vector> configs) { return; } int t = k - 1; - while (t != 0 && com[t] == indexs.get(t)-1) - t--; + while (t != 0 && com[t] == indexs.get(t)-1){ + t--; + } com[t]++; if(t==0 && com[t] >= indexs.get(0)) { break; } - for (int i = t + 1; i < k; i++) - com[i] = 0; + for (int i = t + 1; i < k; i++){ + com[i] = 0; + } } } public String prog1(){ @@ -94,14 +97,16 @@ public String prog1(){ if (gt.getNodeType().compareTo("segment") == 0) { Segment seg = (Segment)gt; String s = seg.verifySpace(); - if (s.indexOf("null")!= -1) + if (s.indexOf("null")!= -1){ return "null"; + } res += s+"+"; } else if (gt.getNodeType().compareTo("loop") == 0) { Loop p = (Loop) gt; String x = p.verifySpace(); - if(x.indexOf("null")!= -1) + if(x.indexOf("null")!= -1){ return "null"; + } if (p.looptype == Loop.LOOP_START) { res += "loop(value,r\"" + x + "+"; } else if (p.looptype == Loop.LOOP_END) { @@ -138,8 +143,9 @@ public String toProgram() } public String prog0() { while (true) { - if (curState >= indexes.size()) + if (curState >= indexes.size()){ return "null"; + } Vector xIntegers = indexes.get(curState); String res = ""; for (int i = 0; i < xIntegers.size(); i++) { diff --git a/src/main/java/edu/isi/karma/cleaning/Test.java b/src/main/java/edu/isi/karma/cleaning/Test.java index a0f2a0f..005b7db 100755 --- a/src/main/java/edu/isi/karma/cleaning/Test.java +++ b/src/main/java/edu/isi/karma/cleaning/Test.java @@ -51,15 +51,17 @@ public static void test4(String dirpath) { String[] pair; int index = 0; while ((pair = cr.readNext()) != null) { - if (pair == null || pair.length <= 1) + if (pair == null || pair.length <= 1){ break; + } entries.add(pair); String[] line = {pair[0],pair[1],"","","wrong"}; // org, tar, tarcode, label xHashMap.put(index + "", line); index++; } - if (entries.size() <= 1) + if (entries.size() <= 1){ continue; + } ExampleSelection expsel = new ExampleSelection(); expsel.firsttime = true; expsel.inite(xHashMap,null); @@ -78,14 +80,15 @@ public static void test4(String dirpath) { psProgSynthesis.inite(examples); Vector pls = new Vector(); Collection ps = psProgSynthesis.run_main(); - if (ps != null) + if (ps != null){ pls.addAll(ps); - else { + }else { System.out.println("Cannot find any rule"); } String[] wexam = null; - if (pls.size() == 0) + if (pls.size() == 0){ break; + } long t1 = System.currentTimeMillis(); for (int i = 0; i < pls.size(); i++) { @@ -101,8 +104,9 @@ public static void test4(String dirpath) { UtilTools.StringColorCode(entries.get(j)[0], tmps, dict); String s = dict.get("Tar"); res += s+"\n"; - if (ConfigParameters.debug == 1) + if (ConfigParameters.debug == 1){ System.out.println("result: " + dict.get("Tardis")); + } if (s == null || s.length() == 0) { String[] ts = {"<_START>" + entries.get(j)[0] + "<_END>","",tmps,classlabel,"wrong"}; xHashMap.put(j + "", ts); @@ -156,8 +160,9 @@ public static void test4(String dirpath) { xHashMap.put(j + "", ts); } } - if (wexam == null) + if (wexam == null){ break; + } resultString.add(res); } records.put(f.getName()+examples.size(), resultString); @@ -251,11 +256,13 @@ public static void test0_sub(Vector all, Vector cand, psProgSynthesis.inite(tmp); Vector pls = new Vector(); Collection ps = psProgSynthesis.run_main(); - if (ps != null) + if (ps != null){ pls.addAll(ps); + } String[] wexam = null; - if (pls.size() == 0) + if (pls.size() == 0){ break; + } for (int i = 0; i < pls.size(); i++) { ProgramRule script = pls.get(i); for (int j = 0; j < all.size(); j++) { @@ -304,12 +311,14 @@ public static void test0(String dirpath) { '\0'); String[] pair; while ((pair = cr.readNext()) != null) { - if (pair == null || pair.length <= 1) + if (pair == null || pair.length <= 1){ break; + } entries.add(pair); } - if (entries.size() <= 1) + if (entries.size() <= 1){ continue; + } int cnt = 0; Vector candStrings = new Vector(); candStrings.addAll(entries); diff --git a/src/main/java/edu/isi/karma/cleaning/TestJAVA.java b/src/main/java/edu/isi/karma/cleaning/TestJAVA.java index 1610196..916bbc5 100755 --- a/src/main/java/edu/isi/karma/cleaning/TestJAVA.java +++ b/src/main/java/edu/isi/karma/cleaning/TestJAVA.java @@ -29,8 +29,9 @@ public class TestJAVA { void generate_combos(Vector indexs,Vector> configs) { int k = indexs.size(); int[] com = new int[k]; - for (int i = 0; i < k; i++) - com[i] = 0; + for (int i = 0; i < k; i++){ + com[i] = 0; + } while (com[k - 1] < indexs.get(k-1)) { Vector res = new Vector(); for (int i = 0; i < k; i++) @@ -41,15 +42,17 @@ void generate_combos(Vector indexs,Vector> configs) { //System.out.println(""); configs.add(res); int t = k - 1; - while (t != 0 && com[t] == indexs.get(t)-1) - t--; + while (t != 0 && com[t] == indexs.get(t)-1){ + t--; + } com[t]++; if(t==0 && com[t] >= indexs.get(0)) { break; } - for (int i = t + 1; i < k; i++) - com[i] = 0; + for (int i = t + 1; i < k; i++){ + com[i] = 0; + } } } public static void main(String[] args) diff --git a/src/main/java/edu/isi/karma/cleaning/Tokenizer.java b/src/main/java/edu/isi/karma/cleaning/Tokenizer.java index 0a74fdb..eb5173e 100755 --- a/src/main/java/edu/isi/karma/cleaning/Tokenizer.java +++ b/src/main/java/edu/isi/karma/cleaning/Tokenizer.java @@ -135,7 +135,9 @@ public final void mLWRD() throws RecognitionException { break; default : - if ( cnt1 >= 1 ) break loop1; + if ( cnt1 >= 1 ){ + break loop1; + } EarlyExitException eee = new EarlyExitException(1, input); throw eee; @@ -193,7 +195,9 @@ public final void mNUMBER() throws RecognitionException { break; default : - if ( cnt2 >= 1 ) break loop2; + if ( cnt2 >= 1 ){ + break loop2; + } EarlyExitException eee = new EarlyExitException(2, input); throw eee; diff --git a/src/main/java/edu/isi/karma/cleaning/Traces.java b/src/main/java/edu/isi/karma/cleaning/Traces.java index fac042e..191710f 100755 --- a/src/main/java/edu/isi/karma/cleaning/Traces.java +++ b/src/main/java/edu/isi/karma/cleaning/Traces.java @@ -78,9 +78,9 @@ public void createTraces() { lines.add(segs); break; } - if (pos2Segs.containsKey(curPos)) + if (pos2Segs.containsKey(curPos)){ children = pos2Segs.get(curPos); - else { + }else { children = findSegs(curPos); } if (children == null || children.size() == 0) { @@ -110,8 +110,9 @@ public void createTraces() { break; // otherwise takes too much time } Vector> lLine = this.genLoop(vgt); - if (lLine != null) + if (lLine != null){ lSeg.addAll(lLine); + } } // consolidate this.traceline = consolidateDiffSize(vSeg); @@ -130,8 +131,9 @@ Vector findSegs(int pos) { segs.add(s); return segs; } - if (pos >= tarNodes.size()) + if (pos >= tarNodes.size()){ return segs; + } Vector tmp = new Vector(); tmp.add(tarNodes.get(pos)); // identify the const string @@ -143,8 +145,9 @@ Vector findSegs(int pos) { tvec.add(tarNodes.get(cnt)); cnt++; tmp.clear(); - if(cnt >= tarNodes.size()) + if(cnt >= tarNodes.size()){ break; + } tmp.add(tarNodes.get(cnt)); q = Ruler.Search(orgNodes, tmp, 0); } @@ -191,8 +194,9 @@ Vector findSegs(int pos) { s = new Segment(pos, i + 1, corrm, orgNodes, tarNodes); AllSegs.put(key, s); } - if(s.section.size() >0) + if(s.section.size() >0){ segs.add(s); + } continue; } else if (mappings.size() == 1) { Vector corrm = new Vector(); @@ -212,8 +216,9 @@ Vector findSegs(int pos) { s = new Segment(pos, i + 1, corrm, orgNodes, tarNodes); AllSegs.put(key, s); } - if(s.section.size() >0) + if(s.section.size() >0){ segs.add(s); + } } else { tvec.add(tarNodes.get(i + 1)); int p = Ruler.Search(orgNodes, tvec, 0); @@ -241,8 +246,9 @@ Vector findSegs(int pos) { s = new Segment(pos, i + 1, corrm, orgNodes, tarNodes); AllSegs.put(key, s); } - if(s.section.size() > 0) + if(s.section.size() > 0){ segs.add(s); + } } else { continue; } @@ -266,8 +272,9 @@ public Traces mergewith(Traces t) { //System.out.println(""+line1+"\n"); //System.out.println(""+line2+"\n"); Template nLine = (Template)line1.mergewith(line2); - if(nLine == null) + if(nLine == null){ continue; + } boolean isfind = true; nLines.put(index, nLine); } @@ -283,8 +290,9 @@ public Traces mergewith(Traces t) { //System.out.println(""+line1+"\n"); //System.out.println(""+t.loopline.get(index).get(line2)+"\n"); Template nLine = (Template)line1.mergewith(t.loopline.get(index).get(line2)); - if(nLine == null) + if(nLine == null){ continue; + } if (allLoops.containsKey(index)) { if(allLoops.get(index).containsKey(line2)) { @@ -316,8 +324,9 @@ public Traces mergewith(Traces t) { //System.out.println(""+line1+"\n"); //System.out.println(""+this.loopline.get(index).get(line2)+"\n"); Template nLine = (Template)line1.mergewith(this.loopline.get(index).get(line2)); - if(nLine == null) + if(nLine == null){ continue; + } if (allLoops.containsKey(index)) { if(allLoops.get(index).containsKey(line2)) { @@ -355,8 +364,9 @@ public Traces mergewith(Traces t) { //System.out.println(""+this.loopline.get(index).get(line1)+"\n"); //System.out.println(""+t.loopline.get(index).get(line2)+"\n"); Template nLine = (Template) this.loopline.get(index).get(line1).mergewith(t.loopline.get(index).get(line2)); - if(nLine == null) + if(nLine == null){ continue; + } if (allLoops.containsKey(index)) { if(allLoops.get(index).containsKey(line2)) { @@ -395,8 +405,9 @@ public Traces mergewith(Traces t) { } } - if (lLines.keySet().size() == 0 && nLines.keySet().size() == 0) + if (lLines.keySet().size() == 0 && nLines.keySet().size() == 0){ return null; + } Traces rTraces = new Traces(nLines, lLines); return rTraces; } @@ -436,10 +447,11 @@ public GrammarTreeNode union(GrammarTreeNode x, GrammarTreeNode y) { } boolean loop = s.isinloop || t.isinloop; Segment r; - if(s.isConstSegment() && t.isConstSegment()) + if(s.isConstSegment() && t.isConstSegment()){ r = new Segment(sec,loop); - else + }else{ r = s; + } return r; } if (x.getNodeType().compareTo("loop") == 0 @@ -478,9 +490,9 @@ public GrammarTreeNode union(GrammarTreeNode x, GrammarTreeNode y) { if (s.looptype == t.looptype) { Segment loopbody; - if(s.loopbody.isConstSegment() && t.loopbody.isConstSegment()) + if(s.loopbody.isConstSegment() && t.loopbody.isConstSegment()){ loopbody= s.loopbody; - else { + }else { loopbody = new Segment(sec,true); } r = new Loop(loopbody, t.looptype); @@ -516,8 +528,9 @@ public HashMap> consolidateDiffLoop( } } else { Vector