diff --git a/src/main/java/com/metaweb/gridworks/ProjectMetadata.java b/src/main/java/com/metaweb/gridworks/ProjectMetadata.java index 3367b0bbd..e444032db 100644 --- a/src/main/java/com/metaweb/gridworks/ProjectMetadata.java +++ b/src/main/java/com/metaweb/gridworks/ProjectMetadata.java @@ -11,11 +11,39 @@ import org.json.JSONWriter; public class ProjectMetadata implements Serializable, Jsonizable { private static final long serialVersionUID = 7959027046468240844L; - public String name; - public String password; - public Date created = new Date(); - public Date modified = new Date(); + private final Date _created = new Date(); + private String _name; + private String _password; + private Date _modified = new Date(); + public Date getCreated() { + return _created; + } + + public void setName(String name) { + this._name = name; + } + + public String getName() { + return _name; + } + + public void setPassword(String password) { + this._password = password; + } + + public String getPassword() { + return _password; + } + + public Date getModified() { + return _modified; + } + + public void updateModified() { + _modified = new Date(); + } + @Override public void write(JSONWriter writer, Properties options) throws JSONException { @@ -23,9 +51,9 @@ public class ProjectMetadata implements Serializable, Jsonizable { SimpleDateFormat sdf = (SimpleDateFormat) SimpleDateFormat.getDateTimeInstance(); writer.object(); - writer.key("name"); writer.value(name); - writer.key("created"); writer.value(sdf.format(created)); - writer.key("modified"); writer.value(sdf.format(modified)); + writer.key("name"); writer.value(getName()); + writer.key("created"); writer.value(sdf.format(getCreated())); + writer.key("modified"); writer.value(sdf.format(_modified)); writer.endObject(); } } diff --git a/src/main/java/com/metaweb/gridworks/browsing/facets/NumericBinIndex.java b/src/main/java/com/metaweb/gridworks/browsing/facets/NumericBinIndex.java index 0c4d92d4b..b435d2ef9 100644 --- a/src/main/java/com/metaweb/gridworks/browsing/facets/NumericBinIndex.java +++ b/src/main/java/com/metaweb/gridworks/browsing/facets/NumericBinIndex.java @@ -10,16 +10,16 @@ import com.metaweb.gridworks.model.Project; import com.metaweb.gridworks.model.Row; public class NumericBinIndex { - public double min; - public double max; - public double step; - public int[] bins; + private double _min; + private double _max; + private double _step; + private int[] _bins; public NumericBinIndex(Project project, int cellIndex, Evaluable eval) { Properties bindings = new Properties(); - min = Double.POSITIVE_INFINITY; - max = Double.NEGATIVE_INFINITY; + _min = Double.POSITIVE_INFINITY; + _max = Double.NEGATIVE_INFINITY; List allValues = new ArrayList(); for (int i = 0; i < project.rows.size(); i++) { @@ -49,40 +49,55 @@ public class NumericBinIndex { } } - if (min >= max) { - step = 0; - bins = new int[0]; + if (getMin() >= getMax()) { + _step = 0; + _bins = new int[0]; return; } - double diff = max - min; + double diff = getMax() - getMin(); + _step = 1; if (diff > 10) { - step = 1; - while (step * 100 < diff) { - step *= 10; + while (getStep() * 100 < diff) { + _step *= 10; } } else { - step = 1; - while (step * 100 > diff) { - step /= 10; + while (getStep() * 100 > diff) { + _step /= 10; } } - min = Math.floor(min / step) * step; - max = Math.ceil(max / step) * step; + _min = (Math.floor(_min / _step) * _step); + _max = (Math.ceil(_max / _step) * _step); - int binCount = 1 + (int) Math.ceil((max - min) / step); + int binCount = 1 + (int) Math.ceil((getMax() - getMin()) / getStep()); - bins = new int[binCount]; + _bins = new int[binCount]; for (double d : allValues) { - int bin = (int) Math.round((d - min) / step); - bins[bin]++; + int bin = (int) Math.round((d - getMin()) / getStep()); + getBins()[bin]++; } } + public double getMin() { + return _min; + } + + public double getMax() { + return _max; + } + + public double getStep() { + return _step; + } + + public int[] getBins() { + return _bins; + } + protected void processValue(double v, List allValues) { - min = Math.min(min, v); - max = Math.max(max, v); + _min = Math.min(getMin(), v); + _max = Math.max(getMax(), v); allValues.add(v); } } diff --git a/src/main/java/com/metaweb/gridworks/browsing/facets/RangeFacet.java b/src/main/java/com/metaweb/gridworks/browsing/facets/RangeFacet.java index 0c8740086..d7c0c168c 100644 --- a/src/main/java/com/metaweb/gridworks/browsing/facets/RangeFacet.java +++ b/src/main/java/com/metaweb/gridworks/browsing/facets/RangeFacet.java @@ -115,9 +115,9 @@ public class RangeFacet implements Facet { column.setPrecompute(key, index); } - _min = index.min; - _max = index.max; - _step = index.step; - _bins = index.bins; + _min = index.getMin(); + _max = index.getMax(); + _step = index.getStep(); + _bins = index.getBins(); } } diff --git a/src/main/java/com/metaweb/gridworks/browsing/facets/TextSearchFacet.java b/src/main/java/com/metaweb/gridworks/browsing/facets/TextSearchFacet.java index a90d3dd5c..5f1f0dba6 100644 --- a/src/main/java/com/metaweb/gridworks/browsing/facets/TextSearchFacet.java +++ b/src/main/java/com/metaweb/gridworks/browsing/facets/TextSearchFacet.java @@ -7,11 +7,9 @@ import org.json.JSONObject; import org.json.JSONWriter; import com.metaweb.gridworks.browsing.FilteredRows; -import com.metaweb.gridworks.browsing.filters.ExpressionNumberComparisonRowFilter; import com.metaweb.gridworks.browsing.filters.ExpressionStringComparisonRowFilter; import com.metaweb.gridworks.browsing.filters.RowFilter; import com.metaweb.gridworks.expr.Evaluable; -import com.metaweb.gridworks.expr.Parser; import com.metaweb.gridworks.expr.VariableExpr; import com.metaweb.gridworks.model.Project; diff --git a/src/main/java/com/metaweb/gridworks/commands/ApproveNewReconcileCommand.java b/src/main/java/com/metaweb/gridworks/commands/ApproveNewReconcileCommand.java index 988290180..591275f19 100644 --- a/src/main/java/com/metaweb/gridworks/commands/ApproveNewReconcileCommand.java +++ b/src/main/java/com/metaweb/gridworks/commands/ApproveNewReconcileCommand.java @@ -39,7 +39,7 @@ public class ApproveNewReconcileCommand extends Command { return; } - String columnName = column.headerLabel; + String columnName = column.getHeaderLabel(); List cellChanges = new ArrayList(project.rows.size()); FilteredRows filteredRows = engine.getAllFilteredRows(); @@ -58,9 +58,10 @@ public class ApproveNewReconcileCommand extends Command { if (cellIndex < row.cells.size()) { Cell cell = row.cells.get(cellIndex); - Cell newCell = new Cell(); - newCell.value = cell.value; - newCell.recon = cell.recon != null ? cell.recon.dup() : new Recon(); + Cell newCell = new Cell( + cell.value, + cell.recon != null ? cell.recon.dup() : new Recon() + ); newCell.recon.match = null; newCell.recon.judgment = Judgment.New; diff --git a/src/main/java/com/metaweb/gridworks/commands/ApproveReconcileCommand.java b/src/main/java/com/metaweb/gridworks/commands/ApproveReconcileCommand.java index 9db795823..8f813182f 100644 --- a/src/main/java/com/metaweb/gridworks/commands/ApproveReconcileCommand.java +++ b/src/main/java/com/metaweb/gridworks/commands/ApproveReconcileCommand.java @@ -38,7 +38,7 @@ public class ApproveReconcileCommand extends Command { return; } - String columnName = column.headerLabel; + String columnName = column.getHeaderLabel(); List cellChanges = new ArrayList(project.rows.size()); FilteredRows filteredRows = engine.getAllFilteredRows(); @@ -57,9 +57,10 @@ public class ApproveReconcileCommand extends Command { if (cellIndex < row.cells.size()) { Cell cell = row.cells.get(cellIndex); if (cell.recon != null && cell.recon.candidates.size() > 0) { - Cell newCell = new Cell(); - newCell.value = cell.value; - newCell.recon = cell.recon.dup(); + Cell newCell = new Cell( + cell.value, + cell.recon.dup() + ); newCell.recon.match = newCell.recon.candidates.get(0); newCell.recon.judgment = Judgment.Approve; diff --git a/src/main/java/com/metaweb/gridworks/commands/CreateProjectFromUploadCommand.java b/src/main/java/com/metaweb/gridworks/commands/CreateProjectFromUploadCommand.java index b1fe2c149..4de1bf792 100644 --- a/src/main/java/com/metaweb/gridworks/commands/CreateProjectFromUploadCommand.java +++ b/src/main/java/com/metaweb/gridworks/commands/CreateProjectFromUploadCommand.java @@ -23,8 +23,8 @@ public class CreateProjectFromUploadCommand extends Command { String content = readFileUpload(request, properties); ProjectMetadata pm = new ProjectMetadata(); - pm.name = properties.getProperty("project-name"); - pm.password = properties.getProperty("project-password"); + pm.setName(properties.getProperty("project-name")); + pm.setPassword(properties.getProperty("project-password")); Project project = ProjectManager.singleton.createProject(pm); @@ -63,9 +63,7 @@ public class CreateProjectFromUploadCommand extends Command { cell = cell.substring(1, cell.length() - 1); } - Column column = new Column(); - column.cellIndex = c; - column.headerLabel = cell; + Column column = new Column(c, cell); project.columnModel.columns.add(column); } @@ -76,8 +74,7 @@ public class CreateProjectFromUploadCommand extends Command { if ((sep.charAt(0) == ',') ? parseCSVIntoRow(row, line) : parseTSVIntoRow(row, line)) { project.rows.add(row); - project.columnModel.maxCellIndex = - Math.max(project.columnModel.maxCellIndex, row.cells.size()); + project.columnModel.setMaxCellIndex(Math.max(project.columnModel.getMaxCellIndex(), row.cells.size())); } } } @@ -94,8 +91,7 @@ public class CreateProjectFromUploadCommand extends Command { for (int c = 0; c < cells.length; c++) { String text = cells[c]; - Cell cell = new Cell(); - cell.value = parseCellValue(text); + Cell cell = new Cell(parseCellValue(text), null); row.cells.add(cell); @@ -133,8 +129,7 @@ public class CreateProjectFromUploadCommand extends Command { } } - Cell cell = new Cell(); - cell.value = parseCellValue(text); + Cell cell = new Cell(parseCellValue(text), null); row.cells.add(cell); diff --git a/src/main/java/com/metaweb/gridworks/commands/DiscardReconcileCommand.java b/src/main/java/com/metaweb/gridworks/commands/DiscardReconcileCommand.java index 7e235dc6a..31bce610c 100644 --- a/src/main/java/com/metaweb/gridworks/commands/DiscardReconcileCommand.java +++ b/src/main/java/com/metaweb/gridworks/commands/DiscardReconcileCommand.java @@ -37,7 +37,7 @@ public class DiscardReconcileCommand extends Command { return; } - String columnName = column.headerLabel; + String columnName = column.getHeaderLabel(); List cellChanges = new ArrayList(project.rows.size()); FilteredRows filteredRows = engine.getAllFilteredRows(); @@ -56,9 +56,7 @@ public class DiscardReconcileCommand extends Command { if (cellIndex < row.cells.size()) { Cell cell = row.cells.get(cellIndex); - Cell newCell = new Cell(); - newCell.value = cell.value; - newCell.recon = null; + Cell newCell = new Cell(cell.value, null); CellChange cellChange = new CellChange(rowIndex, cellIndex, cell, newCell); cellChanges.add(cellChange); diff --git a/src/main/java/com/metaweb/gridworks/commands/DoTextTransformCommand.java b/src/main/java/com/metaweb/gridworks/commands/DoTextTransformCommand.java index 91e3179c0..0f95c6286 100644 --- a/src/main/java/com/metaweb/gridworks/commands/DoTextTransformCommand.java +++ b/src/main/java/com/metaweb/gridworks/commands/DoTextTransformCommand.java @@ -41,7 +41,7 @@ public class DoTextTransformCommand extends Command { return; } - String columnName = column.headerLabel; + String columnName = column.getHeaderLabel(); String expression = request.getParameter("expression"); Evaluable eval = new Parser(expression).getExpression(); @@ -73,9 +73,7 @@ public class DoTextTransformCommand extends Command { bindings.put("cell", cell); bindings.put("value", cell.value); - Cell newCell = new Cell(); - newCell.value = eval.evaluate(bindings); - newCell.recon = cell.recon; + Cell newCell = new Cell(eval.evaluate(bindings), cell.recon); CellChange cellChange = new CellChange(rowIndex, cellIndex, cell, newCell); cellChanges.add(cellChange); diff --git a/src/main/java/com/metaweb/gridworks/commands/ReconcileCommand.java b/src/main/java/com/metaweb/gridworks/commands/ReconcileCommand.java index 48d2118dd..55f93a04f 100644 --- a/src/main/java/com/metaweb/gridworks/commands/ReconcileCommand.java +++ b/src/main/java/com/metaweb/gridworks/commands/ReconcileCommand.java @@ -35,7 +35,7 @@ public class ReconcileCommand extends Command { return; } - String columnName = column.headerLabel; + String columnName = column.getHeaderLabel(); String typeID = request.getParameter("type"); List entries = new ArrayList(project.rows.size()); diff --git a/src/main/java/com/metaweb/gridworks/history/History.java b/src/main/java/com/metaweb/gridworks/history/History.java index 3ca2ddb8c..4c6b6f46c 100644 --- a/src/main/java/com/metaweb/gridworks/history/History.java +++ b/src/main/java/com/metaweb/gridworks/history/History.java @@ -2,7 +2,6 @@ package com.metaweb.gridworks.history; import java.io.Serializable; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.Properties; @@ -39,7 +38,7 @@ public class History implements Serializable, Jsonizable { } protected void setModified() { - ProjectManager.singleton.getProjectMetadata(_projectID).modified = new Date(); + ProjectManager.singleton.getProjectMetadata(_projectID).updateModified(); } public List getLastPastEntries(int count) { diff --git a/src/main/java/com/metaweb/gridworks/history/HistoryProcess.java b/src/main/java/com/metaweb/gridworks/history/HistoryProcess.java index c94c5990c..b0b36bb22 100644 --- a/src/main/java/com/metaweb/gridworks/history/HistoryProcess.java +++ b/src/main/java/com/metaweb/gridworks/history/HistoryProcess.java @@ -13,7 +13,8 @@ public class HistoryProcess extends Process { final protected Project _project; final protected long _lastDoneID; final protected String _description; - boolean _done = false; + + protected boolean _done = false; public HistoryProcess(Project project, long lastDoneID) { _project = project; diff --git a/src/main/java/com/metaweb/gridworks/model/Cell.java b/src/main/java/com/metaweb/gridworks/model/Cell.java index ce818075c..dfd51bea3 100644 --- a/src/main/java/com/metaweb/gridworks/model/Cell.java +++ b/src/main/java/com/metaweb/gridworks/model/Cell.java @@ -12,8 +12,13 @@ import com.metaweb.gridworks.expr.HasFields; public class Cell implements Serializable, HasFields, Jsonizable { private static final long serialVersionUID = -5891067829205458102L; - public Object value; - public Recon recon; + final public Object value; + final public Recon recon; + + public Cell(Object value, Recon recon) { + this.value = value; + this.recon = recon; + } @Override public Object getField(String name, Properties bindings) { diff --git a/src/main/java/com/metaweb/gridworks/model/Column.java b/src/main/java/com/metaweb/gridworks/model/Column.java index 9e2e23be8..1029eadf6 100644 --- a/src/main/java/com/metaweb/gridworks/model/Column.java +++ b/src/main/java/com/metaweb/gridworks/model/Column.java @@ -13,20 +13,40 @@ import com.metaweb.gridworks.Jsonizable; public class Column implements Serializable, Jsonizable { private static final long serialVersionUID = -1063342490951563563L; - public int cellIndex; - public String headerLabel; - public Class valueType; + final private int _cellIndex; + final private String _originalHeaderLabel; + private String _headerLabel; transient protected Map _precomputes; + public Column(int cellIndex, String headerLabel) { + _cellIndex = cellIndex; + _originalHeaderLabel = _headerLabel = headerLabel; + } + + public int getCellIndex() { + return _cellIndex; + } + + public String getOriginalHeaderLabel() { + return _originalHeaderLabel; + } + + public void setHeaderLabel(String headerLabel) { + this._headerLabel = headerLabel; + } + + public String getHeaderLabel() { + return _headerLabel; + } + @Override public void write(JSONWriter writer, Properties options) throws JSONException { writer.object(); - writer.key("cellIndex"); writer.value(cellIndex); - writer.key("headerLabel"); writer.value(headerLabel); - writer.key("valueType"); writer.value(valueType == null ? null : valueType.getSimpleName()); + writer.key("cellIndex"); writer.value(getCellIndex()); + writer.key("headerLabel"); writer.value(getHeaderLabel()); writer.endObject(); } diff --git a/src/main/java/com/metaweb/gridworks/model/ColumnGroup.java b/src/main/java/com/metaweb/gridworks/model/ColumnGroup.java index 656729250..88e8021f9 100644 --- a/src/main/java/com/metaweb/gridworks/model/ColumnGroup.java +++ b/src/main/java/com/metaweb/gridworks/model/ColumnGroup.java @@ -15,13 +15,15 @@ import com.metaweb.gridworks.Jsonizable; public class ColumnGroup implements Serializable, Jsonizable { private static final long serialVersionUID = 2161780779920066118L; - public int[] cellIndices; // must be in order from smallest to largest - public int keyCellIndex; // could be -1 if there is no key cell + final public int[] cellIndices; // must be in order from smallest to largest + final public int keyCellIndex; // could be -1 if there is no key cell transient public ColumnGroup parentGroup; transient public List subgroups; - public ColumnGroup() { + public ColumnGroup(int[] cellIndices, int keyCellIndex) { + this.cellIndices = cellIndices; + this.keyCellIndex = keyCellIndex; internalInitialize(); } diff --git a/src/main/java/com/metaweb/gridworks/model/ColumnModel.java b/src/main/java/com/metaweb/gridworks/model/ColumnModel.java index 9a5360a90..efca98000 100644 --- a/src/main/java/com/metaweb/gridworks/model/ColumnModel.java +++ b/src/main/java/com/metaweb/gridworks/model/ColumnModel.java @@ -19,11 +19,11 @@ import com.metaweb.gridworks.Jsonizable; public class ColumnModel implements Serializable, Jsonizable { private static final long serialVersionUID = 7679639795211544511L; - public List columns = new LinkedList(); - public int maxCellIndex; + final public List columns = new LinkedList(); + final public List columnGroups = new LinkedList(); - public List columnGroups = new LinkedList(); - public int keyCellIndex; + private int _maxCellIndex; + private int _keyCellIndex; transient protected Map _nameToColumn; transient protected Map _cellIndexToColumn; @@ -33,6 +33,23 @@ public class ColumnModel implements Serializable, Jsonizable { internalInitialize(); } + public void setMaxCellIndex(int maxCellIndex) { + this._maxCellIndex = Math.max(this._maxCellIndex, maxCellIndex); + } + + public int getMaxCellIndex() { + return _maxCellIndex; + } + + public void setKeyCellIndex(int keyCellIndex) { + // TODO: check validity of new cell index, e.g., it's not in any group + this._keyCellIndex = keyCellIndex; + } + + public int getKeyCellIndex() { + return _keyCellIndex; + } + public void update() { generateMaps(); } @@ -58,7 +75,7 @@ public class ColumnModel implements Serializable, Jsonizable { } writer.endArray(); - writer.key("keyCellIndex"); writer.value(keyCellIndex); + writer.key("keyCellIndex"); writer.value(getKeyCellIndex()); writer.key("columnGroups"); writer.array(); for (ColumnGroup g : _rootColumnGroups) { @@ -114,8 +131,8 @@ public class ColumnModel implements Serializable, Jsonizable { _cellIndexToColumn = new HashMap(); for (Column column : columns) { - _nameToColumn.put(column.headerLabel, column); - _cellIndexToColumn.put(column.cellIndex, column); + _nameToColumn.put(column.getHeaderLabel(), column); + _cellIndexToColumn.put(column.getCellIndex(), column); } } } diff --git a/src/main/java/com/metaweb/gridworks/model/Project.java b/src/main/java/com/metaweb/gridworks/model/Project.java index 184512e81..4ea78274a 100644 --- a/src/main/java/com/metaweb/gridworks/model/Project.java +++ b/src/main/java/com/metaweb/gridworks/model/Project.java @@ -12,11 +12,11 @@ import com.metaweb.gridworks.process.ProcessManager; public class Project implements Serializable { private static final long serialVersionUID = -5089046824819472570L; - public long id; + final public long id; - public ColumnModel columnModel = new ColumnModel(); - public List rows = new ArrayList(); - public History history; + final public ColumnModel columnModel = new ColumnModel(); + final public List rows = new ArrayList(); + final public History history; transient public ProcessManager processManager; diff --git a/src/main/java/com/metaweb/gridworks/model/ReconCandidate.java b/src/main/java/com/metaweb/gridworks/model/ReconCandidate.java index eb829dcfc..811dec38b 100644 --- a/src/main/java/com/metaweb/gridworks/model/ReconCandidate.java +++ b/src/main/java/com/metaweb/gridworks/model/ReconCandidate.java @@ -12,11 +12,19 @@ import com.metaweb.gridworks.expr.HasFields; public class ReconCandidate implements Serializable, HasFields, Jsonizable { private static final long serialVersionUID = -8013997214978715606L; - public String topicID; - public String topicGUID; - public String topicName; - public String[] typeIDs; - public double score; + final public String topicID; + final public String topicGUID; + final public String topicName; + final public String[] typeIDs; + final public double score; + + public ReconCandidate(String topicID, String topicGUID, String topicName, String[] typeIDs, double score) { + this.topicID = topicID; + this.topicGUID = topicGUID; + this.topicName = topicName; + this.typeIDs = typeIDs; + this.score = score; + } @Override public Object getField(String name, Properties bindings) { diff --git a/src/main/java/com/metaweb/gridworks/model/Row.java b/src/main/java/com/metaweb/gridworks/model/Row.java index db0c2f0b9..d24a23abd 100644 --- a/src/main/java/com/metaweb/gridworks/model/Row.java +++ b/src/main/java/com/metaweb/gridworks/model/Row.java @@ -16,7 +16,7 @@ public class Row implements Serializable, HasFields, Jsonizable { public boolean flagged; public boolean starred; - public List cells; + final public List cells; transient public List contextRows; transient public List contextCells; @@ -45,7 +45,7 @@ public class Row implements Serializable, HasFields, Jsonizable { Project project = (Project) bindings.get("project"); Column column = project.columnModel.getColumnByName(name); if (column != null) { - return cells.get(column.cellIndex); + return cells.get(column.getCellIndex()); } return null; } diff --git a/src/main/java/com/metaweb/gridworks/process/ReconProcess.java b/src/main/java/com/metaweb/gridworks/process/ReconProcess.java index f40c7f28c..5d0d0b244 100644 --- a/src/main/java/com/metaweb/gridworks/process/ReconProcess.java +++ b/src/main/java/com/metaweb/gridworks/process/ReconProcess.java @@ -165,9 +165,7 @@ public class ReconProcess extends LongRunningProcess implements Runnable { for (ReconEntry entry : valueToEntries.get(value)) { Cell oldCell = entry.cell; - Cell newCell = new Cell(); - newCell.value = oldCell.value; - newCell.recon = recon; + Cell newCell = new Cell(oldCell.value, recon); CellChange cellChange = new CellChange( entry.rowIndex, @@ -198,19 +196,20 @@ public class ReconProcess extends LongRunningProcess implements Runnable { continue; } - ReconCandidate candidate = new ReconCandidate(); - - candidate.topicID = result.getString("id"); - candidate.topicGUID = result.getString("guid"); - candidate.topicName = result.getString("name"); - candidate.score = result.getDouble("relevance:score"); - JSONArray types = result.getJSONArray("type"); - candidate.typeIDs = new String[types.length()]; - for (int j = 0; j < candidate.typeIDs.length; j++) { - candidate.typeIDs[j] = types.getJSONObject(j).getString("id"); + String[] typeIDs = new String[types.length()]; + for (int j = 0; j < typeIDs.length; j++) { + typeIDs[j] = types.getJSONObject(j).getString("id"); } + ReconCandidate candidate = new ReconCandidate( + result.getString("id"), + result.getString("guid"), + result.getString("name"), + typeIDs, + result.getDouble("relevance:score") + ); + // best match if (i == 0) { recon.features.put("nameMatch", text.equalsIgnoreCase(candidate.topicName));