use of org.knime.base.node.preproc.pmml.PMMLStringConversionTranslator in project knime-core by knime.
the class StringToNumberNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inObjects, final ExecutionContext exec) throws Exception {
StringBuilder warnings = new StringBuilder();
BufferedDataTable inData = (BufferedDataTable) inObjects[0];
DataTableSpec inSpec = inData.getDataTableSpec();
// find indices to work on.
List<String> inclcols = m_inclCols.getIncludeList();
BufferedDataTable resultTable = null;
if (inclcols.size() == 0) {
// nothing to convert, let's return the input table.
resultTable = inData;
setWarningMessage("No columns selected," + " returning input DataTable.");
} else {
int[] indices = findColumnIndices(inSpec);
ConverterFactory converterFac = new ConverterFactory(indices, inSpec, m_parseType);
ColumnRearranger colre = new ColumnRearranger(inSpec);
colre.replace(converterFac, indices);
resultTable = exec.createColumnRearrangeTable(inData, colre, exec);
String errorMessage = converterFac.getErrorMessage();
if (errorMessage.length() > 0) {
warnings.append("Problems occurred, see Console messages.\n");
}
if (warnings.length() > 0) {
LOGGER.warn(errorMessage);
setWarningMessage(warnings.toString());
}
}
// the optional PMML in port (can be null)
PMMLPortObject inPMMLPort = m_pmmlInEnabled ? (PMMLPortObject) inObjects[1] : null;
PMMLStringConversionTranslator trans = new PMMLStringConversionTranslator(m_inclCols.getIncludeList(), m_parseType, new DerivedFieldMapper(inPMMLPort));
PMMLPortObjectSpecCreator creator = new PMMLPortObjectSpecCreator(inPMMLPort, inSpec);
PMMLPortObject outPMMLPort = new PMMLPortObject(creator.createSpec(), inPMMLPort, inSpec);
outPMMLPort.addGlobalTransformations(trans.exportToTransDict());
return new PortObject[] { resultTable, outPMMLPort };
}
use of org.knime.base.node.preproc.pmml.PMMLStringConversionTranslator in project knime-core by knime.
the class NumberToStringNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inObjects, final ExecutionContext exec) throws Exception {
StringBuilder warnings = new StringBuilder();
BufferedDataTable inData = (BufferedDataTable) inObjects[0];
DataTableSpec inSpec = inData.getDataTableSpec();
// find indices to work on.
List<String> inclcols = m_inclCols.getIncludeList();
BufferedDataTable resultTable = null;
if (inclcols.size() == 0) {
// nothing to convert, let's return the input table.
resultTable = inData;
setWarningMessage("No columns selected," + " returning input DataTable.");
} else {
int[] indices = findColumnIndices(inData.getSpec());
ConverterFactory converterFac = new ConverterFactory(indices, inSpec);
ColumnRearranger colre = new ColumnRearranger(inSpec);
colre.replace(converterFac, indices);
resultTable = exec.createColumnRearrangeTable(inData, colre, exec);
String errorMessage = converterFac.getErrorMessage();
if (errorMessage.length() > 0) {
warnings.append("Problems occurred, see Console messages.\n");
}
if (warnings.length() > 0) {
getLogger().warn(errorMessage);
setWarningMessage(warnings.toString());
}
}
// the optional PMML in port (can be null)
PMMLPortObject inPMMLPort = m_pmmlInEnabled ? (PMMLPortObject) inObjects[1] : null;
PMMLStringConversionTranslator trans = new PMMLStringConversionTranslator(m_inclCols.getIncludeList(), StringCell.TYPE, new DerivedFieldMapper(inPMMLPort));
PMMLPortObjectSpecCreator creator = new PMMLPortObjectSpecCreator(inPMMLPort, inSpec);
PMMLPortObject outPMMLPort = new PMMLPortObject(creator.createSpec(), inPMMLPort, inSpec);
outPMMLPort.addGlobalTransformations(trans.exportToTransDict());
return new PortObject[] { resultTable, outPMMLPort };
}
Aggregations