nus-yam/ex-repair huggingface dataset:
Program: 19898
Project: 19898
Buggy source:
/** 
 * Add a context to a list of contexts after ensuring that no identical contexts exist on the list. When a right context is collected it may contain duplicates in certain cases (when this unit is the last unit in a grammar node, and there is a branch to multiple words in subsequent nodes, for instance)
 * @param context the list of contexts to add the new units to
 * @param units the units to add to the context
 */
private void addContext(List contexts,Unit[] units){
  for (Iterator i=contexts.iterator(); i.hasNext(); ) {
    Unit[] onList=(Unit[])i.next();
    if (Unit.isContextMatch(onList,units)) {
      return;
    }
  }
  contexts.add(units);
}

Fixed version (ground truth):
/** 
 * Add a context to a list of contexts after ensuring that no identical contexts exist on the list. When a right context is collected it may contain duplicates in certain cases (when this unit is the last unit in a grammar node, and there is a branch to multiple words in subsequent nodes, for instance)
 * @param contexts the list of contexts to add the new units to
 * @param units the units to add to the context
 */
private void addContext(List contexts,Unit[] units){
  for (Iterator i=contexts.iterator(); i.hasNext(); ) {
    Unit[] onList=(Unit[])i.next();
    if (Unit.isContextMatch(onList,units)) {
      return;
    }
  }
  contexts.add(units);
}
Program: 19899
Project: 19899
Buggy source:
/** 
 * Gets the unit associated with this point in the grammar. If there is no unit, return filler
 * @param filler the filler to use if the unit is empty
 */
private Unit getUnitOrFill(){
  Unit unit=getUnit();
  if (unit == null) {
    unit=Unit.SILENCE;
  }
  return unit;
}

Fixed version (ground truth):
/** 
 * Gets the unit associated with this point in the grammar. If there is no unit, return filler
 * @return the unit for this grammar node or a filler unit
 */
private Unit getUnitOrFill(){
  Unit unit=getUnit();
  if (unit == null) {
    unit=Unit.SILENCE;
  }
  return unit;
}
Program: 19900
Project: 19900
Buggy source:
/** 
 * Gets the state number for this state
 * @param stateNumber the state number
 */
private int getStateNumber(){
  return stateNumber;
}

Fixed version (ground truth):
/** 
 * Gets the state number for this state
 * @return  the state number
 */
private int getStateNumber(){
  return stateNumber;
}
Program: 19901
Project: 19901
Buggy source:
/** 
 * Method called when a state is visited by the vistor
 * @param the state that is being visited
 * @return true if the visiting should be terminated
 */
public boolean visit(SentenceHMMState state);

Fixed version (ground truth):
/** 
 * Method called when a state is visited by the vistor
 * @param state the state that is being visited
 * @return true if the visiting should be terminated
 */
public boolean visit(SentenceHMMState state);
Program: 19903
Project: 19903
Buggy source:
/** 
 * Adds an exit point to this gstate
 * @param cp the context tag for the state
 * @param tail the state associated with the tag
 */
private void addExitPoint(ContextPair cp,SentenceHMMState state){
  List list=(List)exitPoints.get(cp);
  if (list == null) {
    list=new ArrayList();
    exitPoints.put(cp,list);
  }
  list.add(state);
}

Fixed version (ground truth):
/** 
 * Adds an exit point to this gstate
 * @param cp the context tag for the state
 * @param state the state associated with the tag
 */
private void addExitPoint(ContextPair cp,SentenceHMMState state){
  List list=(List)exitPoints.get(cp);
  if (list == null) {
    list=new ArrayList();
    exitPoints.put(cp,list);
  }
  list.add(state);
}
Program: 19904
Project: 19904
Buggy source:
/** 
 * Creates a UnitContext for the given context. This constructor is not directly accessible, use the factory method instead.
 * @param context the context to wrap with this UnitContext
 */
private ContextPair(UnitContext left,UnitContext right){
  this.left=left;
  this.right=right;
  hashCode=99 + left.hashCode() * 113 + right.hashCode();
}

Fixed version (ground truth):
/** 
 * Creates a UnitContext for the given context. This constructor is not directly accessible, use the factory method instead.
 * @param left the left context
 * @param right the right context
 */
private ContextPair(UnitContext left,UnitContext right){
  this.left=left;
  this.right=right;
  hashCode=99 + left.hashCode() * 113 + right.hashCode();
}
Program: 19905
Project: 19905
Buggy source:
/** 
 * Creates a scoreable job
 * @param scoreableList the list of scoreables
 * @param start the starting point for this job
 * @param size the number of scoreables in this job
 */
ScoreableJob(List scoreables,int start,int size){
  this.scoreables=scoreables;
  this.start=start;
  this.size=size;
}

Fixed version (ground truth):
/** 
 * Creates a scoreable job
 * @param scoreables the list of scoreables
 * @param start the starting point for this job
 * @param size the number of scoreables in this job
 */
ScoreableJob(List scoreables,int start,int size){
  this.scoreables=scoreables;
  this.start=start;
  this.size=size;
}
Program: 19906
Project: 19906
Buggy source:
/** 
 * Copy the input rule object but change all instances of a  RuleName to a BaseRuleName.  Used by setRule method in BaseRuleGrammar so there is a place to put the fully resolved rule name when linking a Grammar.
 */
