2
From a non-standard string, I sometimes receive the equivalent of department/category, sometimes equivalent to category/subcategory, sometimes equivalent to department/subcategory, sometimes department/category/subcategory... etc...
...need to create an SQL query for a standardized table with department, category and subcategory to return the possible categories that most match the received string.
I’m racking my brain but I haven’t been able to find an efficient way to do this kind of consultation.
Someone could help me think of an efficient algorithm that can solve this kind of problem?
Example
string recebida = Camisetas/Masculino
Example of a row from the Mysql table:
--------------------------------------------------------
| Departamento | Categoria | Subcategoria |
--------------------------------------------------------
| Moda e Acessórios | Roupas Masculinas | Camisetas |
--------------------------------------------------------
I started the PHP script with a burst in the received string to take the first item of the array as a department, the second as a category and the third (when it exists) as a sub-category but it doesn’t seem like a good way.
Then make the terms inflection.
So I finally do a comparison using the native PHP function similar_text()
But I’m not getting very satisfactory results.
Is there a Pattern for these cases? Any idea will be very welcome.
I think I have seen (and already answered) some questions in this sense. An output is to generate a query with several LIKE, one for each word. See if it looks like this: http://answall.com/a/15810/70 - http://answall.com/a/38293/70 - http://answall.com/questions/13179/70
– Bacco