Skip to content
This repository was archived by the owner on Mar 7, 2018. It is now read-only.

Only keep most granular location for a given name#133

Merged
c-w merged 4 commits intomasterfrom
keep-only-granular-locations
Sep 11, 2017
Merged

Only keep most granular location for a given name#133
c-w merged 4 commits intomasterfrom
keep-only-granular-locations

Conversation

@c-w
Copy link
Contributor

@c-w c-w commented Sep 11, 2017

For example, if we have a location name that is both a city and a state (like "New York") we only want to keep the city.

Implementation note: keeping the LocationExtractorFactory's lookup field as a Map[String, Set[Location]] although only a single location will be in the set after this change to avoid changing the public API of the factory (i.e., minimize risk surface).

For example, if we have a location name that is both a city and a state
(like "New York") we only want to keep the city.
@c-w c-w force-pushed the keep-only-granular-locations branch from f4b625d to 633ef09 Compare September 11, 2017 18:27
analysis = Analysis(
sentiments = List(.6),
locations = List(Location(wofId = "wof-85670485", confidence = Option(1.0), latitude = 12.21, longitude = 43.1)),
locations = List(Location(wofId = "wof-85670485", layer = "coutry", confidence = Option(1.0), latitude = 12.21, longitude = 43.1)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in country

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* @see https://github.com/whosonfirst/whosonfirst-placetypes
*/
def layerToInt(layer: String): Int = {
if ("continent".equalsIgnoreCase(layer)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you lowercase layer first and then do a match expression here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logDebug(s"Discarding location ${oldLocation.wofId} for name $locationName as we now have more granular location ${newLocation.wofId}")
map(locationName) = newLocation
} else {
logDebug(s"Discarding location ${newLocation.wofId} for name $locationName since we already have more granular location ${oldLocation.wofId}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Ignoring" may be clearer for ignored incoming locations, especially at a quick glance while debugging (differentiating from a more specific location being found in the logs).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@c-w c-w merged commit cfc6736 into master Sep 11, 2017
@c-w c-w deleted the keep-only-granular-locations branch September 11, 2017 19:13
@c-w c-w removed the in progress label Sep 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants