What I love about this problem is that it asks for production level code, and the problem is much deeper than it might appear at first glance. There are also many different ways to skin this cat and there is no "right answer".
When I implemented this, I had to see how my code compared with the production level code on Yelp, so in the source code (see link below), you'll see some test code that compares the two. I ended up preferring the results that my code produced in a number of cases. Here's one example. What do you think?
Here is the original review in its entirety:
I've only been here once, but that one visit was enough for me to know that the pizza here is awesome. It's as good as it gets. It's just sad that they don't have a joint here in Cupertino, but then again I'd be willing to drive to SF from time to time just to enjoy their pizza. The time I went there, the restaurant was bursting with people. We had to wait for at least half an hour or even more, can't really recall. But let me tell you, it was worth the wait. We had the deep dish pizza, the thin crust pizza, the chicken wings and as we plow through the first round of pizzas, we realize that we want more, so there goes the second round. Another round of the deep dish spinach-feta cheese-mushroom pizza and other yummy stuff, we were good to go. I highly recommend the spinach-cheese-mushroom deep dish pizza. I would definitely come back and try their other pizzas. Aaaaahhhhh who's down to go grab some little star pizzas with me right now!!! haha four thumbs up (including my two toes hahaha) That's how good this place is! Oh and make sure you go with the right company - that will make the experience a golden one =DHere is the review fragment that Yelp currently produces:
can't really recall. But let me tell you, it was worth the wait. We had the deep dish pizza, the thin crust pizza, the chicken wings and as we plow through the first round of pizzas, we realize thatHere is the review fragment that my code produces:
We had the deep dish pizza, the thin crust pizza, the chicken wings and as we plow through the first round of pizzas, we realize that we want more, so there goes the second round. I highly recommend the spinach-cheese-mushroom deep dish pizza.Which review fragment do you like better?
Download a ZIP containing the source code to my solution to this problem.
Here is the original problem statement:
For yelp search we need to highlight document snippets that match a query. For
example a yelp search for [deep dish pizza] returns documents that match the
query as well as highlights that try to show why the document is relevant.
(http://www.yelp.com/search?find_desc=deep+dish+pizza&ns=1&rpp=10&find_lo
c=San+Francisco%2C+CA ). Note that highlights (1) highlight all the words in
the query and (2) are not necessarily the full document (they are
instead only a relevant snippet).
For this question you will write a function that finds the most relevant snippet for
a document and highlights all the query terms that appear in the snippet
(basically the highlights you saw on the linked search page).
It is up to you to define what constitutes a good snippet and how big the snippets
will be.
Indicate highlights by surrounding the text to be highlighted with [[HIGHLIGHT]]
.[[ENDHIGHLIGHT]] ...
For instance "Little star's deep dish pizza sure is fantastic." would look like "Little
star's [[HIGHLIGHT]]deep dish pizza[[ENDHIGHLIGHT]] sure is fantastic."
internally.
One highlighting example might be:
highlight_doc("I like fish. Little star's deep dish pizza sure is fantastic. Dogs are
funny.", "deep dish pizza") -> "Little star's [[HIGHLIGHT]]deep dish
pizza[[ENDHIGHLIGHT]] sure is fantastic."
Note that your highlighter doesn't have to have the exact same result on this
example, since *you* are defining what a good snippet is.
The solution can be in any language (but python is preferred). Attach your native
source files (.py, .java, .cpp, etc...). Hint: Write your code as if your peers may be
maintaining your code. Your code should be as if it were for a production
environment. And don't forget to include unit tests!
I would like a function with the signature similar to the following:
def highlight_doc(doc, query):
"""
Args:
doc - String that is a document to be highlighted
query - String that contains the search query
Returns:
The the most relevant snippet with the query terms highlighted.
"""
Hi, interesting problem, I saw your code but couldn't find MatchScore.java class. Can you please provide that.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThere are also many different ways Buy Yelp Reviews to skin this cat and there is no "right answer".
ReplyDeleteJust loved your analysis , you coded in professional way bdw did you get offer from yelp or do you work work at yelp ? also please share other question if you have ??
ReplyDeleteI appreciated your work very thanks Buy Yelp Reviews
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteWhile doing this, it is important to note that the end of your marketing plan cannot be determined the followers’ startup, since the more you buy followers, the additional boost you give to your twitter accounts and business.Buy Targeted Twitter Followers
ReplyDeleteBuy Google Reviews is a new era of advertising and service in which your business/brand is defined by those who experience it.Get Google Reviews & Rating
ReplyDeleteOver 90% of contributors claimed that online positive reviews influenced their purchasing decision, and 85% said their decision was influenced by minus reviews.Buy Google Reviews
ReplyDeleteOur challenge is in imitation of spread you page decennial by a helpful amount on Google accounts..Buy 5 star Google Reviews
ReplyDeleteGoogle reviews can either be positive or negative for your business, stores, office, restaurant, service or requirements. Google is the largest search engine, as well as the most efficient advertisement website.Buy 5 star Google Reviews
ReplyDeleteGoogle allows users to write reviews directly on the business’s Google or Google map listing. Since Google reviews are obviously favored by the search engine and show up upon every relevant result, the best place to start a business firm is getting involved with Google Reviews.
ReplyDeleteBuy 5 star Google Reviews
The key features of this service are that all page reposts are permanent). Second, you’ll get 100% satisfaction assurances. The service delivery time is 10 hours. No programs, bots, or software are used in this service. When you buy this service, it’s a 100 %stable and safe account, with real high-class campaigns as well as 100 % safety and security, as well as customer satisfaction. With this service, you’ll save time and effort. You’ll experience improvements within 24 hours.
ReplyDeleteBuying SoundCloud Plays
Google To FACEBOOK people are sharing their experiences on all, and what they say has a huge impact. Over 90% of contributors claimed that online positive reviews influenced their purchasing decision, and 85% said their decision was influenced by minus reviews.Buy Google Reviews
ReplyDeleteSoundCloud has given a significant career toward numerous new performers. It has given them a chance toward showcase their talent in all above the world.Buy SoundCloud Plays Cheap
ReplyDeleteOne of the reasons why artists should buy SoundCloud plays is acquiring intrinsic inspiration.Buy Real SoundCloud Plays
ReplyDeleteDelivery time is ten hours before you know it your work is online waiting for likes and followers. There is nothing like wasting time unlike other social media. Buying Google reviews delivers the result very fast. Buy Google Star Reviews
ReplyDeleteDelivery time is ten hours before you know it your work is online waiting for likes and followers. There is nothing like wasting time unlike other social media. Buy Real Google Reviews
ReplyDeleteMangocity IT I appreciated your work very thanks Buy Yelp Reviews
ReplyDeleteTop Promoter This is really a nice and informative, containing all information and also has a great impact on the new technology. Check it out here: SoundCloud Promotion
ReplyDeleteTop SEO Work Excellent information on your blog, thank you for taking the time to share with us. Amazing insight you have on this, it's nice to find a website that details so much information about different artists. Monthly SEO Service
ReplyDeleteThanks for this article very helpful. thanks. Best brand Google Reviews
ReplyDeleteI read that Post and got it fine and enlightening. If you don't mind share more like that... Buy SoundCloud Plays
ReplyDeleteBuy Soundcloud Service
ReplyDeleteThis is my first time i visit here. I discovered such a large number of fascinating stuff in your online journal particularly its dialog. From the huge amounts of remarks on your articles, I figure I am by all account not the only one having all the satisfaction here! keep doing awesome BUY GOOGLE PLUS REVIEWS