Program: 131618
Project: 131618
Buggy source:
public void run() throws IOException {
  Alphabet<String> lexAlphabet=new Alphabet<String>();
  Alphabet<String> ntAlphabet=new Alphabet<String>();
  log.info("String_Node_Str");
  CnfGrammarBuilder builder=new CnfGrammarBuilder(lexAlphabet,ntAlphabet);
  builder.loadFromFile(grammar);
  CnfGrammar grammar=builder.getGrammar();
  log.info("String_Node_Str" + ntAlphabet.size());
  log.info("String_Node_Str" + lexAlphabet.size());
  log.info("String_Node_Str");
  lexAlphabet.startGrowth();
  ntAlphabet.startGrowth();
  log.info("String_Node_Str" + train);
  NaryTreebank naryTrees=new NaryTreebank();
  List<File> mrgFiles=Utilities.getMatchingFiles(train,"String_Node_Str");
  for (  File mrgFile : mrgFiles) {
    BufferedReader reader=new BufferedReader(new FileReader(mrgFile));
    NaryTreebank tmpTrees=NaryTreebank.readTreesInPtbFormat(lexAlphabet,ntAlphabet,reader);
    for (    NaryTree tree : tmpTrees) {
      if (tree.getSentence().length <= maxSentenceLength) {
        naryTrees.add(tree);
      }
      if (naryTrees.size() >= maxNumSentences) {
        break;
      }
    }
    if (naryTrees.size() >= maxNumSentences) {
      break;
    }
    reader.close();
  }
  log.info("String_Node_Str");
  lexAlphabet.stopGrowth();
  ntAlphabet.stopGrowth();
  log.info("String_Node_Str" + ntAlphabet.size());
  log.info("String_Node_Str" + lexAlphabet.size());
  log.info("String_Node_Str");
  final int nullElement=ntAlphabet.lookupIndex("String_Node_Str");
  NaryTreeNodeFilter nullElementFilter=new NaryTreeNodeFilter(){
    @Override public boolean accept(    NaryTree node){
      if (node.getSymbol() == nullElement) {
        return false;
      }
 else       if (!node.isLexical() && node.isLeaf()) {
        return false;
      }
      return true;
    }
  }
;
  for (int i=0; i < naryTrees.size(); i++) {
    NaryTree tree=naryTrees.get(i);
    tree.postOrderFilterNodes(nullElementFilter);
    naryTrees.set(i,tree);
  }
  log.info("String_Node_Str");
  LambdaOne<NaryTree> ftRemover=new LambdaOne<NaryTree>(){
    private final Pattern functionTag=Pattern.compile("String_Node_Str");
    @Override public void call(    NaryTree node){
      if (!node.isLexical()) {
        Alphabet<String> alphabet=node.getAlphabet();
        int p=node.getSymbol();
        String pStr=alphabet.lookupObject(p);
        pStr=functionTag.matcher(pStr).replaceAll("String_Node_Str");
        node.setSymbol(alphabet.lookupIndex(pStr));
      }
    }
  }
;
  for (int i=0; i < naryTrees.size(); i++) {
    NaryTree tree=naryTrees.get(i);
    tree.postOrderTraversal(ftRemover);
    naryTrees.set(i,tree);
  }
  if (treeFile != null) {
    log.info("String_Node_Str" + treeFile);
    naryTrees.write(treeFile);
  }
  log.info("String_Node_Str" + naryTrees.size() + "String_Node_Str");
  BinaryTreebank binaryTrees=new BinaryTreebank();
  for (  NaryTree tree : naryTrees) {
    binaryTrees.add(tree.leftBinarize(ntAlphabet));
  }
  naryTrees=null;
  log.info("String_Node_Str" + binaryTrees.size() + "String_Node_Str");
  BinaryTreebank binaryParses=new BinaryTreebank();
  Timer timer=new Timer();
  timer.start();
  for (  BinaryTree tree : binaryTrees) {
    int[] sent=tree.getSentence();
    Chart chart=CkyPcfgParser.parseSentence(sent,grammar);
    Pair<BinaryTree,Double> pair=chart.getViterbiParse();
    binaryParses.add(pair.get1());
    timer.split();
    log.debug("String_Node_Str" + timer.avgSec());
  }
  timer.stop();
  log.info("String_Node_Str");
  LambdaOne<BinaryTree> refineRemover=new LambdaOne<BinaryTree>(){
    private final Pattern refine=Pattern.compile("String_Node_Str");
    @Override public void call(    BinaryTree node){
      if (!node.isLexical()) {
        Alphabet<String> alphabet=node.getAlphabet();
        int p=node.getSymbol();
        String pStr=alphabet.lookupObject(p);
        pStr=refine.matcher(pStr).replaceAll("String_Node_Str");
        node.setSymbol(alphabet.lookupIndex(pStr));
      }
    }
  }
;
  for (int i=0; i < binaryParses.size(); i++) {
    BinaryTree tree=binaryParses.get(i);
    tree.postOrderTraversal(refineRemover);
    binaryParses.set(i,tree);
  }
  log.info("String_Node_Str");
  NaryTreebank naryParses=new NaryTreebank();
  for (  BinaryTree tree : binaryParses) {
    naryParses.add(tree.collapseToNary(ntAlphabet));
  }
  binaryTrees=null;
  if (parseFile != null) {
    log.info("String_Node_Str" + parseFile);
    naryParses.write(parseFile);
  }
  if (evalbDir != null) {
    Evalb evalb=new Evalb(evalbDir);
    evalb.runEvalb(treeFile,parseFile,new File("String_Node_Str"));
  }
}

