Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Archival submissions #49

Closed
wants to merge 3 commits into from
Closed
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
38 changes: 25 additions & 13 deletions jplag/src/main/java/jplag/AllMatches.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ public class AllMatches extends Matches implements Comparator<AllMatches> {
public Submission subA;
public Submission subB;

public AllBasecodeMatches bcmatchesA = null;
public AllBasecodeMatches bcmatchesB = null;


public AllMatches(Submission subA, Submission subB) {
super();
this.subA = subA;
Expand Down Expand Up @@ -92,9 +88,9 @@ public final float roundedPercent() {
}
public final float percent() {
float sa, sb;
if(bcmatchesB != null && bcmatchesA != null){
sa = subA.size() - subA.files.length - bcmatchesA.tokensMatched();
sb = subB.size() - subB.files.length - bcmatchesB.tokensMatched();
if(subA.bcMatches != null && subB.bcMatches != null){
sa = subA.size() - subA.files.length - subA.bcMatches.tokensMatched();
sb = subB.size() - subB.files.length - subB.bcMatches.tokensMatched();
}
else{
sa = subA.size() - subA.files.length;
Expand All @@ -104,14 +100,22 @@ public final float percent() {
}
public final float percentA() {
int divisor;
if(bcmatchesA != null) divisor = subA.size()-subA.files.length-bcmatchesA.tokensMatched();
else divisor = subA.size()-subA.files.length;

if (subA.bcMatches != null)
divisor = subA.size() - subA.files.length - subA.bcMatches.tokensMatched();
else
divisor = subA.size() - subA.files.length;

return (divisor == 0 ? 0f : (tokensMatched()*100 / (float) divisor));
}
public final float percentB() {
int divisor;
if(bcmatchesB != null) divisor = subB.size()-subB.files.length-bcmatchesB.tokensMatched();
else divisor = subB.size()-subB.files.length;

if (subB.bcMatches != null)
divisor = subB.size() - subB.files.length - subB.bcMatches.tokensMatched();
else
divisor = subB.size() - subB.files.length;

return (divisor == 0 ? 0f : (tokensMatched()*100 / (float) divisor));
}

Expand Down Expand Up @@ -139,11 +143,11 @@ public final float percentMinAB() {

public final float percentBasecodeA(){
float sa = subA.size() - subA.files.length;
return bcmatchesA.tokensMatched() * 100 / sa;
return subA.bcMatches.tokensMatched() * 100 / sa;
}
public final float percentBasecodeB(){
float sb = subB.size() - subB.files.length;
return bcmatchesB.tokensMatched() * 100 / sb;
return subB.bcMatches.tokensMatched() * 100 / sb;
}
public final float roundedPercentBasecodeA() {
float percent = percentBasecodeA();
Expand All @@ -154,6 +158,14 @@ public final float roundedPercentBasecodeB() {
return ((int)(percent * 10)) / (float)10;
}

public AllBasecodeMatches getBcMatchesA() {
return subA.bcMatches;
}

public AllBasecodeMatches getBcMatchesB() {
return subB.bcMatches;
}

/* Returns the name of the submissions which were compared
* Parameter: i == 0 submission A,
* i != 0 submission B.
Expand Down
29 changes: 18 additions & 11 deletions jplag/src/main/java/jplag/GSTiling.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,27 @@ public void create_hashes(Structure s, int hashLength, boolean makeTable) {
}

public final AllMatches compare(Submission subA, Submission subB) {
if (subA.struct == null || subB.struct == null) {
return null;
}

Submission A, B, tmp;
AllMatches matches;

if (subA.struct.size() > subB.struct.size()) {
A = subB; B = subA;
} else {
A = subB; B = subA;
A = subA; B = subB;
}
// if hashtable exists in first but not in second structure: flip around!
if (B.struct.table == null && A.struct.table != null) {
tmp = A;
A = B;
B = tmp;
matches = compare(B, A, this.program.get_min_token_match());
} else {
matches = compare(A, B, this.program.get_min_token_match());
}

return compare(A, B, this.program.get_min_token_match());
System.out.println("Comparing " + subA.name + "-" + subB.name + ": " + matches.percent());
return matches;
}

// first parameter should contain the smaller sequence!!!
Expand Down Expand Up @@ -180,19 +187,19 @@ private final AllMatches compare(Submission subA, Submission subB, int mml) {

public final AllBasecodeMatches compareWithBasecode(Submission subA, Submission subB) {
Submission A, B, tmp;

if (subA.struct.size() > subB.struct.size()) {
A = subB; B = subA;
} else {
A = subB; B = subA;
A = subA; B = subB;
}

// if hashtable exists in first but not in second structure: flip around!
if (B.struct.table == null && A.struct.table != null) {
tmp = A;
A = B;
B = tmp;
return compareWithBasecode(B, A, program.get_min_token_match());
} else {
return compareWithBasecode(A, B, program.get_min_token_match());
}

return compareWithBasecode(A, B, this.program.get_min_token_match());
}

private final AllBasecodeMatches compareWithBasecode(Submission subA, Submission subB, int mml) {
Expand Down
Loading