Improving CtxMatch by means of grammatical and ontological knowledge { in order to handle attributes

ing from our example, the general rules for combining atoms are the following. Let n be the node we want to build up the associated formula, and let A be the set of atoms lying in the path from root to n. Furthermore, let f(A) be the formula associated to the atom A by the previous step. Then: 1. R = the first atom in A 2. formula φ = f(R) 3. for each remaining atom A ∈ A, accessing top down: (a) a = main node in A (b) for each ancestor B of A • b = main node in B • R = find-relation(a,b) • Ri = find-relation(b,a) • choose R or Ri (c) if R = IsA or R = PartOf , then φ = φ[b/(f(A))] (d) if Ri = IsA or Ri = PartOf , then φ = φ[a/(f(B))] (e) if R 6= Null, then φ = φ[f(B)/f(A) u ∀R.(f(B))] (f) if Ri 6= Null, then φ = φ[f(B)/f(B) u ∀Ri.(f(A))] The idea expressed by this algorithm is simple. If we find some relation between an atom A and some ancestor B, A becomes a modifier for B, while if we find a relation between B and A, B becomes a modifier for A. The result of applying this final step to the atoms depicted in Figure 4.6 is the following formula: hotel u ∀hasPrice.high u ∀isLocated .(mountain u ∀hasHigh.low) which is exactly that one we want. Note that we use two special rules for IsA and PartOf relations: imagine a situation as depicted in Figure 4.8.a, where we are in presence of a IsA relation.