Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions techniques/Locus/src/miningChanges/CorpusCreation.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class CorpusCreation {
public static String loc = main.Main.settings.get("workingLoc");
public static String repo = main.Main.settings.get("repoDir");
public static HashSet<String> concernedCommits;
public static HashMap<String,String> changeMap;
public static HashSet<String> changeMap;
public static HashMap<String,Integer> sourceFileIndex;

public static void getCommitsOneLine() throws Exception{
Expand Down Expand Up @@ -176,16 +176,15 @@ public static boolean processHunks() throws Exception {
count++;
//System.out.println(count + ":" + concernedCommits.size());

if (!changeMap.containsKey(hash)) continue;
if (!changeMap.contains(hash)) continue;
//System.out.println(fullHash);
// adaptpr for project ChangeLocator

String fullHash = changeMap.get(hash);
String parentPath = revisionLoc + File.separator + fullHash.substring(0,2)+ File.separator +fullHash.substring(2,4);
String commitFile = parentPath + File.separator + fullHash + ".txt";
String parentPath = revisionLoc + File.separator + hash.substring(0,2)+ File.separator +hash.substring(2,4);
String commitFile = parentPath + File.separator + hash + ".txt";

file = new File(parentPath);
if (!file.exists()) file.mkdir();
if (!file.exists()) file.mkdirs();

file = new File(commitFile);
if (!file.exists() || file.length() == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void loadRevisionTime() throws ParseException {
String[] splits = line.split("\t");
String revisionNO = splits[0];
Date date = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy Z", Locale.ENGLISH).parse(splits[2]);
revisionTime.put(revisionNO.substring(0,7), date.getTime());
revisionTime.put(revisionNO, date.getTime());
}
}

Expand Down
13 changes: 7 additions & 6 deletions techniques/Locus/src/miningChanges/ProduceFileLevelResults.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ public void loadFileSuspiciousScore() throws Exception {
if (description.contains("bug") || description.contains("patch") ||
description.contains("fix") || description.contains("issue")) {
// if (description.contains("fix") || description.contains("bug")) {
isCommitFix.put(hash.substring(0, 7), true);
isCommitFix.put(hash, true);
lines.add(hash + "\t1");
} else {
isCommitFix.put(hash.substring(0, 7), false);
isCommitFix.put(hash, false);
lines.add(hash + "\t0");
}
}
Expand All @@ -136,7 +136,7 @@ public void loadFileSuspiciousScore() throws Exception {
lines = FileToLines.fileToLines(commitFix);
for (String line : lines) {
String[] split = line.split("\t");
isCommitFix.put(split[0].substring(0,7), split[1].equals("1"));
isCommitFix.put(split[0], split[1].equals("1"));
}
}

Expand Down Expand Up @@ -214,7 +214,8 @@ public void integrateResults() {
max = fixSuspicious.get(sid);

for (int sid : fixSuspicious.keySet())
fixSuspicious.put(sid, fixSuspicious.get(sid) / max);
if (max > 0.0)
fixSuspicious.put(sid, fixSuspicious.get(sid) / max);

//calculate finalResults
for (String change : results.keySet()) {
Expand Down Expand Up @@ -242,10 +243,10 @@ public void integrateResults() {
double score = finalRanks.get(r).getValue();
String filename = sourceFileIndex.get(sid);

// ��ü ��ŷ���� ����
// ��ü ��ŷ���� ����
fullRanks.add(r + "\t" + score + "\t" + filename);

// answer�� ���� ����� ����.
// answer�� ���� ����� ����.
if (!ansFileIndices.contains(sid)) continue;
rawRanks.add(bid + "\t" +filename + "\t" + r + "\t" + score );
rank.add(r);
Expand Down
11 changes: 4 additions & 7 deletions techniques/Locus/src/preprocess/ExtractCommits.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ExtractCommits {
public static String loc = main.Main.settings.get("workingLoc");
public static String repo = main.Main.settings.get("repoDir");
public static HashSet<String> concernedCommits;
public static HashMap<String,String> changeMap;
public static HashSet<String> changeMap;
public static HashMap<String,Long> changeTime;
public static void indexHunks() throws Exception {
getCommitsOneLine();
Expand Down Expand Up @@ -91,17 +91,14 @@ public static void extractHunks() throws Exception {
int max = concernedCommits.size();
for (String hash : concernedCommits) {
count++;
if (!changeMap.containsKey(hash)) continue;
if (!changeMap.contains(hash)) continue;


String fullHash = changeMap.get(hash);

File parentPath = new File(revisionLoc + File.separator + fullHash.substring(0,2)+ File.separator +fullHash.substring(2,4));
File parentPath = new File(revisionLoc + File.separator + hash.substring(0,2) + File.separator + hash.substring(2,4));
//file = new File(revisionLoc + File.separator + fullHash);
if (!parentPath.exists())
parentPath.mkdirs();

String commitFile = parentPath.getAbsolutePath() + File.separator + fullHash + ".txt";
String commitFile = parentPath.getAbsolutePath() + File.separator + hash + ".txt";
file = new File(commitFile);
if (!file.exists()) {
String content = GitHelp.gitShow(hash, repo);
Expand Down
11 changes: 6 additions & 5 deletions techniques/Locus/src/utils/ChangeLocator.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;

public class ChangeLocator {
public static HashMap<String,String> shortChangeMap = null;
public static HashSet<String> shortChangeMap = null;

public static HashMap<String,String> getShortChangeMap() {
public static HashSet<String> getShortChangeMap() {
if (shortChangeMap == null) {
shortChangeMap = readShortChangeMap();
}
Expand All @@ -30,12 +31,12 @@ public static HashMap<String,Long> getChangeTime() throws ParseException {
return changeTime;
}

public static HashMap<String,String> readShortChangeMap() {
HashMap<String,String> changeMap = new HashMap<String,String>();
public static HashSet<String> readShortChangeMap() {
HashSet<String> changeMap = new HashSet<String>();
List<String> lines = FileToLines.fileToLines(main.Main.settings.get("workingLoc") + File.separator + "logOneline.txt");
for (String line : lines) {
String[] split = line.split("\t");
changeMap.put(split[0].substring(0, 7), split[0]);
changeMap.add(split[0]);
}
return changeMap;
}
Expand Down
2 changes: 1 addition & 1 deletion techniques/Locus/src/utils/GitHelp.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static List<Commit> readFromTextGIT(String filename) {
BufferedReader bw = new BufferedReader(new FileReader(new File(filename)));
line = bw.readLine();
while ( line != null) {
hashId = line.substring(7);
hashId = line.substring(8, 19);
line = bw.readLine();
if (!line.startsWith("Author")) line = bw.readLine();
int nameStart = line.indexOf(":") + 1;
Expand Down