- You may google references needed to complete the exercise, but you may not google the solution itself. If this happens, the result will be an automatic failure.
- The implementation should be full, so all methods are implemented.
- The implementation should be compilable, so no compilation errors in output window.
- The task should be completed within this hour.
- The implementation should be correct.
- No changes to the original interface are allowed.
At XXX Company, we store all sorts of information about our customers' customers. Those are our C2 users. It is common that our primary customer (a plumbing company for example) needs to find one of those customer records. That's where search comes into play. This is an extremely important scenario for our customers because they may have thousands of customers in their system. It isn't always feasible to expect to find the correct records by simply sorting and manually looking for matches.
You will be provided with three sets of data. Weights will contain a field and numeric value that will be used to score search results. For example, the weight for the 'FirstName' field might be 100. Customers will contain commonly used data to identify customers: first name, last name, and address. Finally, you will be provided with a search string.
Armed with this data, your job is to write a program that will evaluate the provided search string and return the top 5 customer search results. The rules for ranking results are as follows:
- All searches are case-insensitive.
- The score of each search result is the sum of scores of its individual fields.
- The search string can be used in full or in part (split into multiple tokens), which is used in the field scoring function below. Note: The tokenization method has been provided for simplicity.
- The score of a field is calculated as follows:
- If a field contains the full search string, it will evaluate as 400% of its weight.
- If a field exactly matches the text of any search token, it will evaluate as 200% of its weight.
- If a field contains the text of any search token, it will evaluate as 100% of its weight.
- A token may match multiple fields and the weight for each is evaluated in isolation.```