0
votes

I am trying to implementing a search in my application, specifically it checks a table in my database against certain parameters specified by the user.

For example if my user wants to return a list of records created with the last 7 days. Then he types last 7 days or last seven days in the search bar.

My issue now is being able to change string like this into a valid date that can be used in a where when checking my database.

The number can also be random as in the user can simply type last 2 days or last two days or last 100 days or last hundred days, inputs like week 25 and last month should also be allowed.

Instead of creating multiple drop downs and input boxes to allow the user to select form the front end i would like to do something much simpler like this.

My question now is that is there a feature or a package in laravel that already takes care of this?

If there isn't how would i go about doing something like that??

1
This has to do a lot more with natural language processing than search. A quick googling shows that there are packages that can help. Here's an example packagist.org/packages/nlp-tools/nlp-toolsjfadich
This seems to be rather helpful, first time hearing of it, i will look into it, thanks :)user3718908

1 Answers

1
votes

I think what you need to look up is "NLP" or "Natural Language Processing". There are many libraries and API's within the field that can help you out so that you don't reinvent the wheel (so to speak).

Here is a package in Laravel: Laravel Aylien Wrapper or nlp-tools, but there are many others for PHP in general.

Just do a quick search or look around at Mashape to find some examples.