[Demonstration 1]

[Buggy Method]
private void spotNGrams(Blackboard blackboard, DocumentComponent component) {
    // are we a sentence? if yes, spot the nGrams
    if (component.hasComponents()) {
        List<DocumentComponent> children = component.getComponents();
        // if not and we're a section, traverse the document tree recursively
        for (DocumentComponent child : children) {
            spotNGrams(blackboard, child);
        }
    } else {
        String sentenceText = component.getText();
        Sentence sent = (Sentence) component;
        List<Token> allWords = sent.getTokens();
        // build the token start and end substring indexes in the input string
        int[] startIndexes = new int[allWords.size()];
        int[] endIndexes = new int[allWords.size()];
        // track how much text we've already scanned
        int searchWordFrom = 0;
        for (int i = 0; i < allWords.size(); i++) {
            startIndexes[i] = sentenceText.indexOf(allWords.get(i).getText(), searchWordFrom);
            endIndexes[i] = startIndexes[i] + allWords.get(i).getText().length();
            searchWordFrom = endIndexes[i];
        }
        // we keep n buffers of the last n words scanned
        // (where n = maxngramsize ). The first buffer is of size 1,
        // the second of size 2, ... and so on.
        // then, we compare these buffers with the valid known PoS patterns
        // and save the ngram if it matches.
        ArrayList<Token>[] lastReadBuffers = new ArrayList[maxGramSize];
        for (int size = 0; size < maxGramSize; size++) {
            lastReadBuffers[size] = new ArrayList<>();
        }
        for (int i = 0; i < allWords.size(); i++) {
            Token word = allWords.get(i);
            for (int size = 0; size < maxGramSize; size++) {
                // if the buffer is not full, fill it
                if (lastReadBuffers[size].size() < size + 1) {
                    lastReadBuffers[size].add(word);
                } else {
                    // else, cut the head and put the new word at the tail
                    lastReadBuffers[size].remove(0);
                    lastReadBuffers[size].add(word);
                }
                if (i >= size) {
                    // if the pattern is in the database AND contains a noun, then
                    // it's a nGram that could be a keyphrase.
                    int nounValue = checkGramNounValue(lastReadBuffers[size]);
                    if (nounValue > 0) {
                        // the identifier is the stem of the words
                        String identifier = lastReadBuffers[size].get(0).getText();
                        for (int k = 1; k < lastReadBuffers[size].size(); k++) {
                            identifier = identifier + " " + lastReadBuffers[size].get(k).getStem();
                        }
                        identifier = identifier.toLowerCase();
                        int startIndex = startIndexes[i - (lastReadBuffers[size].size() - 1)];
                        int endIndex = endIndexes[i];
                        Keyphrase g = new Keyphrase(identifier, lastReadBuffers[size], sentenceText.substring(startIndex, endIndex));
                        g.putFeature(new FeatureAnnotation(NOUNVALUE, ((float) nounValue) / (float) g.getTokens().size()));
                        blackboard.addGram(component, g);
                    }
                }
            }
            // for
        }
        // for
    }
    // if
}

[Buggy Hunk]
String identifier = lastReadBuffers[size].get(0).getText();

[Patch]
String identifier = lastReadBuffers[size].get(0).getStem();

[Demonstration 2]

[Buggy Method]
public boolean insertRecord(String schema, String tableName, java.util.List<CoalesceParameter> parameters) throws CoalesceException {
    boolean success = false;
    StringBuilder sql = new StringBuilder("insert into ").append(schema).append(".").append(NORMALIZER.normalize(tableName)).append(" (");
    boolean first = true;
    for (CoalesceParameter parameter : parameters) {
        if (!first) {
            sql.append(",");
        } else {
            first = false;
        }
        sql.append(parameter.getName());
    }
    sql.append(") values (");
    first = true;
    for (CoalesceParameter parameter : parameters) {
        if (!first) {
            sql.append(",");
        } else {
            first = false;
        }
        if (parameter.getType() == ECoalesceFieldDataTypes.STRING_TYPE.ordinal() || parameter.getType() == ECoalesceFieldDataTypes.GUID_TYPE.ordinal()) {
            sql.append(quote(parameter.getValue()));
        } else {
            sql.append(parameter.getValue());
        }
    }
    sql.append(")");
    try {
        LOGGER.trace("Insert Record SQL: " + sql);
        Connection conn = this.getConnection();
        Statement stmt = conn.createStatement();
        stmt.executeUpdate(sql.toString());
        success = true;
    } catch (SQLException e) {
        throw new CoalesceException("Insert Record Failed", e);
    }
    return success;
}

[Buggy Hunk]
sql.append(parameter.getName());

[Patch]
sql.append(NORMALIZER.normalize(parameter.getName()));

[Demonstration 3]

[Buggy Method]
public void notifyChanged(Notification notification) {
    super.notifyChanged(notification);
    if (notification.getFeature() instanceof EAttributeImpl) {
        if (notification.getNotifier() instanceof BoundsImpl) {
            reposition(((BoundsImpl) notification.getNotifier()).getX(), ((BoundsImpl) notification.getNotifier()).getY(), ((BoundsImpl) notification.getNotifier()).getWidth(), getTreeHeight());
            FigureCanvas canvas = (FigureCanvas) getViewer().getControl();
            canvas.getViewport().repaint();
        }
    }
}

[Buggy Hunk]
getTreeHeight());

[Patch]
TreeNodeUtils.getTreeHeight(inputRootTreeNode, LEAF_HEIGHT));