Skip to content

Commit

Permalink
Replace uses of German language by English translations
Browse files Browse the repository at this point in the history
  • Loading branch information
tsaglam committed Jun 7, 2021
1 parent f6e9064 commit 1a58917
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 73 deletions.
84 changes: 37 additions & 47 deletions jplag.frontend-utils/src/main/java/jplag/Structure.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,22 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

//import java.util.zip.*;

/** The tokenlist */ // TODO PB: The name 'Structure' is very generic and should be changed to something more descriptive.
public class Structure implements TokenConstants {
public Token[] tokens = new Token[0];
Table table = null;
int hash_length = -1;

int files; // number of END_FILE tokens
private int anzahl;

//private final int increment = 300;
private int numberOfTokens;

public Structure() {
tokens = new Token[400];
files = anzahl = 0;
files = numberOfTokens = 0;
}

public final int size() {
return anzahl;
return numberOfTokens;
}

public final void ensureCapacity(int minCapacity) {
Expand All @@ -39,56 +35,55 @@ public final void ensureCapacity(int minCapacity) {
newCapacity = minCapacity;
}
tokens = new Token[newCapacity];
System.arraycopy(oldTokens, 0, tokens, 0, anzahl);
System.arraycopy(oldTokens, 0, tokens, 0, numberOfTokens);
}
}

public final void addToken(Token token) {
ensureCapacity(anzahl + 1);
if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file))
token.file = tokens[anzahl - 1].file; // To save memory ...
if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file)))
token.setLine(tokens[anzahl - 1].getLine());
ensureCapacity(numberOfTokens + 1);
if (numberOfTokens > 0 && tokens[numberOfTokens - 1].file.equals(token.file))
token.file = tokens[numberOfTokens - 1].file; // To save memory ...
if ((numberOfTokens > 0) && (token.getLine() < tokens[numberOfTokens - 1].getLine()) && (token.file.equals(tokens[numberOfTokens - 1].file)))
token.setLine(tokens[numberOfTokens - 1].getLine());
// just to make sure

tokens[anzahl++] = token;
tokens[numberOfTokens++] = token;
if (token.type == FILE_END)
files++;
}

@Override
public final String toString() {
StringBuffer buf = new StringBuffer();
StringBuffer buffer = new StringBuffer();

try {
for (int i = 0; i < anzahl; i++) {
String s = tokens[i].toString();
buf.append(i);
buf.append("\t");
buf.append(s);
if (i < anzahl - 1) {
buf.append("\n");
for (int i = 0; i < numberOfTokens; i++) {
buffer.append(i);
buffer.append("\t");
buffer.append(tokens[i].toString());
if (i < numberOfTokens - 1) {
buffer.append("\n");
}
}
} catch (OutOfMemoryError e) {
return "Tokenlist to large for output: " + (anzahl) + " Tokens";
return "Tokenlist to large for output: " + (numberOfTokens) + " Tokens";
}
return buf.toString();
return buffer.toString();
}

public void save(File file) {

try {
ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file)));
ObjectOutputStream input = new ObjectOutputStream((new FileOutputStream(file)));

p.writeInt(anzahl);
p.writeInt(hash_length);
p.writeInt(files);
input.writeInt(numberOfTokens);
input.writeInt(hash_length);
input.writeInt(files);

for (int i = 0; i < anzahl; i++)
p.writeObject(tokens[i]);
p.flush();
p.close();
for (int i = 0; i < numberOfTokens; i++)
input.writeObject(tokens[i]);
input.flush();
input.close();
} catch (IOException e) {
System.out.println("Error writing file: " + file.toString());
}
Expand All @@ -97,22 +92,17 @@ public void save(File file) {
/* returns "true" when successful */
public boolean load(File file) {
try {
ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file)));

int newAnzahl = p.readInt();
hash_length = p.readInt();
files = p.readInt();
ensureCapacity(newAnzahl);
anzahl = newAnzahl;
for (int i = 0; i < anzahl; i++) {
tokens[i] = (Token) p.readObject();
// special case for text tokens:
// if (tokens[i] instanceof jplag.text.TextToken) {
// jplag.text.TextToken token = (jplag.text.TextToken)tokens[i];
// jplag.text.TextToken.put(token.getText(), token.type);
// }
ObjectInputStream input = new ObjectInputStream((new FileInputStream(file)));

int newNumberOfTokens = input.readInt();
hash_length = input.readInt();
files = input.readInt();
ensureCapacity(newNumberOfTokens);
numberOfTokens = newNumberOfTokens;
for (int i = 0; i < numberOfTokens; i++) {
tokens[i] = (Token) input.readObject();
}
p.close();
input.close();
table = null;
} catch (FileNotFoundException e) {
System.out.println("File not found: " + file.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ public int errorsCount() {
return this.parser.errorsCount();
}

private jplag.scheme.Parser parser;//noch nicht instanziert? siehe
// Konstruktor
private jplag.scheme.Parser parser; // Not yet instantiated? See constructor!

@Override
public String[] suffixes() {
Expand Down
8 changes: 4 additions & 4 deletions jplag/src/main/java/jplag/JPlagComparison.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,11 @@ public final String[] files(int j) {
}

/**
* The bigger a match (length "anz") is relatively to the biggest match the redder is the color returned by this method.
* The bigger a match (length) is relatively to the biggest match the redder is the color returned by this method.
*/
public String color(int anz) {
int farbe = 255 * anz / biggestMatch();
String help = (farbe < 16 ? "0" : "") + Integer.toHexString(farbe);
public String color(int length) {
int color = 255 * length / biggestMatch();
String help = (color < 16 ? "0" : "") + Integer.toHexString(color);
return "#" + help + "0000";
}

Expand Down
22 changes: 9 additions & 13 deletions jplag/src/main/java/jplag/Matches.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
/**
* Minimal data structure that stores "Match" objects.
* <p>
* Note: This class is only used by GSTiling as a data structure to store matches.
* Note: This class is only used by {@link GreedyStringTiling} as a data structure to store matches.
*/
public class Matches {

public Match[] matches;

private int anzahl;
private int numberOfMatches;
private final int increment = 20;

public Matches() {
matches = new Match[10];
for (int i = 0; i < 10; i++) {
matches[i] = new Match();
}
anzahl = 0;
numberOfMatches = 0;
}

public final int size() {
return anzahl;
return numberOfMatches;
}

private void ensureCapacity(int minCapacity) {
Expand All @@ -40,25 +40,21 @@ private void ensureCapacity(int minCapacity) {
}
}

/*
* public final void addMatch(Match match) { for (int i=0; i<anzahl; i++) if (match.overlap(matches[i])) return; // do
* not allow overlaps ensureCapacity(anzahl + 1); matches[anzahl++] = match; }
*/
public final void addMatch(int startA, int startB, int length) {
for (int i = anzahl - 1; i >= 0; i--) { // starting at the end is better(?)
for (int i = numberOfMatches - 1; i >= 0; i--) { // starting at the end is better(?)
if (matches[i].overlap(startA, startB, length)) {
return;
}
// no overlaps!
}

ensureCapacity(anzahl + 1);
ensureCapacity(numberOfMatches + 1);

matches[anzahl].set(startA, startB, length);
anzahl++;
matches[numberOfMatches].set(startA, startB, length);
numberOfMatches++;
}

public final void clear() {
anzahl = 0;
numberOfMatches = 0;
}
}
14 changes: 7 additions & 7 deletions jplag/src/main/java/jplag/reporting/Report.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ private void validateReportDir() throws ExitException {
* Two colors, represented by Rl,Gl,Bl and Rh,Gh,Bh respectively are mixed according to the percentage "percent"
*/
private String color(float percent, int Rl, int Rh, int Gl, int Gh, int Bl, int Bh) {
int farbeR = (int) (Rl + (Rh - Rl) * percent / 100);
int farbeG = (int) (Gl + (Gh - Gl) * percent / 100);
int farbeB = (int) (Bl + (Bh - Bl) * percent / 100);
int redValue = (int) (Rl + (Rh - Rl) * percent / 100);
int greenValue = (int) (Gl + (Gh - Gl) * percent / 100);
int blueValue = (int) (Bl + (Bh - Bl) * percent / 100);

String helpR = (farbeR < 16 ? "0" : "") + Integer.toHexString(farbeR);
String helpG = (farbeG < 16 ? "0" : "") + Integer.toHexString(farbeG);
String helpB = (farbeB < 16 ? "0" : "") + Integer.toHexString(farbeB);
String red = (redValue < 16 ? "0" : "") + Integer.toHexString(redValue);
String green = (greenValue < 16 ? "0" : "") + Integer.toHexString(greenValue);
String blue = (blueValue < 16 ? "0" : "") + Integer.toHexString(blueValue);

return "#" + helpR + helpG + helpB;
return "#" + red + green + blue;
}

/*
Expand Down

0 comments on commit 1a58917

Please sign in to comment.