fix compare 0 bug and cluster of tokens

This commit is contained in:
mimic
2020-06-10 11:52:26 +02:00
parent a26275cf4a
commit 5c2d78e370
2 changed files with 13 additions and 9 deletions
+7 -4
View File
@@ -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('_')[0].split('-')[1])
matches['sizes']=matches['pairs_key'].apply(lambda x:x.split(root)[1].split('/')[0].split('-')[1]) matches['sizes']=matches['pairs_key'].apply(lambda x:x.split(root)[1].split('/')[0].split('-')[1])
if level == 'tokens': 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': # if level == 'tokens':
# matches['actions'] = matches['pairs_key'].apply(lambda x: x.split('/')[0].split('-')[2]) # 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]) # 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] match = matches[matches['sizes'] == s]
if level == 'tokens': if level == 'tokens':
actions = match['tokens'].unique().tolist() actions = match['actions'].unique().tolist()
for action in actions: for action in actions:
match = match[match['tokens'] == action] match = match[match['actions'] == action]
clusterCore(clusterPath, level, match, pairsPath, root, s,action) clusterCore(clusterPath, level, match, pairsPath, root, s,action)
# elif level == 'tokens': # elif level == 'tokens':
# actions = match['actions'].unique().tolist() # actions = match['actions'].unique().tolist()
@@ -200,7 +200,10 @@ def dumpFilesCore(t):
jdk8 = os.environ["JDK8"] 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 # 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) os.makedirs(clusterSavePath, exist_ok=True)
shutil.copy(filePath,join(clusterSavePath,dumpFile)) shutil.copy(filePath,join(clusterSavePath,dumpFile))
# with open(join(clusterSavePath, dumpFile), 'w', encoding='utf-8') as writeFile: # with open(join(clusterSavePath, dumpFile), 'w', encoding='utf-8') as writeFile:
@@ -151,13 +151,14 @@ public class CompareTrees {
public static boolean newCoreCompare( String treeType,ArrayList<String> errorPairs, HashMap<String, String> filenames,JedisPool outerPool ) { public static boolean newCoreCompare( String treeType,ArrayList<String> errorPairs, HashMap<String, String> filenames,JedisPool outerPool ) {
String pairName; String pairName = null;
try (Jedis outer = outerPool.getResource()) { try (Jedis outer = outerPool.getResource()) {
pairName = outer.spop("compare"); pairName = outer.spop("compare");
} // }
if(pairName.equals("0"))
return true;
String matchKey = null; String matchKey = null;
try { // try {
String[] split = pairName.split("/"); String[] split = pairName.split("/");
@@ -235,7 +236,7 @@ public class CompareTrees {
// break; // break;
} }
}catch (Exception e) { }catch (Exception e) {
errorPairs.add(matchKey); errorPairs.add(pairName);
if (pairName == null) if (pairName == null)
return false; return false;
log.debug("{} not comparable", pairName); log.debug("{} not comparable", pairName);