Jelajahi Sumber

Replace uses of German language by English translations

Timur Sağlam 5 tahun lalu
induk
melakukan
1a58917717

+ 37 - 47
jplag.frontend-utils/src/main/java/jplag/Structure.java

@@ -8,8 +8,6 @@ import java.io.IOException;
 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];
@@ -17,17 +15,15 @@ public class Structure implements TokenConstants {
 	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) {
@@ -39,56 +35,55 @@ public class Structure implements TokenConstants {
 				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());
 		}
@@ -97,22 +92,17 @@ public class Structure implements TokenConstants {
 	/* 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());

+ 1 - 2
jplag.frontend.scheme/src/main/java/jplag/scheme/Language.java

@@ -17,8 +17,7 @@ public class Language implements jplag.Language {
 		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() {

+ 4 - 4
jplag/src/main/java/jplag/JPlagComparison.java

@@ -222,11 +222,11 @@ public class JPlagComparison implements Comparator<JPlagComparison> {
     }
 
     /**
-     * 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";
     }
 

+ 9 - 13
jplag/src/main/java/jplag/Matches.java

@@ -3,13 +3,13 @@ package jplag;
 /**
  * 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() {
@@ -17,11 +17,11 @@ public class Matches {
         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) {
@@ -40,25 +40,21 @@ public class Matches {
         }
     }
 
-    /*
-     * 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;
     }
 }

+ 7 - 7
jplag/src/main/java/jplag/reporting/Report.java

@@ -64,15 +64,15 @@ public class Report {
      * 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;
     }
 
     /*