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
Conversation
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.
f4b625d to
633ef09
Compare
| 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)), |
kevinhartman
approved these changes
Sep 11, 2017
| * @see https://github.com/whosonfirst/whosonfirst-placetypes | ||
| */ | ||
| def layerToInt(layer: String): Int = { | ||
| if ("continent".equalsIgnoreCase(layer)) { |
Contributor
There was a problem hiding this comment.
Can you lowercase layer first and then do a match expression here?
| 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}") |
Contributor
There was a problem hiding this comment.
"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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).