From 5c2d78e370c03c026a4902309c1eb7f2a8238453 Mon Sep 17 00:00:00 2001 From: mimic Date: Wed, 10 Jun 2020 11:52:26 +0200 Subject: [PATCH] fix compare 0 bug and cluster of tokens --- python/abstractPatch.py | 11 +++++++---- .../edu/lu/uni/serval/richedit/jobs/CompareTrees.java | 11 ++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/python/abstractPatch.py b/python/abstractPatch.py index 3d682f1..aaaa896 100644 --- a/python/abstractPatch.py +++ b/python/abstractPatch.py @@ -87,7 +87,7 @@ def loadPairMulti(root,clusterPath,level): # matches['sizes']=matches['pairs_key'].apply(lambda x:x.split('_')[0].split('-')[1]) matches['sizes']=matches['pairs_key'].apply(lambda x:x.split(root)[1].split('/')[0].split('-')[1]) if level == 'tokens': - matches['tokens']=matches['pairs_key'].apply(lambda x:x.split('/')[0].split('-')[2]) + matches['actions']=matches['pairs_key'].apply(lambda x:x.split('/')[0].split('-')[2]) # if level == 'tokens': # matches['actions'] = matches['pairs_key'].apply(lambda x: x.split('/')[0].split('-')[2]) # matches['tokens']=matches['pairs_key'].apply(lambda x:x.split('/')[0].split('-')[3]) @@ -125,9 +125,9 @@ def cluster(clusterPath,pairsPath, level): match = matches[matches['sizes'] == s] if level == 'tokens': - actions = match['tokens'].unique().tolist() + actions = match['actions'].unique().tolist() for action in actions: - match = match[match['tokens'] == action] + match = match[match['actions'] == action] clusterCore(clusterPath, level, match, pairsPath, root, s,action) # elif level == 'tokens': # actions = match['actions'].unique().tolist() @@ -200,7 +200,10 @@ def dumpFilesCore(t): jdk8 = os.environ["JDK8"] # cmd = "JAVA_HOME='"+jdk8+"' java -jar "+ join(DATA_PATH,'FixPatternMiner-1.0.1.jar') + " " + join(DATA_PATH,'app.properties')+" PATTERN " +key - clusterSavePath = join(clusterPath, root, s, str(idx)) + if level == 'tokens': + clusterSavePath = join(clusterPath, root, s, action, str(idx)) + else: + clusterSavePath = join(clusterPath, root, s, str(idx)) os.makedirs(clusterSavePath, exist_ok=True) shutil.copy(filePath,join(clusterSavePath,dumpFile)) # with open(join(clusterSavePath, dumpFile), 'w', encoding='utf-8') as writeFile: diff --git a/richedit/src/main/java/edu/lu/uni/serval/richedit/jobs/CompareTrees.java b/richedit/src/main/java/edu/lu/uni/serval/richedit/jobs/CompareTrees.java index 79770bb..277f34d 100755 --- a/richedit/src/main/java/edu/lu/uni/serval/richedit/jobs/CompareTrees.java +++ b/richedit/src/main/java/edu/lu/uni/serval/richedit/jobs/CompareTrees.java @@ -151,13 +151,14 @@ public class CompareTrees { public static boolean newCoreCompare( String treeType,ArrayList errorPairs, HashMap filenames,JedisPool outerPool ) { - String pairName; + String pairName = null; try (Jedis outer = outerPool.getResource()) { pairName = outer.spop("compare"); - } - +// } + if(pairName.equals("0")) + return true; String matchKey = null; - try { +// try { String[] split = pairName.split("/"); @@ -235,7 +236,7 @@ public class CompareTrees { // break; } }catch (Exception e) { - errorPairs.add(matchKey); + errorPairs.add(pairName); if (pairName == null) return false; log.debug("{} not comparable", pairName);