From e77b99e58b067a6354dba524d0d7525660ab4082 Mon Sep 17 00:00:00 2001 From: David Huynh Date: Tue, 27 Apr 2010 21:38:47 +0000 Subject: [PATCH] For relevance service, auto-match only if the type matches, the score is at least 100, and if there is more than one result, the ratio of the first result's score over the second result's score must be at least 1.5. For recon service, auto-match only if the result has match:true. git-svn-id: http://google-refine.googlecode.com/svn/trunk@559 7d457c2a-affb-35e4-300a-418c747d4874 --- .../model/recon/HeuristicReconConfig.java | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/metaweb/gridworks/model/recon/HeuristicReconConfig.java b/src/main/java/com/metaweb/gridworks/model/recon/HeuristicReconConfig.java index 4dbf14afb..4b180f8e7 100644 --- a/src/main/java/com/metaweb/gridworks/model/recon/HeuristicReconConfig.java +++ b/src/main/java/com/metaweb/gridworks/model/recon/HeuristicReconConfig.java @@ -294,28 +294,33 @@ public class HeuristicReconConfig extends ReconConfig { score ); - // best match - if (i == 0) { - recon.setFeature(Recon.Feature_nameMatch, text.equalsIgnoreCase(candidate.topicName)); - recon.setFeature(Recon.Feature_nameLevenshtein, StringUtils.getLevenshteinDistance(text, candidate.topicName)); - recon.setFeature(Recon.Feature_nameWordDistance, wordDistance(text, candidate.topicName)); - - recon.setFeature(Recon.Feature_typeMatch, false); - for (String typeID : candidate.typeIDs) { - if (this.typeID.equals(typeID)) { - recon.setFeature(Recon.Feature_typeMatch, true); - if (autoMatch && score >= 100) { - recon.match = candidate; - recon.judgment = Judgment.Matched; - } - break; - } - } - } - recon.addCandidate(candidate); count++; } + + if (count > 0) { + ReconCandidate candidate = recon.candidates.get(0); + + recon.setFeature(Recon.Feature_nameMatch, text.equalsIgnoreCase(candidate.topicName)); + recon.setFeature(Recon.Feature_nameLevenshtein, StringUtils.getLevenshteinDistance(text, candidate.topicName)); + recon.setFeature(Recon.Feature_nameWordDistance, wordDistance(text, candidate.topicName)); + + recon.setFeature(Recon.Feature_typeMatch, false); + for (String typeID : candidate.typeIDs) { + if (this.typeID.equals(typeID)) { + recon.setFeature(Recon.Feature_typeMatch, true); + if (autoMatch && candidate.score >= 100) { + if (count == 1 || + candidate.score / recon.candidates.get(1).score >= 1.5) { + + recon.match = candidate; + recon.judgment = Judgment.Matched; + } + } + break; + } + } + } } catch (JSONException e) { e.printStackTrace(); } @@ -401,9 +406,7 @@ public class HeuristicReconConfig extends ReconConfig { for (String typeID : candidate.typeIDs) { if (this.typeID.equals(typeID)) { recon.setFeature(Recon.Feature_typeMatch, true); - if (autoMatch && - (score > 0.6 || - (result.has("match") && result.getBoolean("match")))) { + if (autoMatch && result.has("match") && result.getBoolean("match")) { recon.match = candidate; recon.judgment = Judgment.Matched; }