Example usage for org.deeplearning4j.text.documentiterator LabelledDocument setLabel

List of usage examples for org.deeplearning4j.text.documentiterator LabelledDocument setLabel

Introduction

In this page you can find the example usage for org.deeplearning4j.text.documentiterator LabelledDocument setLabel.

Prototype

@Deprecated
    public void setLabel(String label) 

Source Link

Usage

From source file:org.knime.ext.textprocessing.dl4j.data.BufferedDataTableLabelledDocumentIterator.java

License:Open Source License

/**
 * Returns the next {@link LabelledDocument} containing a document and a corresponding label from the
 * {@link BufferedDataTable}.//w w  w  .jav a2s.c om
 *
 * @return the next labelled document
 */
@Override
public LabelledDocument nextDocument() {
    final DataRow row = m_tableIterator.next();
    final DataCell documentCell = row.getCell(m_documentColumnIndex);

    if (m_skipMissing && containsMissing(row)) {
        m_currentRow++;
        return nextDocument();
    }

    String documentContent = null;
    try {
        documentContent = ConverterUtils.convertDataCellToJava(documentCell, String.class);
    } catch (DataCellConversionException e) {
        throw new RuntimeException("Error in row " + row.getKey() + " : " + e.getMessage(), e);
    }

    String documentLabel = m_labels.get(m_nonEmptyRowCounter);
    final LabelledDocument output = new LabelledDocument();
    output.setContent(documentContent);
    output.setLabel(documentLabel);

    m_nonEmptyRowCounter++;
    m_currentRow++;

    return output;
}