Added option for automatically approving best recon candidates that match the expected type and score at least some minimum score.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@115 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-02-21 08:11:07 +00:00
parent b4935f576c
commit b3167a1a9f
3 changed files with 29 additions and 10 deletions

View File

@ -92,7 +92,9 @@ public class ApplyOperationsCommand extends Command {
engineConfig,
columnName,
obj.getString("typeID"),
obj.getString("typeName")
obj.getString("typeName"),
obj.getBoolean("autoMatch"),
obj.getDouble("minScore")
);
} else if ("save-protograph".equals(op)) {
operation = new SaveProtographOperation(

View File

@ -17,7 +17,9 @@ public class ReconcileCommand extends EngineDependentCommand {
String columnName = request.getParameter("columnName");
String typeID = request.getParameter("typeID");
String typeName = request.getParameter("typeName");
boolean autoMatch = "true".equals(request.getParameter("autoMatch"));
double minScore = autoMatch ? Double.parseDouble(request.getParameter("minScore")) : 0;
return new ReconOperation(engineConfig, columnName, typeID, typeName);
return new ReconOperation(engineConfig, columnName, typeID, typeName, autoMatch, minScore);
}
}

View File

@ -32,6 +32,7 @@ import com.metaweb.gridworks.model.Recon;
import com.metaweb.gridworks.model.ReconCandidate;
import com.metaweb.gridworks.model.ReconConfig;
import com.metaweb.gridworks.model.Row;
import com.metaweb.gridworks.model.Recon.Judgment;
import com.metaweb.gridworks.model.changes.CellChange;
import com.metaweb.gridworks.model.changes.MassCellChange;
import com.metaweb.gridworks.process.LongRunningProcess;
@ -44,12 +45,23 @@ public class ReconOperation extends EngineDependentOperation {
final protected String _columnName;
final protected String _typeID;
final protected String _typeName;
final protected boolean _autoMatch;
final protected double _minScore;
public ReconOperation(JSONObject engineConfig, String columnName, String typeID, String typeName) {
public ReconOperation(
JSONObject engineConfig,
String columnName,
String typeID,
String typeName,
boolean autoMatch,
double minScore
) {
super(engineConfig);
_columnName = columnName;
_typeID = typeID;
_typeName = typeName;
_autoMatch = autoMatch;
_minScore = minScore;
}
public Process createProcess(Project project, Properties options) throws Exception {
@ -64,8 +76,7 @@ public class ReconOperation extends EngineDependentOperation {
return new ReconProcess(
project,
getEngineConfig(),
description,
_columnName
description
);
}
@ -78,6 +89,8 @@ public class ReconOperation extends EngineDependentOperation {
writer.key("columnName"); writer.value(_columnName);
writer.key("typeID"); writer.value(_typeID);
writer.key("typeName"); writer.value(_typeName);
writer.key("autoMatch"); writer.value(_autoMatch);
writer.key("minScore"); writer.value(_minScore);
writer.key("engineConfig"); writer.value(getEngineConfig());
writer.endObject();
}
@ -131,20 +144,17 @@ public class ReconOperation extends EngineDependentOperation {
public class ReconProcess extends LongRunningProcess implements Runnable {
final protected Project _project;
final protected JSONObject _engineConfig;
final protected String _columnName;
protected List<ReconEntry> _entries;
protected int _cellIndex;
public ReconProcess(
Project project,
JSONObject engineConfig,
String description,
String columnName
String description
) {
super(description);
_project = project;
_engineConfig = engineConfig;
_columnName = columnName;
}
protected Runnable getRunnable() {
@ -350,12 +360,13 @@ public class ReconOperation extends EngineDependentOperation {
typeIDs[j] = types.getJSONObject(j).getString("id");
}
double score = result.getDouble("relevance:score");
ReconCandidate candidate = new ReconCandidate(
result.getString("id"),
result.getString("guid"),
result.getString("name"),
typeIDs,
result.getDouble("relevance:score")
score
);
// best match
@ -368,6 +379,10 @@ public class ReconOperation extends EngineDependentOperation {
for (String typeID : candidate.typeIDs) {
if (_typeID.equals(typeID)) {
recon.setFeature(Recon.Feature_typeMatch, true);
if (_autoMatch && score >= _minScore) {
recon.match = candidate;
recon.judgment = Judgment.Matched;
}
break;
}
}