Categories assignement based on rules

I´m bringing today a tough issue which is causing me a huge headache. I´m trying to design a solution to assign categories automatically to certain groups of foods. These categories will be able to make the automatic assignment based on a huge set of available rules, based on parameters from this "foods".

Based on this statements:

  • The main issue starts from the point that more than food can comply with more than one rule.
  • Since the categories will be customized, there is a big possibility that more than one category complies with one food, using different rules
  • I need to solve this potential issue where my "wished" category is more important than all the possible others that comply with the same food.

Hope I was clear enough, it was a bit difficult to explain

Kind regards