Fix Recon features computation for empty recons
This commit is contained in:
parent
7b2e2b5894
commit
deb7335848
@ -567,7 +567,7 @@ public class StandardReconConfig extends ReconConfig {
|
|||||||
* the cell value to compare the reconciliation data to
|
* the cell value to compare the reconciliation data to
|
||||||
*/
|
*/
|
||||||
public void computeFeatures(Recon recon, String text) {
|
public void computeFeatures(Recon recon, String text) {
|
||||||
if (!recon.candidates.isEmpty()) {
|
if (recon.candidates != null && !recon.candidates.isEmpty()) {
|
||||||
ReconCandidate candidate = recon.candidates.get(0);
|
ReconCandidate candidate = recon.candidates.get(0);
|
||||||
|
|
||||||
recon.setFeature(Recon.Feature_nameMatch, text.equalsIgnoreCase(candidate.name));
|
recon.setFeature(Recon.Feature_nameMatch, text.equalsIgnoreCase(candidate.name));
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
package com.google.refine.tests.model.recon;
|
package com.google.refine.tests.model.recon;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertNotNull;
|
||||||
import static org.testng.Assert.assertNull;
|
import static org.testng.Assert.assertNull;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
@ -333,4 +334,15 @@ public class StandardReconConfigTests extends RefineTest {
|
|||||||
assertEquals(recon.candidates.get(0).score, 0.3);
|
assertEquals(recon.candidates.get(0).score, 0.3);
|
||||||
assertEquals(recon.candidates.get(0).id, "18951129");
|
assertEquals(recon.candidates.get(0).id, "18951129");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* computing the features on an empty recon should not fail
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testComputeFeatures() {
|
||||||
|
StandardReconConfigStub stub = new StandardReconConfigStub();
|
||||||
|
Recon recon = stub.createNewRecon(2384738L);
|
||||||
|
stub.computeFeatures(recon, "my string");
|
||||||
|
assertNotNull(recon.features);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user