Program: 131503
Project: 131503
Buggy source:
/** 
 * This routine returns a String that is the "signature" of the class of a word. For, example, it might represent whether it is a number of ends in -s. The strings returned by convention match the pattern UNK-.* , which is just assumed to not match any real word. Behavior depends on the unknownLevel (-uwm flag) passed in to the class. The recognized numbers are 1-5: 5 is fairly English-specific; 4, 3, and 2 look for various word features (digits, dashes, etc.) which are only vaguely English-specific; 1 uses the last two characters combined with a simple classification by capitalization. MM, 12.July.2013:  Added unknownLevel '6', for Spanish.
 * @param word The word to make a signature for
 * @param loc Its position in the sentence (mainly so sentence-initial capitalized words can be treated differently)
 * @return A String that is its signature (equivalence class)
 */
public String getSignature(String word,int loc,int unknownLevel){
  StringBuffer sb=new StringBuffer("String_Node_Str");
  if (word.length() == 0)   return sb.toString();
switch (unknownLevel) {
case 6:
{
      String[] reflexiveEndings={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
      String[] verbEndings={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
      int wlen=word.length();
      int numCaps=0;
      boolean hasDigit=false;
      boolean hasDash=false;
      boolean hasLower=false;
      boolean hasRefl=false;
      boolean hasVerb=false;
      for (int i=0; i < wlen; i++) {
        char ch=word.charAt(i);
        if (!hasDigit && Character.isDigit(ch)) {
          hasDigit=true;
        }
 else         if (!hasDash && ch == '-') {
          hasDash=true;
        }
 else         if (Character.isLetter(ch)) {
          if (!hasLower && Character.isLowerCase(ch)) {
            hasLower=true;
          }
 else           if (!hasLower && Character.isTitleCase(ch)) {
            hasLower=true;
            numCaps++;
          }
 else {
            numCaps++;
          }
        }
      }
      char ch0=word.charAt(0);
      String lowered=word.toLowerCase();
      if (Character.isUpperCase(ch0) || Character.isTitleCase(ch0)) {
        if (loc == 0 && numCaps == 1) {
          sb.append("String_Node_Str");
          if (isKnown(lowered)) {
            sb.append("String_Node_Str");
          }
        }
 else {
          sb.append("String_Node_Str");
        }
      }
 else       if (!Character.isLetter(ch0) && numCaps > 0) {
        sb.append("String_Node_Str");
      }
 else       if (hasLower) {
        sb.append("String_Node_Str");
      }
      if (hasDigit) {
        sb.append("String_Node_Str");
      }
      if (hasDash) {
        sb.append("String_Node_Str");
      }
      if (lowered.endsWith("String_Node_Str") && wlen >= 3 && !hasVerb) {
        sb.append("String_Node_Str");
      }
 else       if (word.length() >= 5 && !hasDash && !(hasDigit && numCaps > 0)) {
        String ending=lowered.length() > 2 ? lowered.substring(lowered.length() - 2) : lowered;
        for (        String reflEnding : reflexiveEndings) {
          if (reflEnding.equals(ending)) {
            hasRefl=true;
            break;
          }
        }
        if (hasRefl) {
          ending=lowered.length() > 4 ? lowered.substring(lowered.length() - 4,lowered.length() - 2) : lowered;
        }
        for (        String verbEnding : verbEndings) {
          if (verbEnding.equals(ending)) {
            hasVerb=true;
            sb.append("String_Node_Str");
            break;
          }
        }
      }
      break;
    }
case 5:
{
    int wlen=word.length();
    int numCaps=0;
    boolean hasDigit=false;
    boolean hasDash=false;
    boolean hasLower=false;
    for (int i=0; i < wlen; i++) {
      char ch=word.charAt(i);
      if (!hasDigit && Character.isDigit(ch)) {
        hasDigit=true;
      }
 else       if (!hasDash && ch == '-') {
        hasDash=true;
      }
 else       if (Character.isLetter(ch)) {
        if (!hasLower && Character.isLowerCase(ch)) {
          hasLower=true;
        }
 else         if (!hasLower && Character.isTitleCase(ch)) {
          hasLower=true;
          numCaps++;
        }
 else {
          numCaps++;
        }
      }
    }
    char ch0=word.charAt(0);
    String lowered=word.toLowerCase();
    if (Character.isUpperCase(ch0) || Character.isTitleCase(ch0)) {
      if (loc == 0 && numCaps == 1) {
        sb.append("String_Node_Str");
        if (isKnown(lowered)) {
          sb.append("String_Node_Str");
        }
      }
 else {
        sb.append("String_Node_Str");
      }
    }
 else     if (!Character.isLetter(ch0) && numCaps > 0) {
      sb.append("String_Node_Str");
    }
 else     if (hasLower) {
      sb.append("String_Node_Str");
    }
    if (hasDigit) {
      sb.append("String_Node_Str");
    }
    if (hasDash) {
      sb.append("String_Node_Str");
    }
    if (lowered.endsWith("String_Node_Str") && wlen >= 3) {
      char ch2=lowered.charAt(wlen - 2);
      if (ch2 != 's' && ch2 != 'i' && ch2 != 'u') {
        sb.append("String_Node_Str");
      }
    }
 else     if (word.length() >= 5 && !hasDash && !(hasDigit && numCaps > 0)) {
      if (lowered.endsWith("String_Node_Str")) {
        sb.append("String_Node_Str");
      }
 else       if (lowered.endsWith("String_Node_Str")) {
        sb.append("String_Node_Str");
      }
 else       if (lowered.endsWith("String_Node_Str")) {
        sb.append("String_Node_Str");
      }
 else       if (lowered.endsWith("String_Node_Str")) {
        sb.append("String_Node_Str");
      }
 else       if (lowered.endsWith("String_Node_Str")) {
        sb.append("String_Node_Str");
      }
 else       if (lowered.endsWith("String_Node_Str")) {
        sb.append("String_Node_Str");
      }
 else       if (lowered.endsWith("String_Node_Str")) {
        sb.append("String_Node_Str");
      }
 else       if (lowered.endsWith("String_Node_Str")) {
        sb.append("String_Node_Str");
      }
 else       if (lowered.endsWith("String_Node_Str")) {
        sb.append("String_Node_Str");
      }
    }
    break;
  }
case 4:
{
  boolean hasDigit=false;
  boolean hasNonDigit=false;
  boolean hasLetter=false;
  boolean hasLower=false;
  boolean hasDash=false;
  boolean hasPeriod=false;
  boolean hasComma=false;
  for (int i=0; i < word.length(); i++) {
    char ch=word.charAt(i);
    if (Character.isDigit(ch)) {
      hasDigit=true;
    }
 else {
      hasNonDigit=true;
      if (Character.isLetter(ch)) {
        hasLetter=true;
        if (Character.isLowerCase(ch) || Character.isTitleCase(ch)) {
          hasLower=true;
        }
      }
 else {
        if (ch == '-') {
          hasDash=true;
        }
 else         if (ch == '.') {
          hasPeriod=true;
        }
 else         if (ch == ',') {
          hasComma=true;
        }
      }
    }
  }
  if (Character.isUpperCase(word.charAt(0)) || Character.isTitleCase(word.charAt(0))) {
    if (!hasLower) {
      sb.append("String_Node_Str");
    }
 else     if (loc == 0) {
      sb.append("String_Node_Str");
    }
 else {
      sb.append("String_Node_Str");
    }
  }
 else   if (hasLower) {
    sb.append("String_Node_Str");
  }
 else   if (hasLetter) {
    sb.append("String_Node_Str");
  }
 else {
    sb.append("String_Node_Str");
  }
  if (hasDigit && !hasNonDigit) {
    sb.append("String_Node_Str");
  }
 else   if (hasDigit) {
    sb.append("String_Node_Str");
  }
  if (hasDash) {
    sb.append("String_Node_Str");
  }
  if (hasPeriod) {
    sb.append("String_Node_Str");
  }
  if (hasComma) {
    sb.append("String_Node_Str");
  }
  if (word.length() > 3) {
    char ch=word.charAt(word.length() - 1);
    if (Character.isLetter(ch)) {
      sb.append("String_Node_Str");
      sb.append(Character.toLowerCase(ch));
    }
  }
  break;
}
case 3:
{
sb.append("String_Node_Str");
char lastClass='-';
char newClass;
int num=0;
for (int i=0; i < word.length(); i++) {
  char ch=word.charAt(i);
  if (Character.isUpperCase(ch) || Character.isTitleCase(ch)) {
    if (loc == 0) {
      newClass='S';
    }
 else {
      newClass='L';
    }
  }
 else   if (Character.isLetter(ch)) {
    newClass='l';
  }
 else   if (Character.isDigit(ch)) {
    newClass='d';
  }
 else   if (ch == '-') {
    newClass='h';
  }
 else   if (ch == '.') {
    newClass='p';
  }
 else {
    newClass='s';
  }
  if (newClass != lastClass) {
    lastClass=newClass;
    sb.append(lastClass);
    num=1;
  }
 else {
    if (num < 2) {
      sb.append('+');
    }
    num++;
  }
}
if (word.length() > 3) {
  char ch=Character.toLowerCase(word.charAt(word.length() - 1));
  sb.append('-');
  sb.append(ch);
}
break;
}
case 2:
{
boolean hasDigit=false;
boolean hasNonDigit=false;
boolean hasLower=false;
for (int i=0; i < word.length(); i++) {
char ch=word.charAt(i);
if (Character.isDigit(ch)) {
  hasDigit=true;
}
 else {
  hasNonDigit=true;
  if (Character.isLetter(ch)) {
    if (Character.isLowerCase(ch) || Character.isTitleCase(ch)) {
      hasLower=true;
    }
  }
}
}
if (Character.isUpperCase(word.charAt(0)) || Character.isTitleCase(word.charAt(0))) {
if (!hasLower) {
  sb.append("String_Node_Str");
}
 else if (loc == 0) {
  sb.append("String_Node_Str");
}
 else {
  sb.append("String_Node_Str");
}
}
 else if (hasLower) {
sb.append("String_Node_Str");
}
if (word.indexOf('-') >= 0) {
sb.append("String_Node_Str");
}
if (hasDigit) {
if (!hasNonDigit) {
  sb.append("String_Node_Str");
}
 else {
  sb.append("String_Node_Str");
}
}
 else if (word.length() > 3) {
char ch=word.charAt(word.length() - 1);
sb.append(Character.toLowerCase(ch));
}
break;
}
default :
sb.append("String_Node_Str");
sb.append(word.substring(Math.max(word.length() - 2,0),word.length()));
sb.append("String_Node_Str");
if (Character.isLowerCase(word.charAt(0))) {
sb.append("String_Node_Str");
}
 else {
if (Character.isUpperCase(word.charAt(0))) {
if (loc == 0) {
sb.append("String_Node_Str");
}
 else {
sb.append("String_Node_Str");
}
}
 else {
sb.append("String_Node_Str");
}
}
}
return sb.toString();
}

Fixed version (ground truth):
/** 
 * This routine returns a String that is the "signature" of the class of a word. For, example, it might represent whether it is a number of ends in -s. The strings returned by convention match the pattern UNK-.* , which is just assumed to not match any real word. Behavior depends on the unknownLevel (-uwm flag) passed in to the class. The recognized numbers are 1-5: 5 is fairly English-specific; 4, 3, and 2 look for various word features (digits, dashes, etc.) which are only vaguely English-specific; 1 uses the last two characters combined with a simple classification by capitalization. MM, 12.July.2013:  Added unknownLevel '6', for Spanish.
 * @param word The word to make a signature for
 * @param loc Its position in the sentence (mainly so sentence-initial capitalized words can be treated differently)
 * @return A String that is its signature (equivalence class)
 */
public String getSignature(String word,int loc,int unknownLevel){
  StringBuffer sb=new StringBuffer("String_Node_Str");
  if (word.length() == 0)   return sb.toString();
switch (unknownLevel) {
case 6:
{
      String[] reflexiveEndings={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
      String[] verbEndings={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
      int wlen=word.length();
      int numCaps=0;
      boolean hasDigit=false;
      boolean hasDash=false;
      boolean hasLower=false;
      boolean hasRefl=false;
      boolean hasVerb=false;
      for (int i=0; i < wlen; i++) {
        char ch=word.charAt(i);
        if (!hasDigit && Character.isDigit(ch)) {
          hasDigit=true;
        }
 else         if (!hasDash && ch == '-') {
          hasDash=true;
        }
 else         if (Character.isLetter(ch)) {
          if (Character.isLowerCase(ch)) {
            hasLower=true;
          }
 else           if (Character.isTitleCase(ch)) {
            hasLower=true;
            numCaps++;
          }
 else {
            numCaps++;
          }
        }
      }
      char ch0=word.charAt(0);
      String lowered=word.toLowerCase();
      if (Character.isUpperCase(ch0) || Character.isTitleCase(ch0)) {
        if (loc == 0 && numCaps == 1) {
          sb.append("String_Node_Str");
          if (isKnown(lowered)) {
            sb.append("String_Node_Str");
          }
        }
 else {
          sb.append("String_Node_Str");
        }
      }
 else       if (!Character.isLetter(ch0) && numCaps > 0) {
        sb.append("String_Node_Str");
      }
 else       if (hasLower) {
        sb.append("String_Node_Str");
      }
      if (hasDigit) {
        sb.append("String_Node_Str");
      }
      if (hasDash) {
        sb.append("String_Node_Str");
      }
      if (lowered.endsWith("String_Node_Str") && wlen >= 3 && !hasVerb) {
        sb.append("String_Node_Str");
      }
 else       if (word.length() >= 5 && !hasDash && !(hasDigit && numCaps > 0)) {
        String ending=lowered.length() > 2 ? lowered.substring(lowered.length() - 2) : lowered;
        for (        String reflEnding : reflexiveEndings) {
          if (reflEnding.equals(ending)) {
            hasRefl=true;
            break;
          }
        }
        if (hasRefl) {
          ending=lowered.length() > 4 ? lowered.substring(lowered.length() - 4,lowered.length() - 2) : lowered;
        }
        for (        String verbEnding : verbEndings) {
          if (verbEnding.equals(ending)) {
            hasVerb=true;
            sb.append("String_Node_Str");
            break;
          }
        }
      }
      break;
    }
case 5:
{
    int wlen=word.length();
    int numCaps=0;
    boolean hasDigit=false;
    boolean hasDash=false;
    boolean hasLower=false;
    for (int i=0; i < wlen; i++) {
      char ch=word.charAt(i);
      if (!hasDigit && Character.isDigit(ch)) {
        hasDigit=true;
      }
 else       if (!hasDash && ch == '-') {
        hasDash=true;
      }
 else       if (Character.isLetter(ch)) {
        if (Character.isLowerCase(ch)) {
          hasLower=true;
        }
 else         if (Character.isTitleCase(ch)) {
          hasLower=true;
          numCaps++;
        }
 else {
          numCaps++;
        }
      }
    }
    char ch0=word.charAt(0);
    String lowered=word.toLowerCase();
    if (Character.isUpperCase(ch0) || Character.isTitleCase(ch0)) {
      if (loc == 0 && numCaps == 1) {
        sb.append("String_Node_Str");
        if (isKnown(lowered)) {
          sb.append("String_Node_Str");
        }
      }
 else {
        sb.append("String_Node_Str");
      }
    }
 else     if (!Character.isLetter(ch0) && numCaps > 0) {
      sb.append("String_Node_Str");
    }
 else     if (hasLower) {
      sb.append("String_Node_Str");
    }
    if (hasDigit) {
      sb.append("String_Node_Str");
    }
    if (hasDash) {
      sb.append("String_Node_Str");
    }
    if (lowered.endsWith("String_Node_Str") && wlen >= 3) {
      char ch2=lowered.charAt(wlen - 2);
      if (ch2 != 's' && ch2 != 'i' && ch2 != 'u') {
        sb.append("String_Node_Str");
      }
    }
 else     if (word.length() >= 5 && !hasDash && !(hasDigit && numCaps > 0)) {
      if (lowered.endsWith("String_Node_Str")) {
        sb.append("String_Node_Str");
      }
 else       if (lowered.endsWith("String_Node_Str")) {
        sb.append("String_Node_Str");
      }
 else       if (lowered.endsWith("String_Node_Str")) {
        sb.append("String_Node_Str");
      }
 else       if (lowered.endsWith("String_Node_Str")) {
        sb.append("String_Node_Str");
      }
 else       if (lowered.endsWith("String_Node_Str")) {
        sb.append("String_Node_Str");
      }
 else       if (lowered.endsWith("String_Node_Str")) {
        sb.append("String_Node_Str");
      }
 else       if (lowered.endsWith("String_Node_Str")) {
        sb.append("String_Node_Str");
      }
 else       if (lowered.endsWith("String_Node_Str")) {
        sb.append("String_Node_Str");
      }
 else       if (lowered.endsWith("String_Node_Str")) {
        sb.append("String_Node_Str");
      }
    }
    break;
  }
case 4:
{
  boolean hasDigit=false;
  boolean hasNonDigit=false;
  boolean hasLetter=false;
  boolean hasLower=false;
  boolean hasDash=false;
  boolean hasPeriod=false;
  boolean hasComma=false;
  for (int i=0; i < word.length(); i++) {
    char ch=word.charAt(i);
    if (Character.isDigit(ch)) {
      hasDigit=true;
    }
 else {
      hasNonDigit=true;
      if (Character.isLetter(ch)) {
        hasLetter=true;
        if (Character.isLowerCase(ch) || Character.isTitleCase(ch)) {
          hasLower=true;
        }
      }
 else {
        if (ch == '-') {
          hasDash=true;
        }
 else         if (ch == '.') {
          hasPeriod=true;
        }
 else         if (ch == ',') {
          hasComma=true;
        }
      }
    }
  }
  if (Character.isUpperCase(word.charAt(0)) || Character.isTitleCase(word.charAt(0))) {
    if (!hasLower) {
      sb.append("String_Node_Str");
    }
 else     if (loc == 0) {
      sb.append("String_Node_Str");
    }
 else {
      sb.append("String_Node_Str");
    }
  }
 else   if (hasLower) {
    sb.append("String_Node_Str");
  }
 else   if (hasLetter) {
    sb.append("String_Node_Str");
  }
 else {
    sb.append("String_Node_Str");
  }
  if (hasDigit && !hasNonDigit) {
    sb.append("String_Node_Str");
  }
 else   if (hasDigit) {
    sb.append("String_Node_Str");
  }
  if (hasDash) {
    sb.append("String_Node_Str");
  }
  if (hasPeriod) {
    sb.append("String_Node_Str");
  }
  if (hasComma) {
    sb.append("String_Node_Str");
  }
  if (word.length() > 3) {
    char ch=word.charAt(word.length() - 1);
    if (Character.isLetter(ch)) {
      sb.append("String_Node_Str");
      sb.append(Character.toLowerCase(ch));
    }
  }
  break;
}
case 3:
{
sb.append("String_Node_Str");
char lastClass='-';
char newClass;
int num=0;
for (int i=0; i < word.length(); i++) {
  char ch=word.charAt(i);
  if (Character.isUpperCase(ch) || Character.isTitleCase(ch)) {
    if (loc == 0) {
      newClass='S';
    }
 else {
      newClass='L';
    }
  }
 else   if (Character.isLetter(ch)) {
    newClass='l';
  }
 else   if (Character.isDigit(ch)) {
    newClass='d';
  }
 else   if (ch == '-') {
    newClass='h';
  }
 else   if (ch == '.') {
    newClass='p';
  }
 else {
    newClass='s';
  }
  if (newClass != lastClass) {
    lastClass=newClass;
    sb.append(lastClass);
    num=1;
  }
 else {
    if (num < 2) {
      sb.append('+');
    }
    num++;
  }
}
if (word.length() > 3) {
  char ch=Character.toLowerCase(word.charAt(word.length() - 1));
  sb.append('-');
  sb.append(ch);
}
break;
}
case 2:
{
boolean hasDigit=false;
boolean hasNonDigit=false;
boolean hasLower=false;
for (int i=0; i < word.length(); i++) {
char ch=word.charAt(i);
if (Character.isDigit(ch)) {
  hasDigit=true;
}
 else {
  hasNonDigit=true;
  if (Character.isLetter(ch)) {
    if (Character.isLowerCase(ch) || Character.isTitleCase(ch)) {
      hasLower=true;
    }
  }
}
}
if (Character.isUpperCase(word.charAt(0)) || Character.isTitleCase(word.charAt(0))) {
if (!hasLower) {
  sb.append("String_Node_Str");
}
 else if (loc == 0) {
  sb.append("String_Node_Str");
}
 else {
  sb.append("String_Node_Str");
}
}
 else if (hasLower) {
sb.append("String_Node_Str");
}
if (word.indexOf('-') >= 0) {
sb.append("String_Node_Str");
}
if (hasDigit) {
if (!hasNonDigit) {
  sb.append("String_Node_Str");
}
 else {
  sb.append("String_Node_Str");
}
}
 else if (word.length() > 3) {
char ch=word.charAt(word.length() - 1);
sb.append(Character.toLowerCase(ch));
}
break;
}
default :
sb.append("String_Node_Str");
sb.append(word.substring(Math.max(word.length() - 2,0),word.length()));
sb.append("String_Node_Str");
if (Character.isLowerCase(word.charAt(0))) {
sb.append("String_Node_Str");
}
 else {
if (Character.isUpperCase(word.charAt(0))) {
if (loc == 0) {
sb.append("String_Node_Str");
}
 else {
sb.append("String_Node_Str");
}
}
 else {
sb.append("String_Node_Str");
}
}
}
return sb.toString();
}