use of com.google.refine.browsing.util.ExpressionNominalValueGrouper in project OpenRefine by OpenRefine.
the class FacetCount method call.
@Override
public Object call(Properties bindings, Object[] args) {
if (args.length == 3 && args[1] instanceof String && args[2] instanceof String) {
// choice value to look up
Object choiceValue = args[0];
String facetExpression = (String) args[1];
String columnName = (String) args[2];
Project project = (Project) bindings.get("project");
Column column = project.columnModel.getColumnByName(columnName);
if (column == null) {
return new EvalError("No such column named " + columnName);
}
String key = "nominal-bin:" + facetExpression;
ExpressionNominalValueGrouper grouper = (ExpressionNominalValueGrouper) column.getPrecompute(key);
if (grouper == null) {
try {
Evaluable eval = MetaParser.parse(facetExpression);
Engine engine = new Engine(project);
grouper = new ExpressionNominalValueGrouper(eval, columnName, column.getCellIndex());
engine.getAllRows().accept(project, grouper);
column.setPrecompute(key, grouper);
} catch (ParsingException e) {
return new EvalError("Error parsing facet expression " + facetExpression);
}
}
return grouper.getChoiceValueCountMultiple(choiceValue);
}
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects a choice value, an expression as a string, and a column name");
}
use of com.google.refine.browsing.util.ExpressionNominalValueGrouper in project OpenRefine by OpenRefine.
the class ListFacet method computeChoices.
@Override
public void computeChoices(Project project, FilteredRows filteredRows) {
if (_eval != null && _errorMessage == null) {
ExpressionNominalValueGrouper grouper = new ExpressionNominalValueGrouper(_eval, _columnName, _cellIndex);
filteredRows.accept(project, grouper);
postProcessGrouper(grouper);
}
}
use of com.google.refine.browsing.util.ExpressionNominalValueGrouper in project OpenRefine by OpenRefine.
the class ListFacet method computeChoices.
@Override
public void computeChoices(Project project, FilteredRecords filteredRecords) {
if (_eval != null && _errorMessage == null) {
ExpressionNominalValueGrouper grouper = new ExpressionNominalValueGrouper(_eval, _columnName, _cellIndex);
filteredRecords.accept(project, grouper);
postProcessGrouper(grouper);
}
}
Aggregations