Package com.google.refine.model

Examples of com.google.refine.model.Column


                        columnGroup.keyColumnIndex + 1
                    ));
                }
            }
           
            Column column = new Column(_newCellIndex, _columnName);
            project.columnModel.columns.add(_columnIndex, column);
            try {
                for (CellAtRow cell : _newCells) {
                    project.rows.get(cell.row).setCell(_newCellIndex, cell.cell);
                }
View Full Code Here


        } else if (index >= currentFileColumnNames.size()) {
            String prefix = "Column ";
            int i = index + 1;
            while (true) {
                String columnName = prefix + i;
                Column column = project.columnModel.getColumnByName(columnName);
                if (column != null) {
                    if (hasOurOwnColumnNames) {
                        // Already taken name
                        i++;
                    } else {
                        return column;
                    }
                } else {
                    column = new Column(project.columnModel.allocateNewCellIndex(), columnName);
                    try {
                        project.columnModel.addColumn(project.columnModel.columns.size(), column, false);
                    } catch (ModelException e) {
                        // Ignore: shouldn't get in here since we just checked for duplicate names.
                    }
View Full Code Here

                nameToIndex.put(cell, 2);
            }
           
            columnNames.set(c, cell);
            if (project.columnModel.getColumnByName(cell) == null) {
                Column column = new Column(project.columnModel.allocateNewCellIndex(), cell);
                try {
                    project.columnModel.addColumn(project.columnModel.columns.size(), column, false);
                } catch (ModelException e) {
                    // Ignore: shouldn't get in here since we just checked for duplicate names.
                }
View Full Code Here

            Cell cell = _project.rows.get(rowIndex).getCell(cellIndex);
            if (cell == null || !ExpressionUtils.isNonBlankData(cell.value)) {
                throw new Exception("Cell is blank or error");
            }

            Column column = _project.columnModel.getColumnByCellIndex(cellIndex);
            if (column == null) {
                throw new Exception("No such column");
            }

            Judgment oldJudgment = cell.recon == null ? Judgment.None : cell.recon.judgment;

            newCell = new Cell(
                cell.value,
                cell.recon == null ? new Recon(historyEntryID, identifierSpace, schemaSpace) : cell.recon.dup(historyEntryID)
            );

            String cellDescription =
                "single cell on row " + (rowIndex + 1) +
                ", column " + column.getName() +
                ", containing \"" + cell.value + "\"";

            String description = null;

            newCell.recon.matchRank = -1;
            newCell.recon.judgmentAction = "single";
            newCell.recon.judgmentBatchSize = 1;

            if (judgment == Judgment.None) {
                newCell.recon.judgment = Recon.Judgment.None;
                newCell.recon.match = null;

                description = "Discard recon judgment for " + cellDescription;
            } else if (judgment == Judgment.New) {
                newCell.recon.judgment = Recon.Judgment.New;
                newCell.recon.match = null;

                description = "Mark to create new topic for " + cellDescription;
            } else {
                newCell.recon.judgment = Recon.Judgment.Matched;
                newCell.recon.match = this.match;
                if (newCell.recon.candidates != null) {
                    for (int m = 0; m < newCell.recon.candidates.size(); m++) {
                        if (newCell.recon.candidates.get(m).id.equals(this.match.id)) {
                            newCell.recon.matchRank = m;
                            break;
                        }
                    }
                }
               
                description = "Match " + this.match.name +
                    " (" + match.id + ") to " +
                    cellDescription;
            }

            ReconStats stats = column.getReconStats();
            if (stats == null) {
                stats = ReconStats.create(_project, cellIndex);
            } else {
                int newChange = 0;
                int matchChange = 0;

                if (oldJudgment == Judgment.New) {
                    newChange--;
                }
                if (oldJudgment == Judgment.Matched) {
                    matchChange--;
                }
                if (newCell.recon.judgment == Judgment.New) {
                    newChange++;
                }
                if (newCell.recon.judgment == Judgment.Matched) {
                    matchChange++;
                }

                stats = new ReconStats(
                    stats.nonBlanks,
                    stats.newTopics + newChange,
                    stats.matchedTopics + matchChange);
            }

            Change change = new ReconChange(
                new CellChange(rowIndex, cellIndex, cell, newCell),
                column.getName(),
                column.getReconConfig(),
                stats
            );

            return new HistoryEntry(
                historyEntryID, _project, description, null, change);
View Full Code Here

        _expression = o.getString("expression");
        _columnName = o.getString("columnName");
        _invert = o.has("invert") && o.getBoolean("invert");
       
        if (_columnName.length() > 0) {
            Column column = project.columnModel.getColumnByName(_columnName);
            if (column != null) {
                _cellIndex = column.getCellIndex();
            } else {
                _errorMessage = "No column named " + _columnName;
            }
        } else {
            _cellIndex = -1;
View Full Code Here

            Cell cell = _project.rows.get(rowIndex).getCell(cellIndex);
            if (cell == null || !ExpressionUtils.isNonBlankData(cell.value)) {
                throw new Exception("Cell is blank or error");
            }

            Column column = _project.columnModel.getColumnByCellIndex(cellIndex);
            if (column == null) {
                throw new Exception("No such column");
            }

            Judgment oldJudgment = cell.recon == null ? Judgment.None : cell.recon.judgment;

            newCell = new Cell(cell.value, null);

            ReconStats stats = column.getReconStats();
            if (stats == null) {
                stats = ReconStats.create(_project, cellIndex);
            } else {
                int newChange = 0;
                int matchChange = 0;

                if (oldJudgment == Judgment.New) {
                    newChange--;
                }
                if (oldJudgment == Judgment.Matched) {
                    matchChange--;
                }

                stats = new ReconStats(
                    stats.nonBlanks + 1,
                    stats.newTopics + newChange,
                    stats.matchedTopics + matchChange);
            }

            String description =
                "Clear recon data for single cell on row " + (rowIndex + 1) +
                ", column " + column.getName() +
                ", containing \"" + cell.value + "\"";

            Change change = new ReconChange(
                new CellChange(rowIndex, cellIndex, cell, newCell),
                column.getName(),
                column.getReconConfig(),
                stats
            );

            return new HistoryEntry(
                historyEntryID, _project, description, null, change);
View Full Code Here

        }
       
        ClosableIterable<Triple> triples = graph.find(ANY_SUBJECT_NODE, ANY_PREDICATE_NODE, ANY_OBJECT_NODE);
        try {
            Map<String, List<Row>> subjectToRows = new HashMap<String, List<Row>>();
            Column subjectColumn = new Column(project.columnModel.allocateNewCellIndex(), "subject");
            project.columnModel.addColumn(0, subjectColumn, false);
            project.columnModel.setKeyColumnIndex(0);
           
            for (Triple triple : triples) {
                String subject = triple.getSubject().toString();
                String predicate = triple.getPredicate().toString();
                String object = triple.getObject().toString();

                Column column = project.columnModel.getColumnByName(predicate);
                if (column == null) {
                    column = new Column(project.columnModel.allocateNewCellIndex(), predicate);
                    project.columnModel.addColumn(-1, column, true);
                }

                int cellIndex = column.getCellIndex();
                if (subjectToRows.containsKey(subject)) {
                    List<Row> rows = subjectToRows.get(subject);
                    for (Row row : rows) {
                        if (!ExpressionUtils.isNonBlankData(row.getCellValue(cellIndex))) {
                            row.setCell(cellIndex, new Cell(object, null));
View Full Code Here

       
        columnName_x = o.getString(X_COLUMN_NAME);
        expression_x = o.getString(X_EXPRESSION);
       
        if (columnName_x.length() > 0) {
            Column x_column = project.columnModel.getColumnByName(columnName_x);
            if (x_column != null) {
                columnIndex_x = x_column.getCellIndex();
               
                NumericBinIndex index_x = ScatterplotFacet.getBinIndex(project, x_column, eval_x, expression_x);
                min_x = index_x.getMin();
                max_x = index_x.getMax();
            } else {
                errorMessage_x = "No column named " + columnName_x;
            }
        } else {
            columnIndex_x = -1;
        }
       
        try {
            eval_x = MetaParser.parse(expression_x);
        } catch (ParsingException e) {
            errorMessage_x = e.getMessage();
        }
       
        columnName_y = o.getString(Y_COLUMN_NAME);
        expression_y = o.getString(Y_EXPRESSION);
       
        if (columnName_y.length() > 0) {
            Column y_column = project.columnModel.getColumnByName(columnName_y);
            if (y_column != null) {
                columnIndex_y = y_column.getCellIndex();
               
                NumericBinIndex index_y = ScatterplotFacet.getBinIndex(project, y_column, eval_y, expression_y);
                min_y = index_y.getMin();
                max_y = index_y.getMax();
            } else {
View Full Code Here

            _record = record;
        }
       
        @Override
        public Object getField(String name, Properties bindings) {
            Column column = project.columnModel.getColumnByName(name);
            if (column != null) {
                int cellIndex = column.getCellIndex();
               
                HasFieldsListImpl cells = new HasFieldsListImpl();
                for (int r = _record.fromRowIndex; r < _record.toRowIndex; r++) {
                    Row row = project.rows.get(r);
                    Cell cell = row.getCell(cellIndex);
View Full Code Here

    }

    @Override
    public void computeChoices(Project project, FilteredRows filteredRows) {
        if (eval_x != null && eval_y != null && errorMessage_x == null && errorMessage_y == null) {
            Column column_x = project.columnModel.getColumnByCellIndex(columnIndex_x);
            NumericBinIndex index_x = getBinIndex(project, column_x, eval_x, expression_x, "row-based");
           
            Column column_y = project.columnModel.getColumnByCellIndex(columnIndex_y);
            NumericBinIndex index_y = getBinIndex(project, column_y, eval_y, expression_y, "row-based");

            retrieveDataFromBinIndices(index_x, index_y);
           
            if (IMAGE_URI) {
View Full Code Here

TOP

Related Classes of com.google.refine.model.Column

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.