Suppose you have a list of 100,000+ google queries related to travel bookings. For example:

hotels in london
barcelona flight
city breaks to berlin
khao san road hostel
luxury holiday to paris
new york business class flight price
disneyland trip...
  1. How can I extract the location i.e., London
  2. Classify the Line of Business i.e., flight, hotel, package, etc
  3. Classify the affinity i.e., luxury, family, city break, beach etc
  4. Use this info to record the frequency of various pattern that exists in the keywords

    i.e. **keyword pattern**                **frequency**
    (destination) hotel                          xxx
    flight to (destination)                      yyy
    (theme) (destination) hotel                  zzz


  1. Manual - get an exhaustive as possible list of locations (most of the queries will be for tourist destinations) and look for a match against the keywords. Again, compare the keywords against possible Line of Business Identifiers and Affinity Identifiers

  2. Google Cloud Natural Language API - This can be used to analyse Entities and Sentiment of text. e.g. hotels in london -> entity(hotels), entity(london) barcelona flight -> entity(flight), entity(barcelona) This isn't very powerful and only supports english.

  3. Machine learning - seems difficult as I haven't got any descriptors for the keywords. Would Naive Bayes be applicable or SVM?

I'd preferably like to run any solution in R too.

Could someone please suggest a direction/potential solution?


1 Answer 1


The questions you have listed are more or less independent from each other. To extract location, you should be looking into the class of solutions called Named Entity Recognition. It is widely supported, and, for example, NLTK should have location extraction support for languages but English.

The second task, the line of business, seems cryptic to me, since you are solving the task, you have complete information on the full list of those lines, so probably writing any kind of detector (custom NER would work) is a way to go, however, if all the queries are formed as LOB + location, by solving the first one, you can subtract the location out of query to get the line of business.

From the examples of queries you have provided, I don't see any way for a human being to extract any affinity, so you should investigate it to understand if those queries actually carry such kind of information.

With (1) and (2) given, the fourth task should be trivial to count.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.