# Object qualification algorithm

I need to develop algorithm for one task.

I have 500 types of object, each type is represented by a group of qualifiers (about 20 for each type, the same qualifier can be used for different types), where qualifier is a simple predicate (but calculation of the predicate can take some time, as you have to check data in data base). When all qualifiers for particular type return true then object has such type.

For now I just came up with idea to use cache and go through all types trying to do qualification. For each type firstly I go through predicates without calculation and check that no of them failed before if some failed I skip the type, otherwise I go through qualifiers and do calculations (for each predicate I take data from cache if I did the same qualifier before).

I think may be there are some data structures for such task, or common approaches how to do that better.

A small update to the question. The classification data I have, has special structure, like not all attributes of the object mentioned for each class.

For example Type European transaction:

• Country one of DE, FR, ES
• Color : Blue
• Serial type: 2
• Currency : EUR

Type UK transaction:

• Country: UK
• Serial type: 1

It just example out of my head, each object has much more attributes. The main point here that some attributes can present for some objects but not for others. So if we create data set on the objects to build qualification tree, the value of such attributes could be marked as ANY value, that way it's impossible to do qualification, since we can get to the branch where we have two ways to go.

Thanks.

• Welcome to Computer Science! The title you have chosen is not well suited to representing your question. Please take some time to improve it; we have collected some advice here. Thank you! – Raphael May 15 '18 at 13:49
• Related (but I don't know whether any of these will meet your needs): cs.stackexchange.com/q/55607/755, cs.stackexchange.com/q/55434/755, stats.stackexchange.com/q/205414/2921. – D.W. May 21 '18 at 21:26
• What happens when you ask for the Color of a Type UK transaction? Do you get back "None"? More generally, what happens when you check whether an object matches a predicate, when the type of that object doesn't have the attribute mentioned in the predicate? – D.W. May 21 '18 at 21:29
• @D.W. When you ask for Color of a Type UK transaction you actually can get anything, any color at all (green, red, or None). If object doesn't have some attribute, then in terms of Java language that attribute equals to null(None). For case of color checking to be RED we can have something like this: if (obj.color != null) return color == "RED" else return false. To say generally, we get objects, they have many attributes not all of them can be specified. We know that each object can be classified to exactly one type. We know that a lot of required attributes overlap among types. – Sergey Luchko May 22 '18 at 19:16
• I don't understand how to reconcile the first two sentences in your comment. The first sentence seems to say that if the attribute is missing, when you query it you might get back anything (including green). The second sentence seems to say that if the attribute is missing, when you query it you will get back null (None). So which is it? I'm confused. I encourage you to edit the question to specify the model clearly. – D.W. May 22 '18 at 20:01