Program: 12364
Project: 12364
Buggy source:
/** 
 * Use existing context windows to count term/word frequency within contexts. Context overlap zones are generated for adjacent context windows.
 * @param docIds
 * @return
 */
private int useExistingContexts(List<Integer> docIds){
  int count=0;
  for (  int docId : docIds) {
    count++;
    try {
      Terms lookupVector=SolrUtil.getTermVector(docId,properties.getSolrFieldnameJATENGramInfo(),solrIndexSearcher);
      List<MWEInSentence> terms=collectTermSentenceContext(lookupVector,new HashMap<>());
      List<ContextWindow> contexts_in_doc=contextLookup.get(docId);
      if (contexts_in_doc == null || contexts_in_doc.size() == 0)       continue;
      Collections.sort(contexts_in_doc);
      int cursor=0;
      ContextWindow prevCtx=null;
      for (      ContextWindow ctx : contexts_in_doc) {
        ContextOverlap co=null;
        if (prevCtx != null && prevCtx.getSentenceId() == ctx.getSentenceId()) {
          if (prevCtx.getLastTok() >= ctx.getFirstTok()) {
            co=new ContextOverlap(prevCtx,ctx,new ArrayList<>());
          }
        }
        if (ctx.getDocId() == 399 && ctx.getSentenceId() == 1 && ctx.getFirstTok() == 13 && ctx.getLastTok() == 23)         System.out.println("String_Node_Str");
        int indexFirstIncludedTermByContext=-1;
        for (int i=cursor; i < terms.size(); i++) {
          MWEInSentence t=terms.get(i);
          if (ctx.getSentenceId() < t.sentenceId) {
            cursor=indexFirstIncludedTermByContext;
            break;
          }
 else           if (ctx.getSentenceId() > t.sentenceId) {
            continue;
          }
          boolean outOfContext=false;
          if ((t.firstTokenIndex >= ctx.getFirstTok() && t.firstTokenIndex <= ctx.getLastTok()) || t.lastTokenIndex >= ctx.getFirstTok() && t.lastTokenIndex <= ctx.getLastTok()) {
            feature.increment(ctx,1);
            feature.increment(ctx,t.string,1);
            if (indexFirstIncludedTermByContext == -1)             indexFirstIncludedTermByContext=i;
          }
 else           if (t.lastTokenIndex < ctx.getFirstTok()) {
            continue;
          }
 else {
            outOfContext=true;
            if (indexFirstIncludedTermByContext != -1)             cursor=indexFirstIncludedTermByContext;
          }
          if (co != null) {
            if ((co.getPrevContext().getLastTok() >= t.firstTokenIndex && co.getNextContext().getFirstTok() <= t.firstTokenIndex) || (co.getPrevContext().getLastTok() >= t.lastTokenIndex && co.getNextContext().getFirstTok() <= t.lastTokenIndex) || (co.getPrevContext().getFirstTok() <= t.firstTokenIndex && co.getPrevContext().getLastTok() >= t.firstTokenIndex && co.getNextContext().getLastTok() >= t.lastTokenIndex && co.getNextContext().getFirstTok() <= t.lastTokenIndex)) {
              co.getTerms().add(t.string);
            }
          }
          if (outOfContext)           break;
        }
        prevCtx=ctx;
        if (co != null && co.getTerms().size() > 0)         feature.addCtxOverlapZone(co);
      }
    }
 catch (    IOException|JATEException ioe) {
      StringBuilder sb=new StringBuilder("String_Node_Str");
      sb.append(docId).append("String_Node_Str");
      sb.append(ExceptionUtils.getFullStackTrace(ioe));
      LOG.severe(sb.toString());
    }
  }
  return count;
}

Fixed version (ground truth):
/** 
 * Use existing context windows to count term/word frequency within contexts. Context overlap zones are generated for adjacent context windows.
 * @param docIds
 * @return
 */
private int useExistingContexts(List<Integer> docIds){
  int count=0;
  for (  int docId : docIds) {
    count++;
    try {
      Terms lookupVector=SolrUtil.getTermVector(docId,properties.getSolrFieldnameJATENGramInfo(),solrIndexSearcher);
      List<MWEInSentence> terms=collectTermSentenceContext(lookupVector,new HashMap<>());
      List<ContextWindow> contexts_in_doc=contextLookup.get(docId);
      if (contexts_in_doc == null || contexts_in_doc.size() == 0)       continue;
      Collections.sort(contexts_in_doc);
      int cursor=0;
      ContextWindow prevCtx=null;
      for (      ContextWindow ctx : contexts_in_doc) {
        ContextOverlap co=null;
        if (prevCtx != null && prevCtx.getSentenceId() == ctx.getSentenceId()) {
          if (prevCtx.getLastTok() >= ctx.getFirstTok()) {
            co=new ContextOverlap(prevCtx,ctx,new ArrayList<>());
          }
        }
        int indexFirstIncludedTermByContext=-1;
        for (int i=cursor; i < terms.size(); i++) {
          MWEInSentence t=terms.get(i);
          if (ctx.getSentenceId() < t.sentenceId) {
            cursor=indexFirstIncludedTermByContext;
            break;
          }
 else           if (ctx.getSentenceId() > t.sentenceId) {
            continue;
          }
          boolean outOfContext=false;
          if ((t.firstTokenIndex >= ctx.getFirstTok() && t.firstTokenIndex <= ctx.getLastTok()) || t.lastTokenIndex >= ctx.getFirstTok() && t.lastTokenIndex <= ctx.getLastTok()) {
            feature.increment(ctx,1);
            feature.increment(ctx,t.string,1);
            if (indexFirstIncludedTermByContext == -1)             indexFirstIncludedTermByContext=i;
          }
 else           if (t.lastTokenIndex < ctx.getFirstTok()) {
            continue;
          }
 else {
            outOfContext=true;
            if (indexFirstIncludedTermByContext != -1)             cursor=indexFirstIncludedTermByContext;
          }
          if (co != null) {
            if ((co.getPrevContext().getLastTok() >= t.firstTokenIndex && co.getNextContext().getFirstTok() <= t.firstTokenIndex) || (co.getPrevContext().getLastTok() >= t.lastTokenIndex && co.getNextContext().getFirstTok() <= t.lastTokenIndex) || (co.getPrevContext().getFirstTok() <= t.firstTokenIndex && co.getPrevContext().getLastTok() >= t.firstTokenIndex && co.getNextContext().getLastTok() >= t.lastTokenIndex && co.getNextContext().getFirstTok() <= t.lastTokenIndex)) {
              co.getTerms().add(t.string);
            }
          }
          if (outOfContext)           break;
        }
        prevCtx=ctx;
        if (co != null && co.getTerms().size() > 0)         feature.addCtxOverlapZone(co);
      }
    }
 catch (    IOException|JATEException ioe) {
      StringBuilder sb=new StringBuilder("String_Node_Str");
      sb.append(docId).append("String_Node_Str");
      sb.append(ExceptionUtils.getFullStackTrace(ioe));
      LOG.severe(sb.toString());
    }
  }
  return count;
}