test_class.declarator: comp
test_class.modifier: private
test_class.original_string: private Levenshtein comp;
test_class.type: Levenshtein
test_class.var_name: comp
test_class.file: lib/Duke/duke-core/src/test/java/no/priv/garshol/duke/comparators/LevenshteinTest.java
test_class.identifier: LevenshteinTest
test_case.body: @Test
    public void testCEmpty() {
      assertEquals(0, Levenshtein.compactDistance("", ""));
    }
test_case.class_method_signature: LevenshteinTest.testCEmpty()
test_case.full_signature: @Test public void testCEmpty()
test_case.identifier: testCEmpty
test_case.invocations: assertEquals compactDistance
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testCEmpty()
focal_class.file: lib/Duke/duke-core/src/main/java/no/priv/garshol/duke/comparators/Levenshtein.java
focal_class.identifier: Levenshtein
focal_class.interfaces: implements Comparator
focal_class.class_method_signature: Levenshtein.compare(String s1, String s2)
focal_class.full_signature: @Override public double compare(String s1, String s2)
focal_class.identifier: compare
focal_class.modifiers: @Override public
focal_class.parameters: (String s1, String s2)
focal_class.return: double
focal_class.signature: double compare(String s1, String s2)
focal_class.class_method_signature: Levenshtein.isTokenized()
focal_class.full_signature: @Override public boolean isTokenized()
focal_class.identifier: isTokenized
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isTokenized()
focal_class.class_method_signature: Levenshtein.distance(String s1, String s2)
focal_class.full_signature: public static int distance(String s1, String s2)
focal_class.identifier: distance
focal_class.modifiers: public static
focal_class.parameters: (String s1, String s2)
focal_class.return: int
focal_class.signature: int distance(String s1, String s2)
focal_class.class_method_signature: Levenshtein.compactDistance(String s1, String s2)
focal_class.full_signature: public static int compactDistance(String s1, String s2)
focal_class.identifier: compactDistance
focal_class.modifiers: public static
focal_class.parameters: (String s1, String s2)
focal_class.return: int
focal_class.signature: int compactDistance(String s1, String s2)
focal_method.body: public static int compactDistance(String s1, String s2) {
      if (s1.length() == 0)
        return s2.length();
      if (s2.length() == 0)
        return s1.length();
  
      // the maximum edit distance there is any point in reporting.
      int maxdist = Math.min(s1.length(), s2.length()) / 2;
      
      // we allocate just one column instead of the entire matrix, in
      // order to save space.  this also enables us to implement the
      // algorithm somewhat faster.  the first cell is always the
      // virtual first row.
      int s1len = s1.length();
      int[] column = new int[s1len + 1];
  
      // first we need to fill in the initial column. we use a separate
      // loop for this, because in this case our basis for comparison is
      // not the previous column, but a virtual first column.
      int ix2 = 0;
      char ch2 = s2.charAt(ix2);
      column[0] = 1; // virtual first row
      for (int ix1 = 1; ix1 <= s1len; ix1++) {
        int cost = s1.charAt(ix1 - 1) == ch2 ? 0 : 1;
  
        // Lowest of three: above (column[ix1 - 1]), aboveleft: ix1 - 1,
        // left: ix1. Latter cannot possibly be lowest, so is
        // ignored.
        column[ix1] = Math.min(column[ix1 - 1], ix1 - 1) + cost;
      }
  
      // okay, now we have an initialized first column, and we can
      // compute the rest of the matrix.
      int above = 0;
      for (ix2 = 1; ix2 < s2.length(); ix2++) {
        ch2 = s2.charAt(ix2);
        above = ix2 + 1; // virtual first row
  
        int smallest = s1len * 2; // used to implement cutoff
        for (int ix1 = 1; ix1 <= s1len; ix1++) {
          int cost = s1.charAt(ix1 - 1) == ch2 ? 0 : 1;
  
          // above:     above
          // aboveleft: column[ix1 - 1]
          // left:      column[ix1]
          int value = Math.min(Math.min(above, column[ix1 - 1]), column[ix1]) +
                      cost;
          column[ix1 - 1] = above; // write previous
          above = value;           // keep current
          smallest = Math.min(smallest, value);
        }
        column[s1len] = above;
  
        // check if we can stop because we'll be going over the max distance
        if (smallest > maxdist)
          return smallest;
      }
  
      // ok, we're done
      return above;
    }
focal_method.class_method_signature: Levenshtein.compactDistance(String s1, String s2)
focal_method.full_signature: public static int compactDistance(String s1, String s2)
focal_method.identifier: compactDistance
focal_method.invocations: length length length length min length length length charAt charAt min length charAt charAt min min min
focal_method.modifiers: public static
focal_method.parameters: (String s1, String s2)
focal_method.return: int
focal_method.signature: int compactDistance(String s1, String s2)