public static Rule copyForBaseRuleName(Rule r){
  if (r == null) {
    return null;
  }
  if (r instanceof RuleToken) {
    RuleToken rt=(RuleToken)r;
    return new RuleToken(rt.getText());
  }
  if (r instanceof RuleAlternatives) {
    RuleAlternatives ra=(RuleAlternatives)r;
    Rule array[]=ra.getRules();
    for (int i=0; i < array.length; i++) {
      array[i]=copyForBaseRuleName(array[i]);
    }
    return new RuleAlternatives(array);
  }
  if (r instanceof RuleSequence) {
    RuleSequence rs=(RuleSequence)r;
    Rule array[]=rs.getRules();
    for (int i=0; i < array.length; i++) {
      array[i]=copyForBaseRuleName(array[i]);
    }
    return new RuleSequence(array);
  }
  if (r instanceof RuleCount) {
    RuleCount rc=(RuleCount)r;
    return new RuleCount(copyForBaseRuleName(rc.getRule()),rc.getCount());
  }
  if (r instanceof RuleTag) {
    RuleTag rt=(RuleTag)r;
    return new RuleTag(copyForBaseRuleName(rt.getRule()),rt.getTag());
  }
  if (r instanceof RuleName) {
    RuleName rn=(RuleName)r;
    return new BaseRuleName(rn.getRuleName());
  }
  throw new RuntimeException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Copy the input rule object but change all instances of a  RuleName to a BaseRuleName.  Used by setRule method in BaseRuleGrammar so there is a place to put the fully resolved rule name when linking a Grammar.
 */
public static Rule copyForBaseRuleName(Rule r){
  if (r == null) {
    return null;
  }
  if (r instanceof RuleToken) {
    RuleToken rt=(RuleToken)r;
    return new RuleToken(rt.getText());
  }
  if (r instanceof RuleAlternatives) {
    RuleAlternatives ra=(RuleAlternatives)r;
    Rule array[]=ra.getRules();
    float[] weights=ra.getWeights();
    for (int i=0; i < array.length; i++) {
      array[i]=copyForBaseRuleName(array[i]);
    }
    return new RuleAlternatives(array,weights);
  }
  if (r instanceof RuleSequence) {
    RuleSequence rs=(RuleSequence)r;
    Rule array[]=rs.getRules();
    for (int i=0; i < array.length; i++) {
      array[i]=copyForBaseRuleName(array[i]);
    }
    return new RuleSequence(array);
  }
  if (r instanceof RuleCount) {
    RuleCount rc=(RuleCount)r;
    return new RuleCount(copyForBaseRuleName(rc.getRule()),rc.getCount());
  }
  if (r instanceof RuleTag) {
    RuleTag rt=(RuleTag)r;
    return new RuleTag(copyForBaseRuleName(rt.getRule()),rt.getTag());
  }
  if (r instanceof RuleName) {
    RuleName rn=(RuleName)r;
    return new BaseRuleName(rn.getRuleName());
  }
  throw new RuntimeException("String_Node_Str");
}
Program: 19908
Project: 19908
Buggy source:
/** 
 * Constructs a LexTreeHMMState
 * @param hmmNode the hmm state associated with this unit
 * @param wordSequence the word history 
 * @param languageProbability the probability of the transition
 * @param insertionProbability the probability of the transition
 * @param acousticProbability the probability of the transitionoccuring
 */
LexTreeHMMState(HMMNode hmmNode,WordSequence wordSequence,HMMState hmmState,float languageProbability,float insertionProbability,float acousticProbability,Node parentNode){
  super(hmmNode,wordSequence);
  this.hmmState=hmmState;
  this.parentNode=parentNode;
  this.logLanguageProbability=languageProbability;
  this.logAcousticProbability=acousticProbability;
  this.logInsertionProbability=insertionProbability;
}

Fixed version (ground truth):
/** 
 * Constructs a LexTreeHMMState
 * @param hmmNode the hmm state associated with this unit
 * @param wordSequence the word history 
 * @param languageProbability the probability of the transition
 * @param insertionProbability the probability of the transition
 * @param acousticProbability the probability of the transitionoccuring
 */
LexTreeHMMState(HMMNode hmmNode,WordSequence wordSequence,HMMState hmmState,float languageProbability,float insertionProbability,float acousticProbability,Node parentNode){
  super(hmmNode,wordSequence);
  this.hmmState=hmmState;
  this.parentNode=parentNode;
  this.logLanguageProbability=languageProbability;
  this.logInsertionProbability=insertionProbability;
  this.logAcousticProbability=acousticProbability;
}
Program: 19909
Project: 19909
Buggy source:
/** 
 * Compiles the n-gram into a lex tree that is used during the search
 */
protected void compileGrammar(){
  Timer.start("String_Node_Str");
  hmmPool=new HMMPool(acousticModel);
  silenceID=hmmPool.getID(Unit.SILENCE);
  hmmTree=new HMMTree(hmmPool,dictionary,languageModel,addFillerWords,languageWeight);
  hmmPool.dumpInfo();
  Timer.stop("String_Node_Str");
  Timer.dumpAll();
}

Fixed version (ground truth):
/** 
 * Compiles the n-gram into a lex tree that is used during the search
 */
protected void compileGrammar(){
  Timer.start("String_Node_Str");
  hmmPool=new HMMPool(acousticModel);
  hmmTree=new HMMTree(hmmPool,dictionary,languageModel,addFillerWords,languageWeight);
  hmmPool.dumpInfo();
  Timer.stop("String_Node_Str");
  Timer.dumpAll();
}
Program: 19910
Project: 19910
Buggy source:
/** 
 * Runs this DecodingThread.
 */
public void run(){
  Result result=decoder.decode();
  if (doEndpointing) {
    microphone.stopRecording();
  }
  String resultText=result.getBestResultNoSilences();
  String tag=getResultTag(resultText);
  cardMatchFrame.processResults(resultText,tag);
  drain();
}

Fixed version (ground truth):
/** 
 * Runs this DecodingThread.
 */
public void run(){
  Result result=decoder.decode();
  if (doEndpointing) {
    microphone.stopRecording();
  }
  String resultText=result.getBestResultNoFiller();
  String tag=getResultTag(resultText);
  cardMatchFrame.processResults(resultText,tag);
  drain();
}
Program: 19911
Project: 19911
Buggy source:
/** 
 * Goes through the active list of tokens and expands each token, finding the set of successor tokens until all the successor tokens are emitting tokens.
 */
protected void growBranches(){
  growTimer.start();
  bestTokenMap=new HashMap(activeList.size() * 10);
  ActiveList oldActiveList=activeList;
  Iterator oldListIterator=activeList.iterator();
  resultList=new LinkedList();
  activeList=activeList.createNew();
  threshold=oldActiveList.getBeamThreshold();
  wordThreshold=oldActiveList.getBestScore() + logRelativeWordBeamWidth;
  while (oldListIterator.hasNext()) {
    Token token=(Token)oldListIterator.next();
    collectSuccessorTokens(token);
  }
  growTimer.stop();
  if (false) {
    int hmms=activeList.size();
    totalHmms+=hmms;
    System.out.println("String_Node_Str" + currentFrameNumber + "String_Node_Str"+ hmms+ "String_Node_Str"+ totalHmms);
  }
}

Fixed version (ground truth):
/** 
 * Goes through the active list of tokens and expands each token, finding the set of successor tokens until all the successor tokens are emitting tokens.
 */
protected void growBranches(){
  int mapSize=activeList.size() * 10;
  if (mapSize == 0) {
    mapSize=1;
  }
  growTimer.start();
  bestTokenMap=new HashMap(mapSize);
  ActiveList oldActiveList=activeList;
  Iterator oldListIterator=activeList.iterator();
  resultList=new LinkedList();
  activeList=activeList.createNew();
  threshold=oldActiveList.getBeamThreshold();
  wordThreshold=oldActiveList.getBestScore() + logRelativeWordBeamWidth;
  while (oldListIterator.hasNext()) {
    Token token=(Token)oldListIterator.next();
    collectSuccessorTokens(token);
  }
  growTimer.stop();
  if (false) {
    int hmms=activeList.size();
    totalHmms+=hmms;
    System.out.println("String_Node_Str" + currentFrameNumber + "String_Node_Str"+ hmms+ "String_Node_Str"+ totalHmms);
  }
}
Program: 19912
Project: 19912
Buggy source:
/** 
 * Replicate the last frame into the last window number of frames in the cepstraBuffer.
 * @return the number of replicated Cepstrum
 */
private int replicateLastCepstrum(){
  float[] last=null;
  if (bufferPosition > 0) {
    last=this.cepstraBuffer[bufferPosition - 1];
  }
 else   if (bufferPosition == 0) {
    last=cepstraBuffer[cepstraBuffer.length - 1];
  }
 else {
    throw new Error("String_Node_Str");
  }
  if (bufferPosition + window < cepstraBufferSize) {
    Arrays.fill(cepstraBuffer,bufferPosition,bufferPosition + window,last);
    bufferPosition+=window;
  }
 else {
    for (int i=0; i < window; i++) {
      addCepstrumData(last);
    }
  }
  return window;
}

Fixed version (ground truth):
/** 
 * Replicate the last frame into the last window number of frames in the cepstraBuffer.
 * @return the number of replicated Cepstrum
 */
private int replicateLastCepstrum(){
  float[] last=null;
  if (bufferPosition > 0) {
    last=this.cepstraBuffer[bufferPosition - 1];
  }
 else   if (bufferPosition == 0) {
    last=cepstraBuffer[cepstraBuffer.length - 1];
  }
 else {
    throw new Error("String_Node_Str");
  }
  for (int i=0; i < window; i++) {
    addCepstrumData(last);
  }
  return window;
}
Program: 19913
Project: 19913
Buggy source:
/** 
 * Returns the next Feature object produced by this LiveFeatureExtractor.
 * @return the next available Feature object, returns null if noFeature object is available
 * @throws java.io.IOException if there is an error readingthe Feature objects
 * @see Feature
 * @see FeatureFrame
 */
public Feature getFeature() throws IOException {
  Cepstrum input=predecessor.getCepstrum();
  if (input != null) {
    if (input.hasContent()) {
      addCepstrumData(input.getCepstrumData());
      computeFeatures(1);
    }
 else     if (input.hasSignal(Signal.UTTERANCE_START)) {
      hasUtteranceEnd=false;
      outputQueue.add(new Feature(Signal.UTTERANCE_START,IDGenerator.NON_ID));
      featureID.reset();
      Cepstrum start=predecessor.getCepstrum();
      int n=processFirstCepstrum(start);
      computeFeatures(n);
      if (hasUtteranceEnd) {
        outputQueue.add(getUtteranceEndFeature());
      }
    }
 else     if (input.hasSignal(Signal.UTTERANCE_END)) {
      int n=replicateLastCepstrum();
      computeFeatures(n);
      outputQueue.add(getUtteranceEndFeature());
    }
  }
  if (outputQueue.size() > 0) {
    Feature feature=(Feature)outputQueue.remove(0);
    return feature;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Returns the next Feature object produced by this LiveFeatureExtractor.
 * @return the next available Feature object, returns null if noFeature object is available
 * @throws java.io.IOException if there is an error readingthe Feature objects
 * @see Feature
 * @see FeatureFrame
 */
public Feature getFeature() throws IOException {
  if (outputQueue.size() == 0) {
    Cepstrum input=predecessor.getCepstrum();
    if (input != null) {
      if (input.hasContent()) {
        addCepstrumData(input.getCepstrumData());
        computeFeatures(1);
      }
 else       if (input.hasSignal(Signal.UTTERANCE_START)) {
        hasUtteranceEnd=false;
        outputQueue.add(new Feature(Signal.UTTERANCE_START,IDGenerator.NON_ID));
        featureID.reset();
        Cepstrum start=predecessor.getCepstrum();
        int n=processFirstCepstrum(start);
        computeFeatures(n);
        if (hasUtteranceEnd) {
          outputQueue.add(getUtteranceEndFeature());
        }
      }
 else       if (input.hasSignal(Signal.UTTERANCE_END)) {
        int n=replicateLastCepstrum();
        computeFeatures(n);
        outputQueue.add(getUtteranceEndFeature());
      }
    }
  }
  if (outputQueue.size() > 0) {
    Feature feature=(Feature)outputQueue.remove(0);
    return feature;
  }
 else {
    return null;
  }
}
Program: 19914
Project: 19914
Buggy source:
/** 
 * Returns the next Feature object from this FrameDropper. The Feature objects belonging to a single Utterance should be preceded by a Feature object with the Signal.UTTERANCE_START, and ended by a Feature object wtih the Signal.UTTERANCE_END.
 * @return the next available Feature object, returns null if noFeature object is available
 * @throws java.io.IOException
 */
public Feature getFeature() throws IOException {
  Feature feature=predecessor.getFeature();
  if (feature.hasContent()) {
    if ((feature.getID() % dropEveryNthFrame) == (dropEveryNthFrame - 1)) {
      if (replaceNthWithPrevious) {
        feature=new Feature(lastFeature.getFeatureData(),id++);
      }
 else {
        feature=predecessor.getFeature();
        if (feature.hasContent()) {
          feature.setID(id++);
        }
      }
    }
 else {
      feature.setID(id++);
    }
  }
 else   if (feature.hasSignal(Signal.UTTERANCE_START)) {
    id=0;
  }
  if (feature.hasContent()) {
    lastFeature=feature;
  }
 else {
    lastFeature=null;
  }
  return feature;
}

Fixed version (ground truth):
/** 
 * Returns the next Feature object from this FrameDropper. The Feature objects belonging to a single Utterance should be preceded by a Feature object with the Signal.UTTERANCE_START, and ended by a Feature object wtih the Signal.UTTERANCE_END.
 * @return the next available Feature object, returns null if noFeature object is available
 * @throws java.io.IOException
 */
public Feature getFeature() throws IOException {
  Feature feature=predecessor.getFeature();
  if (feature != null) {
    if (feature.hasContent()) {
      if ((feature.getID() % dropEveryNthFrame) == (dropEveryNthFrame - 1)) {
        if (replaceNthWithPrevious) {
          feature=new Feature(lastFeature.getFeatureData(),id++);
        }
 else {
          feature=predecessor.getFeature();
          if (feature != null && feature.hasContent()) {
            feature.setID(id++);
          }
        }
      }
 else {
        feature.setID(id++);
      }
    }
    if (feature != null) {
      if (feature.hasSignal(Signal.UTTERANCE_START)) {
        id=0;
      }
      if (feature.hasContent()) {
        lastFeature=feature;
      }
 else {
        lastFeature=null;
      }
    }
 else {
      lastFeature=null;
    }
  }
  return feature;
}
Program: 19915
Project: 19915
Buggy source:
/** 
 * Loads the given sphinx3 style simple dictionary from  the given InputStream. The InputStream is assumed to contain ASCII data.
 * @param inputStream the InputStream of the dictionary
 * @param isFillerDict true if this is a filler dictionary, false otherwise
 * @throws java.io.IOException if there is an error reading the dictionary
 */
private void loadDictionary(InputStream inputStream,boolean isFillerDict) throws IOException {
  InputStreamReader isr=new InputStreamReader(inputStream);
  BufferedReader br=new BufferedReader(isr);
  String line;
  while ((line=br.readLine()) != null) {
    if (line.length() > 0) {
      int spaceIndex=line.indexOf(' ');
      int spaceIndexTab=line.indexOf('\t');
      if (spaceIndex == -1) {
        spaceIndex=spaceIndexTab;
      }
 else       if ((spaceIndexTab >= 0) && (spaceIndexTab < spaceIndex)) {
        spaceIndex=spaceIndexTab;
      }
      if (spaceIndex == -1) {
        throw new Error("String_Node_Str" + line);
      }
      String word=line.substring(0,spaceIndex);
      word=word.toLowerCase();
      if (isFillerDict) {
        dictionary.put(word,(FILLER_TAG + line));
      }
 else {
        dictionary.put(word,line);
      }
    }
  }
  br.close();
  isr.close();
  inputStream.close();
}

Fixed version (ground truth):
/** 
 * Loads the given sphinx3 style simple dictionary from  the given InputStream. The InputStream is assumed to contain ASCII data.
 * @param inputStream the InputStream of the dictionary
 * @param isFillerDict true if this is a filler dictionary, false otherwise
 * @throws java.io.IOException if there is an error reading the dictionary
 */
private void loadDictionary(InputStream inputStream,boolean isFillerDict) throws IOException {
  InputStreamReader isr=new InputStreamReader(inputStream);
  BufferedReader br=new BufferedReader(isr);
  String line;
  while ((line=br.readLine()) != null) {
    if (line.length() > 0) {
      int spaceIndex=line.indexOf(' ');
      int spaceIndexTab=line.indexOf('\t');
      if (spaceIndex == -1) {
        spaceIndex=spaceIndexTab;
      }
 else       if ((spaceIndexTab >= 0) && (spaceIndexTab < spaceIndex)) {
        spaceIndex=spaceIndexTab;
      }
      if (spaceIndex == -1) {
        throw new Error("String_Node_Str" + line);
      }
      String word=line.substring(0,spaceIndex);
      word=word.toLowerCase();
      if (isFillerDict) {
        dictionary.put(word,(FILLER_TAG + line));
        fillerWords.add(word);
      }
 else {
        dictionary.put(word,line);
      }
    }
  }
  br.close();
  isr.close();
  inputStream.close();
}
Program: 19917
Project: 19917
Buggy source:
/** 
 * Gets the set of all filler words in the dictionary
 * @return an array (possibly empty) of all filler words
 */
public Word[] getFillerWords(){
  return (Word[])fillerWords.toArray(new Word[fillerWords.size()]);
}

Fixed version (ground truth):
/** 
 * Gets the set of all filler words in the dictionary
 * @return an array (possibly empty) of all filler words
 */
public Word[] getFillerWords(){
  Word[] fillerWordArray=new Word[fillerWords.size()];
  int index=0;
  for (Iterator i=fillerWords.iterator(); i.hasNext(); ) {
    String spelling=(String)i.next();
    fillerWordArray[index++]=getWord(spelling);
  }
  return fillerWordArray;
}
Program: 19918
Project: 19918
Buggy source:
/** 
 * Create a Word object with the given spelling and pronunciations, and insert it into the dictionary.
 * @param text the spelling of the word
 * @param pronunciation the pronunciation of the word
 * @param isFiller if <code>true</code> this is a filler word
 * @return the word
 */
private Word createWord(String text,Pronunciation[] pronunciation,boolean isFiller){
  Word word=new Word(text,pronunciation,isFiller);
  dictionary.put(text,word);
  if (isFiller) {
    fillerWords.add(word);
  }
  return word;
}

Fixed version (ground truth):
/** 
 * Create a Word object with the given spelling and pronunciations, and insert it into the dictionary.
 * @param text the spelling of the word
 * @param pronunciation the pronunciation of the word
 * @param isFiller if <code>true</code> this is a filler word
 * @return the word
 */
private Word createWord(String text,Pronunciation[] pronunciation,boolean isFiller){
  Word word=new Word(text,pronunciation,isFiller);
  dictionary.put(text,word);
  return word;
}
Program: 19919
Project: 19919
Buggy source:
/** 
 * Handles the given Cepstrum in the case when mergeSpeechSegment is false.
 */
private Cepstrum handleNonMergingCepstrum(Cepstrum cepstrum) throws IOException {
  Cepstrum next=cepstrum;
  if (cepstrum != null) {
    if (cepstrum.hasSignal(Signal.SPEECH_START)) {
      discardMode=false;
      next=new Cepstrum(Signal.UTTERANCE_START);
    }
 else     if (cepstrum.hasSignal(Signal.SPEECH_END)) {
      discardMode=true;
      next=new Cepstrum(Signal.UTTERANCE_END);
    }
 else     if (discardMode) {
      next=handleNonMergingCepstrum(readCepstrum());
    }
  }
  return next;
}

Fixed version (ground truth):
/** 
 * Handles the given Cepstrum in the case when mergeSpeechSegment is false.
 */
private Cepstrum handleNonMergingCepstrum(Cepstrum cepstrum) throws IOException {
  Cepstrum next=cepstrum;
  if (cepstrum != null) {
    if (cepstrum.hasSignal(Signal.SPEECH_START)) {
      discardMode=false;
      next=new Cepstrum(Signal.UTTERANCE_START);
    }
 else     if (cepstrum.hasSignal(Signal.SPEECH_END)) {
      discardMode=true;
      next=new Cepstrum(Signal.UTTERANCE_END);
    }
 else     if (discardMode) {
      while (next.getSignal() != Signal.SPEECH_START && next.getSignal() != Signal.SPEECH_END) {
        next=readCepstrum();
      }
      next=handleNonMergingCepstrum(next);
    }
  }
  return next;
}
Program: 19920
Project: 19920
Buggy source:
/** 
 * Process the given low energy Cepstrum.
 * @param cepstrum the low energy Cepstrum to process
 */
private void processLowEnergyCepstrum(Cepstrum cepstrum){
  if (inSpeech) {
    if (endLowFrames == endOffset) {
      endOffsetFrame=cepstrum;
    }
 else     if (endLowFrames > endWindow) {
      speechEnd();
    }
    endLowFrames++;
  }
 else {
    if (startLowFrames > 1) {
      startHighFrames=0;
    }
    startLowFrames++;
  }
  if (cepstrum.getEnergy() < startLow) {
    location=BELOW_START_LOW;
  }
}

Fixed version (ground truth):
/** 
 * Process the given low energy Cepstrum.
 * @param cepstrum the low energy Cepstrum to process
 */
private void processLowEnergyCepstrum(Cepstrum cepstrum){
  if (inSpeech) {
    if (endLowFrames == endOffset) {
      endOffsetFrame=cepstrum;
    }
 else     if (endLowFrames > endWindow) {
      speechEnd();
    }
    endLowFrames++;
  }
 else {
    if (startLowFrames > maxDropout) {
      startHighFrames=0;
    }
    startLowFrames++;
  }
  if (cepstrum.getEnergy() < startLow) {
    location=BELOW_START_LOW;
  }
}
Program: 19921
Project: 19921
Buggy source:
/** 
 * Process the given high energy Cepstrum.
 * @param cepstrum the high energy Cepstrum to process
 */
private void processHighEnergyCepstrum(Cepstrum cepstrum){
  if (location == BELOW_START_LOW) {
    if (outputQueue.size() > 0) {
      setLastStartLowFrame((Cepstrum)outputQueue.getFirst());
    }
  }
  if (startHighFrames > startWindow) {
    if (!inSpeech) {
      speechStart();
    }
 else {
      endLowFrames=0;
      endOffsetFrame=null;
    }
  }
 else {
    startHighFrames++;
  }
  location=ABOVE_START_HIGH;
}

Fixed version (ground truth):
/** 
 * Process the given high energy Cepstrum.
 * @param cepstrum the high energy Cepstrum to process
 */
private void processHighEnergyCepstrum(Cepstrum cepstrum){
  if (location == BELOW_START_LOW) {
    if (outputQueue.size() > 0) {
      setLastStartLowFrame((Cepstrum)outputQueue.getFirst());
    }
  }
  if (startHighFrames > startWindow) {
    if (!inSpeech) {
      speechStart();
    }
 else {
      endLowFrames=0;
      endOffsetFrame=null;
    }
  }
 else {
    startHighFrames++;
  }
  location=ABOVE_START_HIGH;
  endLowFrames=0;
}
Program: 19922
Project: 19922
Buggy source:
/** 
 * Inserts a SPEECH_START at the appropriate place.
 */
private void insertSpeechStart(){
  int index=outputQueue.indexOf(lastStartLowFrame);
  if (index > -1) {
    int i=0;
    for (ListIterator iterator=outputQueue.listIterator(index); i < startOffset && iterator.hasNext(); i++) {
      Cepstrum cepstrum=(Cepstrum)iterator.next();
      if (cepstrum.hasSignal(Signal.UTTERANCE_START)) {
        break;
      }
    }
    index+=i;
  }
  if (index >= outputQueue.size()) {
    index=outputQueue.size();
  }
 else   if (index < 0) {
    index=0;
    System.out.println("String_Node_Str" + "String_Node_Str");
    for (ListIterator i=outputQueue.listIterator(); i.hasNext(); ) {
      Cepstrum cepstrum=(Cepstrum)i.next();
      if (cepstrum.hasSignal(Signal.UTTERANCE_START)) {
        index=outputQueue.indexOf(cepstrum);
      }
    }
  }
  outputQueue.add(index,(new Cepstrum(Signal.SPEECH_START)));
}

Fixed version (ground truth):
/** 
 * Inserts a SPEECH_START at the appropriate place.
 */
private void insertSpeechStart(){
  int index=outputQueue.indexOf(lastStartLowFrame);
  if (index > -1) {
    int i=0;
    for (ListIterator iterator=outputQueue.listIterator(index); i < startOffset && iterator.hasNext(); i++) {
      Cepstrum cepstrum=(Cepstrum)iterator.next();
      if (cepstrum.hasSignal(Signal.UTTERANCE_START) || cepstrum.hasSignal(Signal.SPEECH_END)) {
        break;
      }
    }
    index+=i;
  }
  if (index >= outputQueue.size()) {
    index=outputQueue.size();
  }
 else   if (index < 0) {
    index=0;
    System.out.println("String_Node_Str" + "String_Node_Str");
    for (ListIterator i=outputQueue.listIterator(); i.hasNext(); ) {
      Cepstrum cepstrum=(Cepstrum)i.next();
      if (cepstrum.hasSignal(Signal.UTTERANCE_START)) {
        index=outputQueue.indexOf(cepstrum);
      }
    }
  }
  outputQueue.add(index,(new Cepstrum(Signal.SPEECH_START)));
}
Program: 19923
Project: 19923
Buggy source:
/** 
 * Process the given low energy Cepstrum.
 * @param cepstrum the low energy Cepstrum to process
 */
private void processLowEnergyCepstrum(Cepstrum cepstrum){
  if (inSpeech) {
    if (endLowFrames == endOffset) {
      endOffsetFrame=cepstrum;
    }
 else     if (endLowFrames > endWindow) {
      speechEnd();
    }
    endLowFrames++;
  }
 else {
    startLowFrames++;
  }
  if (cepstrum.getEnergy() < startLow) {
    location=BELOW_START_LOW;
  }
}

Fixed version (ground truth):
/** 
 * Process the given low energy Cepstrum.
 * @param cepstrum the low energy Cepstrum to process
 */
private void processLowEnergyCepstrum(Cepstrum cepstrum){
  if (inSpeech) {
    if (endLowFrames == endOffset) {
      endOffsetFrame=cepstrum;
    }
 else     if (endLowFrames > endWindow) {
      speechEnd();
    }
    endLowFrames++;
  }
 else {
    if (startLowFrames > 1) {
      startHighFrames=0;
    }
    startLowFrames++;
  }
  if (cepstrum.getEnergy() < startLow) {
    location=BELOW_START_LOW;
  }
}
Program: 19924
Project: 19924
Buggy source:
/** 
 * Scores all of the Scoreables in the ScoreableJob
 * @param job the scoreable job
 * @return the best scoring scoreable in the job
 */
private Scoreable scoreScoreables(ScoreableJob job){
  if (job.getSize() <= 0) {
    return null;
  }
  Scoreable best=job.getFirst();
  List scoreables=job.getScoreables();
  for (int i=job.getStart(); i < job.getSize(); i++) {
    Scoreable scoreable=(Scoreable)scoreables.get(i);
    if (scoreable.getFrameNumber() != curFeature.getID()) {
      throw new Error("String_Node_Str" + scoreable.getFrameNumber() + "String_Node_Str"+ curFeature.getID());
    }
    if (scoreable.calculateScore(curFeature) > best.getScore()) {
      best=scoreable;
    }
  }
  return best;
}

Fixed version (ground truth):
/** 
 * Scores all of the Scoreables in the ScoreableJob
 * @param job the scoreable job
 * @return the best scoring scoreable in the job
 */
private Scoreable scoreScoreables(ScoreableJob job){
  Scoreable best=job.getFirst();
  int listSize=job.getScoreables().size();
  int end=job.getStart() + job.getSize();
  if (end > listSize) {
    end=listSize;
  }
  ListIterator iterator=job.getListIterator();
  for (int i=job.getStart(); i < end; i++) {
    Scoreable scoreable=(Scoreable)iterator.next();
    if (scoreable.getFrameNumber() != curFeature.getID()) {
      throw new Error("String_Node_Str" + scoreable.getFrameNumber() + "String_Node_Str"+ curFeature.getID());
    }
    if (scoreable.calculateScore(curFeature) > best.getScore()) {
      best=scoreable;
    }
  }
  return best;
}
Program: 19925
Project: 19925
Buggy source:
/** 
 * Creates a scoreable job
 * @param scoreableList the list of scoreables
 * @param start the starting point for this job
 * @param size the number of scoreables in this job
 */
ScoreableJob(List scoreables,int start,int size){
  this.scoreables=scoreables;
  this.start=start;
  if ((start + size) > scoreables.size()) {
    this.size=scoreables.size() - start;
  }
 else {
    this.size=size;
  }
}

Fixed version (ground truth):
/** 
 * Creates a scoreable job
 * @param scoreableList the list of scoreables
 * @param start the starting point for this job
 * @param size the number of scoreables in this job
 */
ScoreableJob(List scoreables,int start,int size){
  this.scoreables=scoreables;
  this.start=start;
  this.size=size;
}
Program: 19926
Project: 19926
Buggy source:
public void run(){
  if (!handsFree) {
    lastResult=decoder.decode(liveFrame.getReference());
    updateLiveFrame(decoder.getNISTAlign());
    liveFrame.setButtonsEnabled(true);
    liveFrame.setDecoderComboBoxEnabled(true);
  }
 else {
    liveFrame.setNextButtonEnabled(true);
    while (decoder.getMicrophone().getRecording()) {
      try {
        System.out.println("String_Node_Str");
        lastResult=decoder.decode(liveFrame.getReference());
        System.out.println("String_Node_Str");
        updateLiveFrame(decoder.getNISTAlign());
        System.out.println("String_Node_Str");
      }
 catch (      NullPointerException npe) {
        npe.printStackTrace();
      }
    }
  }
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
public void run(){
  if (!handsFree) {
    lastResult=decoder.decode(liveFrame.getReference());
    updateLiveFrame(decoder.getNISTAlign());
    liveFrame.setButtonsEnabled(true);
    liveFrame.setDecoderComboBoxEnabled(true);
  }
 else {
    liveFrame.setNextButtonEnabled(true);
    while (decoder.getMicrophone().getRecording()) {
      try {
        System.out.println("String_Node_Str");
        lastResult=decoder.decode();
        decoder.setReferenceText(liveFrame.getReference());
        decoder.showFinalResult(lastResult,decoder.getTimer());
        System.out.println("String_Node_Str");
        updateLiveFrame(decoder.getNISTAlign());
      }
 catch (      NullPointerException npe) {
        npe.printStackTrace();
      }
    }
  }
  System.out.println("String_Node_Str");
}
Program: 19928
Project: 19928
Buggy source:
/** 
 * Adds transition matrix to the transition matrices pool
 * @param pool the pool to add matrix to
 * @param stid current HMM's id
 * @param numStates number of states in current HMM
 * @param floor the transition probability floor
 * @param skip if true, states can be skipped
 * @throws IOException if an error occurs while loading the data
 */
private void addModelToTransitionMatricesPool(Pool pool,int stid,int numStates,float floor,boolean skip) throws IOException {
}

Fixed version (ground truth):
/** 
 * Adds transition matrix to the transition matrices pool
 * @param pool the pool to add matrix to
 * @param hmmId current HMM's id
 * @param numStates number of states in current HMM
 * @param floor the transition probability floor
 * @param skip if true, states can be skipped
 * @throws IOException if an error occurs while loading the data
 */
private void addModelToTransitionMatricesPool(Pool pool,int hmmId,int numEmittingStates,float floor,boolean skip) throws IOException {
}
Program: 19929
Project: 19929
Buggy source:
/** 
 * Adds a model to the senone pool.
 * @param pool the senone pool
 * @param stateID vector with senone ID for an HMM
 * @param distFloor the lowest allowed score 
 * @return the senone pool
 */
private void addModelToSenonePool(Pool pool,int[] stateID,float distFloor){
}

Fixed version (ground truth):
/** 
 * Adds a model to the senone pool.
 * @param pool the senone pool
 * @param stateID vector with senone ID for an HMM
 * @param distFloor the lowest allowed score 
 * @param varianceFloor the lowest allowed variance
 * @return the senone pool
 */
private void addModelToSenonePool(Pool pool,int[] stateID,float distFloor,float varianceFloor){
}
Program: 19930
Project: 19930
Buggy source:
/** 
 * Update the models.
 */
protected void update(){
  updateMeans();
  updateVariances();
  updateMixtureWeights();
  updateTransitionMatrices();
}

Fixed version (ground truth):
/** 
 * Update the models.
 */
protected void update(){
  updateMeans();
  updateVariances();
  recomputeMixtureComponents();
  updateMixtureWeights();
  updateTransitionMatrices();
}
Program: 19931
Project: 19931
Buggy source:
/** 
 * Accumulate the transition probabilities.
 */
private void accumulateTransition(int indexHmm,TrainerScore score,TrainerScore[] nextScore){
  if (indexHmm == TrainerAcousticModel.ALL_MODELS) {
    for (Iterator i=hmmManager.getIterator(); i.hasNext(); ) {
      HMM hmm=(HMM)i.next();
      for (int j=0; j < hmm.getOrder(); j++) {
        accumulateStateTransition(j,hmm,score.getScore());
      }
    }
  }
 else {
    HMMState state=score.getState();
    accumulateStateTransition(state.getState(),score,nextScore);
  }
}

Fixed version (ground truth):
/** 
 * Accumulate the transition probabilities.
 */
private void accumulateTransition(int indexHmm,int indexScore,TrainerScore[] score,TrainerScore[] nextScore){
  if (indexHmm == TrainerAcousticModel.ALL_MODELS) {
    for (Iterator i=hmmManager.getIterator(); i.hasNext(); ) {
      HMM hmm=(HMM)i.next();
      for (int j=0; j < hmm.getOrder(); j++) {
        accumulateStateTransition(j,hmm,score[indexScore].getScore());
      }
    }
  }
 else {
    if (nextScore != null) {
      accumulateStateTransition(indexScore,score,nextScore);
    }
  }
}
Program: 19932
Project: 19932
Buggy source:
/** 
 * Accumulate the TrainerScore into the buffers.
 * @param score the TrainerScore
 * @param nextScore the TrainerScore for the next time frame
 */
protected void accumulate(TrainerScore score,TrainerScore[] nextScore){
  int senoneID;
  HMMState state=score.getState();
  if (state == null) {
    senoneID=score.getSenoneID();
  }
 else {
    senoneID=senonePool.indexOf(state.getSenone());
  }
  Feature feature=score.getFeature();
  currentLogLikelihood=score.getLogLikelihood();
  float prob=score.getScore();
  accumulateMean(senoneID,score);
  accumulateVariance(senoneID,score);
  accumulateMixture(senoneID,score);
  accumulateTransition(senoneID,score,nextScore);
}

Fixed version (ground truth):
/** 
 * Accumulate the TrainerScore into the buffers.
 * @param index the current index into the TrainerScore vector
 * @param score the TrainerScore for the current frame
 * @param nextScore the TrainerScore for the next time frame
 */
protected void accumulate(int index,TrainerScore[] score,TrainerScore[] nextScore){
  int senoneID;
  TrainerScore thisScore=score[index];
  Feature feature=thisScore.getFeature();
  currentLogLikelihood=thisScore.getLogLikelihood();
  HMMState state=thisScore.getState();
  if (state == null) {
    senoneID=thisScore.getSenoneID();
    if (senoneID == TrainerAcousticModel.ALL_MODELS) {
      accumulateMean(senoneID,score[index]);
      accumulateVariance(senoneID,score[index]);
      accumulateMixture(senoneID,score[index]);
      accumulateTransition(senoneID,index,score,nextScore);
    }
  }
 else {
    if (state.isEmitting()) {
      senoneID=senonePool.indexOf(state.getSenone());
      accumulateMean(senoneID,score[index]);
      accumulateVariance(senoneID,score[index]);
      accumulateMixture(senoneID,score[index]);
      accumulateTransition(senoneID,index,score,nextScore);
    }
  }
}
Program: 19933
Project: 19933
Buggy source:
/** 
 * Constructor for this pool manager. It gets the pointers to the pools from a loader.
 * @param loader the loader
 */
protected HMMPoolManager(Loader loader,SphinxProperties props){
  hmmManager=loader.getHMMManager();
  meansPool=loader.getMeansPool();
  variancePool=loader.getVariancePool();
  mixtureWeightsPool=loader.getMixtureWeightPool();
  matrixPool=loader.getTransitionMatrixPool();
  senonePool=loader.getSenonePool();
  logMath=LogMath.getLogMath(props.getContext());
  float mixtureWeightFloor=props.getFloat(AcousticModel.PROP_MW_FLOOR,AcousticModel.PROP_MW_FLOOR_DEFAULT);
  logMixtureWeightFloor=logMath.linearToLog(mixtureWeightFloor);
  float transitionProbabilityFloor=props.getFloat(AcousticModel.PROP_TP_FLOOR,AcousticModel.PROP_TP_FLOOR_DEFAULT);
  logTransitionProbabilityFloor=logMath.linearToLog(transitionProbabilityFloor);
  varianceFloor=props.getFloat(AcousticModel.PROP_VARIANCE_FLOOR,AcousticModel.PROP_VARIANCE_FLOOR_DEFAULT);
  createBuffers();
  logLikelihood=LogMath.getLogZero();
}

Fixed version (ground truth):
/** 
 * Constructor for this pool manager. It gets the pointers to the pools from a loader.
 * @param loader the loader
 */
protected HMMPoolManager(Loader loader,SphinxProperties props){
  hmmManager=loader.getHMMManager();
  meansPool=loader.getMeansPool();
  variancePool=loader.getVariancePool();
  mixtureWeightsPool=loader.getMixtureWeightPool();
  matrixPool=loader.getTransitionMatrixPool();
  senonePool=loader.getSenonePool();
  logMath=LogMath.getLogMath(props.getContext());
  float mixtureWeightFloor=props.getFloat(AcousticModel.PROP_MW_FLOOR,AcousticModel.PROP_MW_FLOOR_DEFAULT);
  logMixtureWeightFloor=logMath.linearToLog(mixtureWeightFloor);
  float transitionProbabilityFloor=props.getFloat(AcousticModel.PROP_TP_FLOOR,AcousticModel.PROP_TP_FLOOR_DEFAULT);
  logTransitionProbabilityFloor=logMath.linearToLog(transitionProbabilityFloor);
  varianceFloor=props.getFloat(AcousticModel.PROP_VARIANCE_FLOOR,AcousticModel.PROP_VARIANCE_FLOOR_DEFAULT);
  createBuffers();
  logLikelihood=0.0f;
}
Program: 19934
Project: 19934
Buggy source:
/** 
 * Construct a FullDictionaryTest with the given SphinxProperties file.
 * @param propertiesFile a SphinxProperties file
 */
public LMGramTest(String propertiesFile) throws Exception {
  LanguageModel languageModel;
  edu.cmu.sphinx.decoder.linguist.Grammar grammar;
  String pwd=System.getProperty("String_Node_Str");
  SphinxProperties.initContext(context,new URL("String_Node_Str" + pwd + File.separatorChar+ propertiesFile));
  SphinxProperties props=SphinxProperties.getSphinxProperties(context);
  Timer lmTimer=Timer.getTimer("String_Node_Str","String_Node_Str");
  Timer gramTimer=Timer.getTimer("String_Node_Str","String_Node_Str");
  lmTimer.start();
  languageModel=LanguageModelFactory.createLanguageModel(context);
  lmTimer.stop();
  Utilities.dumpMemoryInfo("String_Node_Str");
  gramTimer.start();
  grammar=new edu.cmu.sphinx.decoder.linguist.LMGrammar();
  grammar.initialize(props.getContext(),languageModel,null);
  gramTimer.stop();
  Utilities.dumpMemoryInfo("String_Node_Str");
  Timer.dumpAll();
  grammar.dumpStatistics();
}

Fixed version (ground truth):
/** 
 * Construct a FullDictionaryTest with the given SphinxProperties file.
 * @param propertiesFile a SphinxProperties file
 */
public LMGramTest(String propertiesFile) throws Exception {
  LanguageModel languageModel;
  edu.cmu.sphinx.decoder.linguist.Grammar grammar;
  String pwd=System.getProperty("String_Node_Str");
  SphinxProperties.initContext(context,new URL("String_Node_Str" + pwd + File.separatorChar+ propertiesFile));
  SphinxProperties props=SphinxProperties.getSphinxProperties(context);
  Timer lmTimer=Timer.getTimer("String_Node_Str","String_Node_Str");
  Timer gramTimer=Timer.getTimer("String_Node_Str","String_Node_Str");
  Dictionary dictionary=new FullDictionary(context);
  lmTimer.start();
  languageModel=LanguageModelFactory.createLanguageModel(context,dictionary);
  lmTimer.stop();
  Utilities.dumpMemoryInfo("String_Node_Str");
  gramTimer.start();
  grammar=new edu.cmu.sphinx.decoder.linguist.LMGrammar();
  grammar.initialize(props.getContext(),languageModel,null);
  gramTimer.stop();
  Utilities.dumpMemoryInfo("String_Node_Str");
  Timer.dumpAll();
  grammar.dumpStatistics();
}
Program: 19935
Project: 19935
Buggy source:
/** 
 * Creates a new buffer
 * @param size the number of elements in this buffer
 */
Buffer(int size){
  numerator=new float[size];
}

Fixed version (ground truth):
/** 
 * Creates a new buffer. If the values will be in log, the buffer is initialized to all <code>LogMath.getLogZero()</code>.
 * @param size the number of elements in this buffer
 * @param isLog if true, the values in the buffer will be in log
 */
Buffer(int size,boolean isLog){
  this.isLog=isLog;
  numerator=new float[size];
  if (isLog) {
    denominator=LogMath.getLogZero();
    for (int i=0; i < size; i++) {
      numerator[i]=LogMath.getLogZero();
    }
  }
}
Program: 19936
Project: 19936
Buggy source:
/** 
 * Normalize the buffer in log scale. The normalization is done so that the summation of elements in the buffer is log(1) = 0. In this, we assume that if an element has a value of zero, it won't be updated.
 * @param logMath the logMath to use
 */
void logNormalizeToSum(LogMath logMath){
  float logZero=logMath.getLogZero();
  float den=logZero;
  for (int i=0; i < numerator.length; i++) {
    if (numerator[i] != logZero) {
      den=logMath.addAsLinear(den,numerator[i]);
    }
  }
  for (int i=0; i < numerator.length; i++) {
    if (numerator[i] != logZero) {
      numerator[i]-=den;
    }
  }
  denominator=0.0f;
}

Fixed version (ground truth):
/** 
 * Normalize the buffer in log scale. The normalization is done so that the summation of elements in the buffer is log(1) = 0. In this, we assume that if an element has a value of zero, it won't be updated.
 * @param logMath the logMath to use
 */
void logNormalizeToSum(LogMath logMath){
  assert isLog;
  float logZero=logMath.getLogZero();
  float den=logZero;
  for (int i=0; i < numerator.length; i++) {
    if (numerator[i] != logZero) {
      den=logMath.addAsLinear(den,numerator[i]);
    }
  }
  for (int i=0; i < numerator.length; i++) {
    if (numerator[i] != logZero) {
      numerator[i]-=den;
    }
  }
  denominator=0.0f;
}
Program: 19937
Project: 19937
Buggy source:
/** 
 * Normalize the buffer. This method divides the numerator by the denominator, storing the result in the numerator, and setting denominator to 1.
 */
void normalize(){
  float invDenominator=1.0f / denominator;
  for (int i=0; i < numerator.length; i++) {
    numerator[i]*=invDenominator;
  }
  denominator=1.0f;
}

Fixed version (ground truth):
/** 
 * Normalize the buffer. This method divides the numerator by the denominator, storing the result in the numerator, and setting denominator to 1.
 */
void normalize(){
}
Program: 19938
Project: 19938
Buggy source:
/** 
 * Normalize the buffer. The normalization is done so that the summation of elements in the buffer is 1.
 */
void normalizeToSum(){
  float den=0.0f;
  for (int i=0; i < numerator.length; i++) {
    den+=numerator[i];
  }
  float invDenominator=1.0f / den;
  for (int i=0; i < numerator.length; i++) {
    numerator[i]*=invDenominator;
  }
  denominator=1.0f;
}

Fixed version (ground truth):
/** 
 * Normalize the buffer. The normalization is done so that the summation of elements in the buffer is 1.
 */
void normalizeToSum(){
}
Program: 19939
Project: 19939
Buggy source:
/** 
 * Floor the buffer in log scale.
 * @param logFloor the floor for this buffer, in log scale
 * @return if true, the buffer was modified
 */
protected boolean logFloor(float logFloor){
  boolean wasModified=false;
  for (int i=0; i < numerator.length; i++) {
    if (numerator[i] < logFloor) {
      wasModified=true;
      numerator[i]=logFloor;
    }
  }
  return wasModified;
}

Fixed version (ground truth):
/** 
 * Floor the buffer in log scale.
 * @param logFloor the floor for this buffer, in log scale
 * @return if true, the buffer was modified
 */
protected boolean logFloor(float logFloor){
  assert isLog;
  boolean wasModified=false;
  for (int i=0; i < numerator.length; i++) {
    if (numerator[i] < logFloor) {
      wasModified=true;
      numerator[i]=logFloor;
    }
  }
  return wasModified;
}
Program: 19940
Project: 19940
Buggy source:
/** 
 * Floor the buffer.
 * @param floor the floor for this buffer
 * @return if true, the buffer was modified
 */
protected boolean floor(float floor){
  boolean wasModified=false;
  for (int i=0; i < numerator.length; i++) {
    if (numerator[i] < floor) {
      wasModified=true;
      numerator[i]=floor;
    }
  }
  return wasModified;
}

Fixed version (ground truth):
/** 
 * Floor the buffer.
 * @param floor the floor for this buffer
 * @return if true, the buffer was modified
 */
protected boolean floor(float floor){
}
Program: 19941
Project: 19941
Buggy source:
/** 
 * Normalize the buffer in log scale. This method divides the numerator by the denominator, storing the result in the numerator, and setting denominator to log(1) = 0.
 */
void logNormalize(){
  for (int i=0; i < numerator.length; i++) {
    numerator[i]-=denominator;
  }
  denominator=0.0f;
}

Fixed version (ground truth):
/** 
 * Normalize the buffer in log scale. This method divides the numerator by the denominator, storing the result in the numerator, and setting denominator to log(1) = 0.
 */
void logNormalize(){
  assert isLog;
  for (int i=0; i < numerator.length; i++) {
    numerator[i]-=denominator;
  }
  denominator=0.0f;
}