Reputation: 703
I am looking to take text from a box that will be something like "basketball bristol" or "basketball, Bristol" or even "rugby rugby"
There might be more words there might be no location so just "basketball" or just a location i.e. "Bristol"
I know lots of site that cleverly work out when you have a location in the string and search using that but I am at a loss for how best to implement this as there are many ways that "could" work. I am currently using a Java backend connecting to an ElasticSeach data node.
The question mainly is what is considered the most reliable and effective approach? Any additional hints on a successful implementation would be appreciated.
Upvotes: 0
Views: 128
Reputation: 52185
First thing that comes to mind would be to have a list of all possible locations you can have from your data, you can then compare the words you have in the text with this list. However, this is only valid when you have a few items. Maintaining it would be not practicable.
What you can do however, is to split your text and obtain tokens (words) and then you could query an open source GeoCoding service such as Nominatim. If the word is indeed a place, you should get some GPS coordinates or some similar result, if not you should get something else.
If you require a more rubust system, you might want to take a look at Google's geocoding service.
Upvotes: 1