Question: 1. The first step would be to do this coding assignment and send the answer back for review. 2. Feel free to code in any
1. The first step would be to do this coding assignment and send the answer back for review.
2. Feel free to code in any language you prefer.
3. Please include a quick summary of your thought process of your code and the efficiency of your solution.
Suppose you're building a Yelp competitor, and now want to implement your version of Review Highlights.
"The Review Highlights feature was built to help consumers quickly discover the core elements, attractions, menu items, or other popular offerings that a business may be known for. The highlights reflect overall trends we see in the words or phrases that Yelpers use in their reviews of the business, which reduces the consumer's task of reading dozens (or even hundreds) of reviews."
Write a function with this signature:
def review_highlights(reviews, max)
# Arguments:
# * reviews is an array of strings
# * max is the maximum number of review highlights to return
#
# Returns an array of 0 to max review highlights
For example, given the following reviews:
? "I Love their falafel sandwiches, go early there is always line at lunchtime during the week, but it goes pretty quick.",
? "I've also had the gyros sandwich, which I honestly have only had once. Like I said previously, the falafel sandwich is just too good. What's different about Falafel Drive-In's gyros is that the meat is cubed--not sliced. I also like the seasoning used for the gyros meat.",
? "Falafel's Drive-In is one popular place--its menu is a cross between Middle East-inspired street food and American classics (hot dogs and the like).",
? "The food itself was fine. We ordered one of the specials, a large falafel sandwich and banana shake, a large side of fries, and then a falafel salad. The falafel itself really is great and with the red sauce on the side, it is awesome. However, the salad was just really plain and bland."
Some possible review highlights might be:
? "falafel sandwich"
? "I Love their falafel sandwiches, go early there is always line at lunchtime during the week, but it goes pretty quick."
These are just examples. There are no right or wrong review highlights! We've purposely left this more open to see how you think.
The solution can be in any language. Send your source files, and provide instructions to build an executable named rh (if you've used a compiled language), or provide a script named rh (if it's an interpreted language).
rh should expect two arguments:
? the first argument is the path to a file containing one review per line (i.e., each review is " " delimited)
? the second argument is the maximum number of review highlights to return rh should print one review highlight per line (" " delimited"). For example:
$ cat ~/reviews.txt
I Love their falafel sandwiches, go early there is always line at lunchtime during the week, but it goes pretty quick.,
I've also had the gyros sandwich, which I honestly have only had once. Like I said previously, the falafel sandwich is just too good. What's different about Falafel
Drive-In's gyros is that the meat is cubed--not sliced. I also like the seasoning used for the gyros meat.,
Falafel's Drive-In is one popular place--its menu is a cross between Middle East-inspired street food and American classics (hot dogs and the like).,
The food itself was fine. We ordered one of the specials, a large falafel sandwich and banana shake, a large side of fries, and then a falafel salad. The falafel itself really is great and with the red sauce on the side, it is awesome. However, the salad was just really plain and bland.
$ ./rh ~/reviews.txt 2
falafel sandwich
I Love their falafel sandwiches, go early there is always line at lunchtime during the week, but it goes pretty quick.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
