Package com.google.refine.model

Examples of com.google.refine.model.Cell


           
            int end;
            for (end = from; end < limit && ids.size() < 10; end++) {
                int index = rowIndices.get(end);
                Row row = _project.rows.get(index);
                Cell cell = row.getCell(_cellIndex);
               
                ids.add(cell.recon.match.id);
            }
           
            Map<String, DataExtension> map = null;
            try {
                map = _job.extend(ids, reconCandidateMap);
            } catch (Exception e) {
                map = new HashMap<String, DataExtension>();
            }
           
            for (int i = from; i < end; i++) {
                int index = rowIndices.get(i);
                Row row = _project.rows.get(index);
                Cell cell = row.getCell(_cellIndex);
                String guid = cell.recon.match.id;
               
                if (map.containsKey(guid)) {
                    dataExtensions.add(map.get(guid));
                } else {
View Full Code Here


        Map<String, Recon> reconMap
    ) {
        Object[] values = dataExtension.data[extensionRowIndex];
        for (int c = 0; c < values.length; c++) {
            Object value = values[c];
            Cell cell = null;
           
            if (value instanceof ReconCandidate) {
                ReconCandidate rc = (ReconCandidate) value;
                Recon recon;
                if (reconMap.containsKey(rc.id)) {
                    recon = reconMap.get(rc.id);
                } else {
                    recon = Recon.makeFreebaseRecon(_historyEntryID);
                    recon.addCandidate(rc);
                    recon.service = "mql";
                    recon.match = rc;
                    recon.matchRank = 0;
                    recon.judgment = Judgment.Matched;
                    recon.judgmentAction = "auto";
                    recon.judgmentBatchSize = 1;
                   
                    reconMap.put(rc.id, recon);
                }
                cell = new Cell(rc.name, recon);
            } else {
                cell = new Cell((Serializable) value, null);
            }
           
            row.setCell(_firstNewCellIndex + c, cell);
        }
    }
View Full Code Here

       
        for (int r = 0; r < project.rows.size(); r++) {
            Row row = project.rows.get(r);
           
            for (int c = 0; c < row.cells.size(); c++) {
                Cell cell = row.cells.get(c);
                if (cell != null && cell.recon != null) {
                    Recon oldRecon = cell.recon;
                   
                    if (reconIDToResult.containsKey(oldRecon.id)) {
                        Recon newRecon = oldRecon.dup();
View Full Code Here

                // nothing to do
            }

            @Override
            public boolean visit(Project project, int rowIndex, Row row) {
                Cell cell = row.getCell(cellIndex);
                if (cell != null) {
                    long reconID = cell.recon != null ? cell.recon.id : 0;
                   
                    Recon newRecon;
                    if (dupReconMap.containsKey(reconID)) {
                        newRecon = dupReconMap.get(reconID);
                        newRecon.judgmentBatchSize++;
                    } else {
                        newRecon = cell.recon != null ?
                            cell.recon.dup(historyEntryID) :
                            new Recon(
                                historyEntryID,
                                identifierSpace,
                                schemaSpace);
                           
                        newRecon.match = match;
                        newRecon.matchRank = -1;
                        newRecon.judgment = Judgment.Matched;
                        newRecon.judgmentAction = "mass";
                        newRecon.judgmentBatchSize = 1;
                       
                        dupReconMap.put(reconID, newRecon);
                    }
                   
                    Cell newCell = new Cell(
                        cell.value,
                        newRecon
                    );
                   
                    CellChange cellChange = new CellChange(rowIndex, cellIndex, cell, newCell);
View Full Code Here

            }
           
            for (int r3 = r; r3 < r2; r3++) {
                Row newRow = project.rows.get(r3).dup();
                if (r3 == r) {
                    newRow.setCell(cellIndex, new Cell(sb.toString(), null));
                } else {
                    newRow.setCell(cellIndex, null);
                }
               
                if (!newRow.isEmpty()) {
View Full Code Here

                // nothing to do
            }
           
            @Override
            public boolean visit(Project project, int rowIndex, Row row) {
                Cell cell = row.getCell(_cellIndex);
                if (cell != null && ExpressionUtils.isNonBlankData(cell.value)) {
                    String value = cell.value instanceof String ?
                            ((String) cell.value) : cell.value.toString();
                           
                    if (_similarValue.equals(value)) {
                        Recon recon = null;
                        if (_judgment == Judgment.New && _shareNewTopics) {
                            if (_sharedNewRecon == null) {
                                _sharedNewRecon = new Recon(_historyEntryID, null, null);
                                _sharedNewRecon.judgment = Judgment.New;
                                _sharedNewRecon.judgmentBatchSize = 0;
                                _sharedNewRecon.judgmentAction = "similar";
                            }
                            _sharedNewRecon.judgmentBatchSize++;
                           
                            recon = _sharedNewRecon;
                        } else {
                            if (_dupReconMap.containsKey(cell.recon.id)) {
                                recon = _dupReconMap.get(cell.recon.id);
                                recon.judgmentBatchSize++;
                            } else {
                                recon = cell.recon.dup(_historyEntryID);
                                recon.judgmentBatchSize = 1;
                                recon.matchRank = -1;
                                recon.judgmentAction = "similar";
                               
                                if (_judgment == Judgment.Matched) {
                                    recon.judgment = Recon.Judgment.Matched;
                                    recon.match = _match;
                                   
                                    if (recon.candidates != null) {
                                        for (int m = 0; m < recon.candidates.size(); m++) {
                                            if (recon.candidates.get(m).id.equals(_match.id)) {
                                                recon.matchRank = m;
                                                break;
                                            }
                                        }
                                    }
                                } else if (_judgment == Judgment.New) {
                                    recon.judgment = Recon.Judgment.New;
                                    recon.match = null;
                                } else if (_judgment == Judgment.None) {
                                    recon.judgment = Recon.Judgment.None;
                                    recon.match = null;
                                }
                               
                                _dupReconMap.put(cell.recon.id, recon);
                            }
                        }
                       
                        Cell newCell = new Cell(cell.value, recon);
                       
                        CellChange cellChange = new CellChange(rowIndex, _cellIndex, cell, newCell);
                        _cellChanges.add(cellChange);
                    }
                }
View Full Code Here

                // nothing to do
            }

            @Override
            public boolean visit(Project project, int rowIndex, Row row) {
                Cell cell = row.getCell(cellIndex);
                Cell newCell = null;

                Object oldValue = cell != null ? cell.value : null;

                ExpressionUtils.bind(bindings, row, rowIndex, _columnName, cell);

                Object o = eval.evaluate(bindings);
                if (o == null) {
                    if (oldValue != null) {
                        CellChange cellChange = new CellChange(rowIndex, cellIndex, cell, null);
                        cellChanges.add(cellChange);
                    }
                } else {
                    if (o instanceof Cell) {
                        newCell = (Cell) o;
                    } else if (o instanceof WrappedCell) {
                        newCell = ((WrappedCell) o).cell;
                    } else {
                        Serializable newValue = ExpressionUtils.wrapStorable(o);
                        if (ExpressionUtils.isError(newValue)) {
                            if (_onError == OnError.KeepOriginal) {
                                return false;
                            } else if (_onError == OnError.SetToBlank) {
                                newValue = null;
                            }
                        }
                       
                        if (!ExpressionUtils.sameValue(oldValue, newValue)) {
                            newCell = new Cell(newValue, (cell != null) ? cell.recon : null);
                           
                            if (_repeat) {
                                for (int i = 0; i < _repeatCount; i++) {
                                    ExpressionUtils.bind(bindings, row, rowIndex, _columnName, newCell);
                                   
                                    newValue = ExpressionUtils.wrapStorable(eval.evaluate(bindings));
                                    if (ExpressionUtils.isError(newValue)) {
                                        break;
                                    } else if (ExpressionUtils.sameValue(newCell.value, newValue)) {
                                        break;
                                    }
                                   
                                    newCell = new Cell(newValue, newCell.recon);
                                }
                            }
                        }
                    }
                   
View Full Code Here

                Row newRow = r2 == 0 ? firstNewRow : new Row(newColumns.size());
                boolean hasData = r2 == 0;
               
                for (int c = 0; c < oldColumns.size(); c++) {
                    Column column = oldColumns.get(c);
                    Cell cell = oldRow.getCell(column.getCellIndex());
                   
                    if (cell != null && cell.value != null) {
                        if (c == columnIndex) {
                            firstNewRow.setCell(columnIndex + r2, cell);
                        } else if (c < columnIndex) {
View Full Code Here

            newRows.add(firstNewRow);
           
            int transposedCells = 0;
            for (int c = 0; c < oldColumns.size(); c++) {
                Column column = oldColumns.get(c);
                Cell cell = oldRow.getCell(column.getCellIndex());
               
                if (c < startColumnIndex) {
                    firstNewRow.setCell(c, cell);
                } else if (c == startColumnIndex || c < startColumnIndex + columnCount) {
                    if (_combinedColumnName != null) {
                        Cell newCell;
                        if (cell == null || cell.value == null) {
                            if (_prependColumnName && !_ignoreBlankCells) {
                                newCell = new Cell(column.getName() + _separator, null);
                            } else {
                                continue;
                            }
                        } else if (_prependColumnName) {
                            newCell = new Cell(column.getName() + _separator + cell.value, null);
                        } else {
                            newCell = cell;
                        }
                       
                        Row rowToModify;
                        if (transposedCells == 0) {
                            rowToModify = firstNewRow;
                        } else {
                            rowToModify = new Row(newColumns.size());
                            newRows.add(rowToModify);
                        }
                        rowToModify.setCell(startColumnIndex, newCell);
                       
                        transposedCells++;
                    } else {
                        if (_ignoreBlankCells && (cell == null || cell.value == null)) {
                            continue;
                        }
                       
                        Row rowToModify;
                        if (transposedCells == 0) {
                            rowToModify = firstNewRow;
                        } else {
                            rowToModify = new Row(newColumns.size());
                            newRows.add(rowToModify);
                        }
                        rowToModify.setCell(startColumnIndex, new Cell(column.getName(), null));
                        rowToModify.setCell(startColumnIndex + 1, cell);
                       
                        transposedCells++;
                    }
                   
                } else {
                    firstNewRow.setCell(
                        c - columnCount + (_combinedColumnName != null ? 1 : 2),
                        cell);
                }
            }
           
            if (_fillDown) {
                for (int r2 = firstNewRowIndex + 1; r2 < newRows.size(); r2++) {
                    Row newRow = newRows.get(r2);
                    for (int c = 0; c < newColumns.size(); c++) {
                        if (c < startColumnIndex ||
                            (_combinedColumnName != null ?
                                c > startColumnIndex :
                                c > startColumnIndex + 1)) {
                            Column column = newColumns.get(c);
                            int cellIndex = column.getCellIndex();
                           
                            Cell cellToCopy = firstNewRow.getCell(cellIndex);
                            if (cellToCopy != null && newRow.getCell(cellIndex) == null) {
                                newRow.setCell(cellIndex, cellToCopy);
                            }
                        }
                    }
View Full Code Here

            // nothing to do
        }
       
        @Override
        public boolean visit(Project project, int rowIndex, Row row) {
            Cell cell = row.getCell(_colindex);
            if (cell != null && cell.value != null) {
                Object v = cell.value;
                String s = (v instanceof String) ? ((String) v) : v.toString();
                _clusterer.populate(s);
                count(s);
View Full Code Here

TOP

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

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.