Get the max size of edit scripts.
This commit is contained in:
@@ -15,7 +15,6 @@ public class AkkaMiner {
|
|||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(AkkaMiner.class);
|
private static Logger log = LoggerFactory.getLogger(AkkaMiner.class);
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// input data
|
// input data
|
||||||
log.info("Get the input data...");
|
log.info("Get the input data...");
|
||||||
@@ -59,14 +58,6 @@ public class AkkaMiner {
|
|||||||
if (revFile.getName().endsWith(".java")) {
|
if (revFile.getName().endsWith(".java")) {
|
||||||
File prevFile = new File(projectFolder + "/prevFiles/prev_" + revFile.getName());// previous file
|
File prevFile = new File(projectFolder + "/prevFiles/prev_" + revFile.getName());// previous file
|
||||||
File diffentryFile = new File(projectFolder + "/DiffEntries/" + revFile.getName().replace(".java", ".txt")); // DiffEntry file
|
File diffentryFile = new File(projectFolder + "/DiffEntries/" + revFile.getName().replace(".java", ".txt")); // DiffEntry file
|
||||||
// if (!prevFile.exists()) {
|
|
||||||
// log.info("======" + prevFile.getPath());
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// if (!diffentryFile.exists()) {
|
|
||||||
// log.info("======" + diffentryFile.getPath());
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
MessageFile msgFile = new MessageFile(revFile, prevFile, diffentryFile);
|
MessageFile msgFile = new MessageFile(revFile, prevFile, diffentryFile);
|
||||||
msgFiles.add(msgFile);
|
msgFiles.add(msgFile);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ public class MineFixPatternActor extends UntypedActor {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Object message) throws Exception {
|
public void onReceive(Object message) throws Exception {
|
||||||
if (message instanceof WorkMessage) {
|
if (message instanceof WorkMessage) {
|
||||||
|
|||||||
@@ -38,21 +38,22 @@ public class MineFixPatternWorker extends UntypedActor {
|
|||||||
List<MessageFile> files = msg.getMsgFiles();
|
List<MessageFile> files = msg.getMsgFiles();
|
||||||
StringBuilder editScripts = new StringBuilder();
|
StringBuilder editScripts = new StringBuilder();
|
||||||
StringBuilder patchesSourceCode = new StringBuilder();
|
StringBuilder patchesSourceCode = new StringBuilder();
|
||||||
|
int maxSize = 0;
|
||||||
for (MessageFile msgFile : files) {
|
for (MessageFile msgFile : files) {
|
||||||
File revFile = msgFile.getRevFile();
|
File revFile = msgFile.getRevFile();
|
||||||
File prevFile = msgFile.getPrevFile();
|
File prevFile = msgFile.getPrevFile();
|
||||||
File diffentryFile = msgFile.getDiffEntryFile();
|
File diffentryFile = msgFile.getDiffEntryFile();
|
||||||
if (!prevFile.exists()) {
|
|
||||||
System.out.println("Previous File:" + prevFile.getPath());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Miner miner = new Miner();
|
Miner miner = new Miner();
|
||||||
miner.mineFixPatterns(prevFile, revFile, diffentryFile);
|
miner.mineFixPatterns(prevFile, revFile, diffentryFile);
|
||||||
editScripts.append(miner.getAstEditScripts());
|
editScripts.append(miner.getAstEditScripts());
|
||||||
patchesSourceCode.append(miner.getPatchesSourceCode());
|
patchesSourceCode.append(miner.getPatchesSourceCode());
|
||||||
|
int size = miner.getMaxSize();
|
||||||
|
if (size > maxSize) {
|
||||||
|
maxSize = size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileHelper.outputToFile(editScriptsFilePath + "edistScripts" + msg.getId() + ".list", editScripts, false);
|
FileHelper.outputToFile(editScriptsFilePath + "edistScripts" + msg.getId() + "_MaxSize=" + maxSize + ".list", editScripts, false);
|
||||||
FileHelper.outputToFile(patchesSourceCodeFilePath + "patches" + msg.getId() + ".list", patchesSourceCode, false);
|
FileHelper.outputToFile(patchesSourceCodeFilePath + "patches" + msg.getId() + ".list", patchesSourceCode, false);
|
||||||
|
|
||||||
this.getSender().tell("STOP", getSelf());
|
this.getSender().tell("STOP", getSelf());
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import edu.lu.uni.serval.utils.FileHelper;
|
|||||||
public class Miner {
|
public class Miner {
|
||||||
private String astEditScripts = "";
|
private String astEditScripts = "";
|
||||||
private String patchesSourceCode = "";
|
private String patchesSourceCode = "";
|
||||||
|
private int maxSize = 0;
|
||||||
|
|
||||||
public void mineFixPatterns(File prevFile, File revFile, File diffEntryFile) throws FileNotFoundException, IOException {
|
public void mineFixPatterns(File prevFile, File revFile, File diffEntryFile) throws FileNotFoundException, IOException {
|
||||||
// GumTree results
|
// GumTree results
|
||||||
@@ -131,6 +132,10 @@ public class Miner {
|
|||||||
*/
|
*/
|
||||||
// 1. First level: AST node type.
|
// 1. First level: AST node type.
|
||||||
String astEditScripts = getASTEditScripts(actionSet);
|
String astEditScripts = getASTEditScripts(actionSet);
|
||||||
|
int size = astEditScripts.split(" ").length;
|
||||||
|
if (size > maxSize) {
|
||||||
|
maxSize = size;
|
||||||
|
}
|
||||||
this.astEditScripts += astEditScripts + "\n";
|
this.astEditScripts += astEditScripts + "\n";
|
||||||
// 2. source code: raw tokens
|
// 2. source code: raw tokens
|
||||||
String rawTokenEditScripts = getRawTokenEditScripts(actionSet);
|
String rawTokenEditScripts = getRawTokenEditScripts(actionSet);
|
||||||
@@ -232,7 +237,6 @@ public class Miner {
|
|||||||
String lineNum = line.substring(4, plusIndex);
|
String lineNum = line.substring(4, plusIndex);
|
||||||
String[] nums = lineNum.split(",");
|
String[] nums = lineNum.split(",");
|
||||||
if (nums.length != 2) {
|
if (nums.length != 2) {
|
||||||
System.out.println("Line Num: " + line + ", Old line: " + startLineNum + " - " + endLineNum);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
startLine = Integer.parseInt(nums[0].trim());
|
startLine = Integer.parseInt(nums[0].trim());
|
||||||
@@ -248,7 +252,6 @@ public class Miner {
|
|||||||
lineNum2 = lineNum2.substring(1, lineNum2.length() - 2);
|
lineNum2 = lineNum2.substring(1, lineNum2.length() - 2);
|
||||||
String[] nums2 = lineNum2.split(",");
|
String[] nums2 = lineNum2.split(",");
|
||||||
if (nums2.length != 2) {
|
if (nums2.length != 2) {
|
||||||
System.out.println("Line Num: " + line + ", New line: " + startLineNum2 + " - " + endLineNum2);
|
|
||||||
startLine = 0;
|
startLine = 0;
|
||||||
range = 0;
|
range = 0;
|
||||||
continue;
|
continue;
|
||||||
@@ -350,4 +353,8 @@ public class Miner {
|
|||||||
return patchesSourceCode;
|
return patchesSourceCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMaxSize() {
|
||||||
|
return maxSize;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user