Fixed version (ground truth):
public void run() throws IOException {
  Alphabet<String> lexAlphabet=new Alphabet<String>();
  Alphabet<String> ntAlphabet=new Alphabet<String>();
  log.info("String_Node_Str");
  CnfGrammarBuilder builder=new CnfGrammarBuilder(lexAlphabet,ntAlphabet);
  builder.loadFromFile(grammar);
  CnfGrammar grammar=builder.getGrammar();
  log.info("String_Node_Str" + ntAlphabet.size());
  log.info("String_Node_Str" + lexAlphabet.size());
  log.info("String_Node_Str");
  lexAlphabet.startGrowth();
  ntAlphabet.startGrowth();
  log.info("String_Node_Str" + train);
  NaryTreebank naryTrees=new NaryTreebank();
  List<File> mrgFiles=Utilities.getMatchingFiles(train,"String_Node_Str");
  for (  File mrgFile : mrgFiles) {
    BufferedReader reader=new BufferedReader(new FileReader(mrgFile));
    NaryTreebank tmpTrees=NaryTreebank.readTreesInPtbFormat(lexAlphabet,ntAlphabet,reader);
    for (    NaryTree tree : tmpTrees) {
      if (tree.getSentence().length <= maxSentenceLength) {
        naryTrees.add(tree);
      }
      if (naryTrees.size() >= maxNumSentences) {
        break;
      }
    }
    if (naryTrees.size() >= maxNumSentences) {
      break;
    }
    reader.close();
  }
  log.info("String_Node_Str");
  lexAlphabet.stopGrowth();
  ntAlphabet.stopGrowth();
  log.info("String_Node_Str" + ntAlphabet.size());
  log.info("String_Node_Str" + lexAlphabet.size());
  log.info("String_Node_Str");
  final int nullElement=ntAlphabet.lookupIndex("String_Node_Str");
  NaryTreeNodeFilter nullElementFilter=new NaryTreeNodeFilter(){
    @Override public boolean accept(    NaryTree node){
      if (node.getSymbol() == nullElement) {
        return false;
      }
 else       if (!node.isLexical() && node.isLeaf()) {
        return false;
      }
      return true;
    }
  }
;
  for (int i=0; i < naryTrees.size(); i++) {
    NaryTree tree=naryTrees.get(i);
    tree.postOrderFilterNodes(nullElementFilter);
    naryTrees.set(i,tree);
  }
  log.info("String_Node_Str");
  LambdaOne<NaryTree> ftRemover=new LambdaOne<NaryTree>(){
    private final Pattern functionTag=Pattern.compile("String_Node_Str");
    @Override public void call(    NaryTree node){
      if (!node.isLexical()) {
        Alphabet<String> alphabet=node.getAlphabet();
        int p=node.getSymbol();
        String pStr=alphabet.lookupObject(p);
        pStr=functionTag.matcher(pStr).replaceAll("String_Node_Str");
        node.setSymbol(alphabet.lookupIndex(pStr));
      }
    }
  }
;
  for (int i=0; i < naryTrees.size(); i++) {
    NaryTree tree=naryTrees.get(i);
    tree.postOrderTraversal(ftRemover);
    naryTrees.set(i,tree);
  }
  if (treeFile != null) {
    log.info("String_Node_Str" + treeFile);
    naryTrees.writeTreesInOneLineFormat(treeFile);
  }
  log.info("String_Node_Str" + naryTrees.size() + "String_Node_Str");
  BinaryTreebank binaryTrees=new BinaryTreebank();
  for (  NaryTree tree : naryTrees) {
    binaryTrees.add(tree.leftBinarize(ntAlphabet));
  }
  naryTrees=null;
  log.info("String_Node_Str" + binaryTrees.size() + "String_Node_Str");
  BinaryTreebank binaryParses=new BinaryTreebank();
  Timer timer=new Timer();
  timer.start();
  for (  BinaryTree tree : binaryTrees) {
    int[] sent=tree.getSentence();
    Chart chart=CkyPcfgParser.parseSentence(sent,grammar);
    Pair<BinaryTree,Double> pair=chart.getViterbiParse();
    binaryParses.add(pair.get1());
    timer.split();
    log.debug("String_Node_Str" + timer.avgSec());
  }
  timer.stop();
  log.info("String_Node_Str");
  LambdaOne<BinaryTree> refineRemover=new LambdaOne<BinaryTree>(){
    private final Pattern refine=Pattern.compile("String_Node_Str");
    @Override public void call(    BinaryTree node){
      if (!node.isLexical()) {
        Alphabet<String> alphabet=node.getAlphabet();
        int p=node.getSymbol();
        String pStr=alphabet.lookupObject(p);
        pStr=refine.matcher(pStr).replaceAll("String_Node_Str");
        node.setSymbol(alphabet.lookupIndex(pStr));
      }
    }
  }
;
  for (int i=0; i < binaryParses.size(); i++) {
    BinaryTree tree=binaryParses.get(i);
    tree.postOrderTraversal(refineRemover);
    binaryParses.set(i,tree);
  }
  log.info("String_Node_Str");
  NaryTreebank naryParses=new NaryTreebank();
  for (  BinaryTree tree : binaryParses) {
    naryParses.add(tree.collapseToNary(ntAlphabet));
  }
  binaryTrees=null;
  if (parseFile != null) {
    log.info("String_Node_Str" + parseFile);
    naryParses.writeTreesInOneLineFormat(parseFile);
  }
  if (evalbDir != null) {
    Evalb evalb=new Evalb(evalbDir);
    evalb.runEvalb(treeFile,parseFile,new File("String_Node_Str"));
  }
}