I have a web application that shows a users all of their data bucketed in to special campaigns. These campaigns can have different ‘tags’ that belay their purpose (Growth, Retention, Loyalty) many more then I’ve given here.
What I’m looking for is a way to allow more advanced and intelligent users to create groups of AND/OR clauses that allow them to look specifically for certain campaigns that target their strategy.
My tags are simple, index-based with titles. I can generate a list of the campaigns for a user but I want the actual filtering of the campaigns to happen on the user end because they can download the campaigns. The site will also have such things as ‘new’ campaign tags and the like.
So if I have a filterExpression like “(Retention+Growth)|Loyalty”, I should see all campaigns that are tagged with both Retention AND Growth, OR loyalty.
Thoughts?
Right now my logic is causing crossed eyes.
Edit: Psuedo-Example:
Growth OR Loyalty OR Retention
= 0|1|2
filterPass = [ [0], [1], [2] ]
CampaignTags = [ 1,4,5,6 ]
//This campaign passes because it has "1"
(Growth AND Loyalty) OR Retention
= (0+1)|2
filterPass = [ [0,1] , [2] ]
CampaignTags = [ 1,4,5,6 ]
//Fails because it doesn't have "0" AND "1", OR "2"
|operators at the top level, and all+operators just inside that. The example you gave above is already in such a form. Roughly, your algorithm should recursively find terms of the formx+(y|z)and replace them with(x+y)|(x+z)and flatten nested+s and|s.Alternatively, if you need speed, look into BDDs.