Program: 19523
Project: 19523
Buggy source:
/** 
 * Imports an openfst text format Several files are imported as follows: - basename.input.syms - basename.output.syms - basename.fst.txt
 * @param basename the files' base name
 * @param semiring the fst's semiring
 * @return imported FST
 * @throws IOException IO went wrong
 * @throws NumberFormatException load failed due to data format issues
 */
public static Fst importFst(String basename,Semiring semiring) throws NumberFormatException, IOException {
  Fst fst=new Fst(semiring);
  HashMap<String,Integer> isyms=importSymbols(basename + "String_Node_Str");
  if (isyms == null) {
    isyms=new HashMap<String,Integer>();
    isyms.put("String_Node_Str",0);
  }
  HashMap<String,Integer> osyms=importSymbols(basename + "String_Node_Str");
  if (osyms == null) {
    osyms=new HashMap<String,Integer>();
    osyms.put("String_Node_Str",0);
  }
  HashMap<String,Integer> ssyms=importSymbols(basename + "String_Node_Str");
  FileInputStream fis=new FileInputStream(basename + "String_Node_Str");
  DataInputStream dis=new DataInputStream(fis);
  BufferedReader br=new BufferedReader(new InputStreamReader(dis));
  boolean firstLine=true;
  String strLine;
  HashMap<Integer,State> stateMap=new HashMap<Integer,State>();
  while ((strLine=br.readLine()) != null) {
    String[] tokens=strLine.split("String_Node_Str");
    Integer inputStateId;
    if (ssyms == null) {
      inputStateId=Integer.parseInt(tokens[0]);
    }
 else {
      inputStateId=ssyms.get(tokens[0]);
    }
    State inputState=stateMap.get(inputStateId);
    if (inputState == null) {
      inputState=new State(semiring.zero());
      fst.addState(inputState);
      stateMap.put(inputStateId,inputState);
    }
    if (firstLine) {
      firstLine=false;
      fst.setStart(inputState);
    }
    if (tokens.length > 2) {
      Integer nextStateId;
      if (ssyms == null) {
        nextStateId=Integer.parseInt(tokens[1]);
      }
 else {
        nextStateId=ssyms.get(tokens[1]);
      }
      State nextState=stateMap.get(nextStateId);
      if (nextState == null) {
        nextState=new State(semiring.zero());
        fst.addState(nextState);
        stateMap.put(nextStateId,nextState);
      }
      if (isyms.get(tokens[2]) == null) {
        isyms.put(tokens[2],isyms.size());
      }
      int iLabel=isyms.get(tokens[2]);
      if (osyms.get(tokens[3]) == null) {
        osyms.put(tokens[3],osyms.size());
      }
      int oLabel=osyms.get(tokens[3]);
      float arcWeight;
      if (tokens.length > 4) {
        arcWeight=Float.parseFloat(tokens[4]);
      }
 else {
        arcWeight=0;
      }
      Arc arc=new Arc(iLabel,oLabel,arcWeight,nextState);
      inputState.addArc(arc);
    }
 else {
      if (tokens.length > 1) {
        float finalWeight=Float.parseFloat(tokens[1]);
        inputState.setFinalWeight(finalWeight);
      }
 else {
        inputState.setFinalWeight(0.0f);
      }
    }
  }
  dis.close();
  fst.setIsyms(Utils.toStringArray(isyms));
  fst.setOsyms(Utils.toStringArray(osyms));
  return fst;
}

Fixed version (ground truth):
/** 
 * Imports an openfst text format Several files are imported as follows: - basename.input.syms - basename.output.syms - basename.fst.txt
 * @param basename the files' base name
 * @param semiring the fst's semiring
 * @return imported FST
 * @throws IOException IO went wrong
 * @throws NumberFormatException load failed due to data format issues
 */
public static Fst importFst(String basename,Semiring semiring) throws NumberFormatException, IOException {
  Fst fst=new Fst(semiring);
  HashMap<String,Integer> isyms=importSymbols(basename + "String_Node_Str");
  if (isyms == null) {
    isyms=new HashMap<String,Integer>();
    isyms.put("String_Node_Str",0);
  }
  HashMap<String,Integer> osyms=importSymbols(basename + "String_Node_Str");
  if (osyms == null) {
    osyms=new HashMap<String,Integer>();
    osyms.put("String_Node_Str",0);
  }
  HashMap<String,Integer> ssyms=importSymbols(basename + "String_Node_Str");
  FileInputStream fis=new FileInputStream(basename + "String_Node_Str");
  DataInputStream dis=new DataInputStream(fis);
  BufferedReader br=new BufferedReader(new InputStreamReader(dis,"String_Node_Str"));
  boolean firstLine=true;
  String strLine;
  HashMap<Integer,State> stateMap=new HashMap<Integer,State>();
  while ((strLine=br.readLine()) != null) {
    String[] tokens=strLine.split("String_Node_Str");
    Integer inputStateId;
    if (ssyms == null) {
      inputStateId=Integer.parseInt(tokens[0]);
    }
 else {
      inputStateId=ssyms.get(tokens[0]);
    }
    State inputState=stateMap.get(inputStateId);
    if (inputState == null) {
      inputState=new State(semiring.zero());
      fst.addState(inputState);
      stateMap.put(inputStateId,inputState);
    }
    if (firstLine) {
      firstLine=false;
      fst.setStart(inputState);
    }
    if (tokens.length > 2) {
      Integer nextStateId;
      if (ssyms == null) {
        nextStateId=Integer.parseInt(tokens[1]);
      }
 else {
        nextStateId=ssyms.get(tokens[1]);
      }
      State nextState=stateMap.get(nextStateId);
      if (nextState == null) {
        nextState=new State(semiring.zero());
        fst.addState(nextState);
        stateMap.put(nextStateId,nextState);
      }
      if (isyms.get(tokens[2]) == null) {
        isyms.put(tokens[2],isyms.size());
      }
      int iLabel=isyms.get(tokens[2]);
      if (osyms.get(tokens[3]) == null) {
        osyms.put(tokens[3],osyms.size());
      }
      int oLabel=osyms.get(tokens[3]);
      float arcWeight;
      if (tokens.length > 4) {
        arcWeight=Float.parseFloat(tokens[4]);
      }
 else {
        arcWeight=0;
      }
      Arc arc=new Arc(iLabel,oLabel,arcWeight,nextState);
      inputState.addArc(arc);
    }
 else {
      if (tokens.length > 1) {
        float finalWeight=Float.parseFloat(tokens[1]);
        inputState.setFinalWeight(finalWeight);
      }
 else {
        inputState.setFinalWeight(0.0f);
      }
    }
  }
  dis.close();
  fst.setIsyms(Utils.toStringArray(isyms));
  fst.setOsyms(Utils.toStringArray(osyms));
  return fst;
}