Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Commit

Permalink
pick states over tiny cities (Oklahoma), but pick big cities over sta…
Browse files Browse the repository at this point in the history
…tes (Sao Paulo) #28
  • Loading branch information
rahulbot committed Mar 23, 2015
1 parent d63549c commit 40e0df1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@ protected List<List<ResolvedLocation>> disambiguate(
return possibilitiesToRemove;
}

/**
* Tuned to skip tiny cities that are populated to solve the Oklahoma problem
* and the Sao Paulo problem.
* @param candidates
* @return
*/
private boolean containsPopulatedCityExactMatch(List<ResolvedLocation> candidates) {
for(ResolvedLocation loc:candidates){
if(loc.geoname.population>0 && isCity(loc) && isExactMatch(loc)){
if(loc.geoname.population>10000 && isCity(loc) && isExactMatch(loc)){
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.mediameter.cliff.test.places.disambiguation;

import static org.junit.Assert.assertEquals;

import java.util.List;

import org.junit.Test;
import org.mediameter.cliff.ParseManager;
import org.mediameter.cliff.test.util.TestPlaces;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.bericotech.clavin.resolver.ResolvedLocation;

public class OklahomaPlaceTest {

private static final Logger logger = LoggerFactory.getLogger(OklahomaPlaceTest.class);

@Test
public void testOklahoma() throws Exception {
List<ResolvedLocation> results = ParseManager.extractAndResolve("Oklahoma say Common Core tests are too costly.").getResolvedLocations();
assertEquals("Found "+results.size()+" places, should have been 1!",1,results.size());
assertEquals(TestPlaces.STATE_OKLAHOMA, results.get(0).geoname.geonameID);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ public class TestPlaces {
public static final int STATE_MAINE = 4971068;
public static final int CITY_BANGOR = 4957280;
public static final int COUNTRY_RUSSIA = 2017370;
public static final int STATE_OKLAHOMA = 4544379;

}

0 comments on commit 40e0df1

Please sign in to comment.