Help:Chains of relations and attributes

From semanticweb.org

Jump to: navigation, search


This page expands on Help:Semantic search.

Contents

[edit] Chain of two relations

For a given A, a set of A's, or unrestricted A, and two given relations R1 and R2, we can find C for which there is a B such that C R1 B and B R2 A (a "distance" between A and C of 2 relations). There are two ways, but neither of them gives the triples (C,B,A), nothing more, nothing less. The first method selects B, but includes those without a C, and shows excess A's. The second method selects the correct C's, but does not show A, and shows excess B's. Which method is better varies: if just one A is given, it need not be displayed; with one-to-one relations there are no "siblings" displayed in excess; excess rows are cumbersome if there are many, but rather harmless if there are few, empty cells in one column show that these rows are not applicable.

The first method requires annotations for R1inv and R2. The query is <ask>R2::A[[R1inv::*]][[R2::*]]</ask>. This produces a table with B and C, and all A1 such that B R2 A1. This may include A's not in the specified set. The table may contain excess rows without a C.

Examples:

  • All grandparents: <ask>parent of::+[[child of::*]][[parent of::*]]</ask> gives parents of parents; on the left the parents, on the right their parents (the grandparents), if any, and the children of the parents (those in set A but also siblings):

warning.pngThe part "parent of" of the query was not understood. Results might not be as expected. The part "::" of the query was not understood. Results might not be as expected.

  • Grandparents of Cain, Irad, and Ham:<ask>parent of::Cain||Irad||Ham[[child of::*]][[parent of::*]]</ask> includes rows for each of the parents of Cain, showing that he had no grandparents, and includes the siblings of Ham:
!
!Main
!Main
!Main-c
"myName"
'''Faisal Alkhateeb'''
'n Beetje Verliefd
( 31) - 20 - 598 7731/7483
(+31) - 20 - 598 7678
(+44)(0)114 222 1891
(+44-161) 275-6176
(+45) 4674 3835
(302) 831-1959
(306) 585-5226
(310) 448-8472
(33)4 67 41 85 79
(33-1) 40 27 22 53
(351)911085353
(404) 3851139
(407) 380-1200
(412) 266-2492
(412) 268-5477
(509) 372-4946
(610) 758-6533
(617)440-4364
(65)6790-4802
(650) 723 6725
(650) 723-6725
(650) 723-9770
(650) 859-6153
(805) 523-0193
(814) 865-6460
(animated)
(testing 2)
(testing)
*
++31 (0) 20 - 598 7753
++49681/302-5358
+1 (215) 898-2665
+1 (650) 859-6058
+1 (703) 669 5510
+1 000 000 8080
+1 302.463.1354
+1 412 268 1357
+1 415 555 1212
+1 425 785 9995
+1 507-5388384
+1 613-321-2043
+1 617 258 6167
+1 951 710 1861
… further results

warning.pngThe part "parent of" of the query was not understood. Results might not be as expected. The part "::" of the query was not understood. Results might not be as expected. The part "Cain" of the query was not understood. Results might not be as expected. The part "Irad" of the query was not understood. Results might not be as expected. The part "Ham" of the query was not understood. Results might not be as expected. Some subquery has no valid condition.

The second method (which can be extended to a chain of three relations, see below) requires annotations for R1 and R2. The query is <ask>R1::<q>R2::A</q></ask>. This produces a list with C only. It is not possible to produce B; a partial workaround is to display all B1 such that C R1 B1, these include B: <ask>R1::<q>R2::A</q>[[R1::*]]</ask>. If for A a set of pages is given, another limitation is that A cannot be displayed. There is not even a workaround like for B, unless there are annotations for the composite relation R1.R2.

Examples:

  • <ask>parent of::<q>parent of::+</q>[[parent of::*]]</ask> gives all grandparents, with their children (parents, uncles and aunts):

warning.pngThe part "parent of" of the query was not understood. Results might not be as expected. The part "::" of the query was not understood. Results might not be as expected. The part "parent of" of the query was not understood. Results might not be as expected. The part "::" of the query was not understood. Results might not be as expected. Some subquery has no valid condition.

  • Grandparents of Cain, Irad, and Ham: <ask>parent of::<q>parent of::Cain||Irad||Ham</q>[[parent of::*]]</ask> gives all grandparents of the specified people, with their children (parents, uncles and aunts, without distinguishing these), but without indicating the grandchild:

warning.pngThe part "parent of" of the query was not understood. Results might not be as expected. The part "::" of the query was not understood. Results might not be as expected. The part "parent of" of the query was not understood. Results might not be as expected. The part "::" of the query was not understood. Results might not be as expected. The part "Cain" of the query was not understood. Results might not be as expected. The part "Irad" of the query was not understood. Results might not be as expected. The part "Ham" of the query was not understood. Results might not be as expected. Some subquery has no valid condition.

<ask>has stop::Haarlem (railway station)||Amsterdam Centraal</q>[[has stop::*]]</ask> gives !, !Main, !Main, !Main-c, "myName", Faisal Alkhateeb, 'n Beetje Verliefd, ( 31) - 20 - 598 7731/7483, (+31) - 20 - 598 7678, (+44)(0)114 222 1891, (+44-161) 275-6176, (+45) 4674 3835, (302) 831-1959, (306) 585-5226, (310) 448-8472, (33)4 67 41 85 79, (33-1) 40 27 22 53, (351)911085353, (404) 3851139, (407) 380-1200, (412) 266-2492, (412) 268-5477, (509) 372-4946, (610) 758-6533, (617)440-4364, (65)6790-4802, (650) 723 6725, (650) 723-6725, (650) 723-9770, (650) 859-6153, (805) 523-0193, (814) 865-6460, (animated), (testing 2), (testing), *, ++31 (0) 20 - 598 7753, ++49681/302-5358, +1 (215) 898-2665, +1 (650) 859-6058, +1 (703) 669 5510, +1 000 000 8080, +1 302.463.1354, +1 412 268 1357, +1 415 555 1212, +1 425 785 9995, +1 507-5388384, +1 613-321-2043, +1 617 258 6167, and +1 951 710 1861 … further resultswarning.pngThe part "has stop" of the query was not understood. Results might not be as expected. The part "::" of the query was not understood. Results might not be as expected. The part "Haarlem (railway station)" of the query was not understood. Results might not be as expected. The part "Amsterdam Centraal" of the query was not understood. Results might not be as expected. There appear to be too many occurrences of "</q>" in the query.


<ask>stop of::NS line 10 hlm||NS line 11[[stop of::*]]</ask> gives !, !Main, !Main, !Main-c, "myName", Faisal Alkhateeb, 'n Beetje Verliefd, ( 31) - 20 - 598 7731/7483, (+31) - 20 - 598 7678, (+44)(0)114 222 1891, (+44-161) 275-6176, (+45) 4674 3835, (302) 831-1959, (306) 585-5226, (310) 448-8472, (33)4 67 41 85 79, (33-1) 40 27 22 53, (351)911085353, (404) 3851139, (407) 380-1200, (412) 266-2492, (412) 268-5477, (509) 372-4946, (610) 758-6533, (617)440-4364, (65)6790-4802, (650) 723 6725, (650) 723-6725, (650) 723-9770, (650) 859-6153, (805) 523-0193, (814) 865-6460, (animated), (testing 2), (testing), *, ++31 (0) 20 - 598 7753, ++49681/302-5358, +1 (215) 898-2665, +1 (650) 859-6058, +1 (703) 669 5510, +1 000 000 8080, +1 302.463.1354, +1 412 268 1357, +1 415 555 1212, +1 425 785 9995, +1 507-5388384, +1 613-321-2043, +1 617 258 6167, and +1 951 710 1861 … further resultswarning.pngThe part "stop of" of the query was not understood. Results might not be as expected. The part "::" of the query was not understood. Results might not be as expected. The part "NS line 10 hlm" of the query was not understood. Results might not be as expected. The part "NS line 11" of the query was not understood. Results might not be as expected. Some subquery has no valid condition.

[edit] Chain of two attributes

For a given V, a set of V's, or unrestricted V, and given attributes A1 and A2, we can find W for which there is a B such that B A1 V and B A2 W

The query is <ask>A1::V[[A1:=*]][[A2:=*]]</ask>.

This produces a table with B and W, and all V1 such that B A1 V1. This may include V's not in the specified set. The table may contain excess rows without a W.

[edit] Chain with a relation and an attribute

For a given V, a set of V's, or unrestricted V, a given relation R, and a given attribute A, we consider finding triples (C, B, V) such that C R B and B A V. There are two ways, but neither of them gives nothing more, nothing less. The first method selects B, but includes those without a C, and shows excess V's. The second method selects the correct C's, but does not show V, and shows excess B's. Which method is better varies: if just one V is given, it need not be displayed; with a one-to-one relation there are no "siblings" displayed in excess; excess rows are cumbersome if there are many, but rather harmless if there are few, empty cells in one column show that these rows are not applicable.

The first method requires annotations for A and the inverse of R. The query is <ask>A::V[[A:=*]][[Rinv::*]]</ask>.

This produces a table with B and C, and all V1 such that B A V1. This may include V's not in the specified set. The table may contain excess rows without a C.

Example: <ask>Nr. of screens:=>13[[Nr. of screens:=*]][[located in::*]]</ask> gives:

warning.pngThe part "nr. of screens" of the query was not understood. Results might not be as expected. The part ":=" of the query was not understood. Results might not be as expected. The part ">13" of the query was not understood. Results might not be as expected.

The second method requires annotations for R and A. The query is <ask>R::<q>A:=V</q></ask>. This produces a list with C only. It is not possible to produce B; a partial workaround is to display all B1 such that C R B1, these include B: <ask>R::<q>A:=V</q>[[R::*]]</ask>. If for V a set of pages is given, another limitation is that V cannot be displayed. There is not even a workaround like for B, unless there are annotations for the composite attribute R.A.

Examples:

  • <ask>is location of::<q>nr. of screens:=+</q>[[is location of::*]]</ask> gives all cities with a cinema with 13 or more screens, with all cinemas (not only those with that many screens), but without showing the numbers of screens:

warning.pngThe part "is location of" of the query was not understood. Results might not be as expected. The part "::" of the query was not understood. Results might not be as expected. The part "nr. of screens" of the query was not understood. Results might not be as expected. The part ":=" of the query was not understood. Results might not be as expected. The part ">13" of the query was not understood. Results might not be as expected. Some subquery has no valid condition.

<ask>is location of::<q>nr. of screens:=+</q>[[is location of::*]]</ask> gives all cities with a cinema for which the number of screens is given, with all cinemas, but without showing the numbers of screens:

warning.pngThe part "is location of" of the query was not understood. Results might not be as expected. The part "::" of the query was not understood. Results might not be as expected. The part "nr. of screens" of the query was not understood. Results might not be as expected. The part ":=" of the query was not understood. Results might not be as expected. Some subquery has no valid condition.

[edit] Chain of three relations

For a given A and given relations R1, R2, and R3, we can find D for which there are C and B such that D R1 C and C R2 B and B R3 A (a "distance" between A and D of 3 relations, which is the maximum for a query). This requires annotations for R1inv, R2 and R3. The query is <ask>R2::<q>R3::A</q>[[R1inv::*]]</ask>. This produces a table with C and D. It is not possible to produce B; a partial workaround is to display all B1 such that C R2 B1, these include B: <ask>R2::<q>R3::A</q>[[R1inv::*]][[R2::*]]</ask>

Example:

  • <ask>parent of::<q>parent of::+</q>[[child of::*]][[parent of::*]]</ask> gives parents of parents of parents; on the left the grandparents, on the right their parents (the grandgrandparents), if any, and the children of the grandparents (parents, uncles and aunts):

warning.pngThe part "parent of" of the query was not understood. Results might not be as expected. The part "::" of the query was not understood. Results might not be as expected. The part "parent of" of the query was not understood. Results might not be as expected. The part "::" of the query was not understood. Results might not be as expected. Some subquery has no valid condition.

If for A a set of pages is given, another limitation is that A cannot be displayed. There is not even a workaround like above, unless there are annotations for the composite relation R2.R3.

This kind of query is typically used in conjunction with a query for C R2 B and B R3 A as explained above, to provide the lacking info.

Examples:

<ask>stop of::<q>has stop::Haarlem (railway station)||Amsterdam Centraal</q>[[stop of::*]]</ask> gives the stops with a direct connection with at least one of the given stops, but does not show which one; for each of the resulting stops shows all lines through that stop, but not which one connects to one of the given stops:

warning.pngThe part "stop of" of the query was not understood. Results might not be as expected. The part "::" of the query was not understood. Results might not be as expected. The part "has stop" of the query was not understood. Results might not be as expected. The part "::" of the query was not understood. Results might not be as expected. The part "Haarlem (railway station)" of the query was not understood. Results might not be as expected. The part "Amsterdam Centraal" of the query was not understood. Results might not be as expected. Some subquery has no valid condition.

<ask>has stop::<q>stop of::NS line 10||NS line 11</q>[[has stop::*]]</ask> gives the lines connecting to at least one of the given lines, but does not show which one; for each of the resulting lines shows all stops on that line, but not at which one the line connects to one of the given lines:


warning.pngThe part "has stop" of the query was not understood. Results might not be as expected. The part "::" of the query was not understood. Results might not be as expected. The part "stop of" of the query was not understood. Results might not be as expected. The part "::" of the query was not understood. Results might not be as expected. The part "NS line 10" of the query was not understood. Results might not be as expected. The part "NS line 11" of the query was not understood. Results might not be as expected. Some subquery has no valid condition.

[edit] Overview of queries based on a single relation

First method for a chain of 2, R1inv=R2=R:

For a given A, a set of A's, or unrestricted A, and a given relation R, we can find C for which there is a B such that B R A and A R C

The query is <ask>R::A[[R::*]]</ask>. This produces a table with B and C, and all A1 such that B R A1. This may include A's not in the specified set.

If, for a given A, a set of A's, or unrestricted A, we just want to know the pairs (B,A) such that B R A, the A's not in the specified set can either be seen as an extra, or as some unavoidable clutter.

Examples (we get the first, even if we only want the second):

  • find the parents of A and for each, all their children / find for each A his/her parents
  • find the lines with any of the given stops, and for each, all their stops / find for each stop all lines through that stop
  • find the stops on any of the given lines, and for each, the crossing lines / find for each line all stops

<ask>[[has stop::Haarlem (railway station)||Amsterdam Centraal]][[has stop::*]]</ask> gives:


<ask>[[stop of::NS line 10 shl||NS line 11]][[stop of::*]]</ask> gives:


Second method for a chain of 2, R1=R2=R:

For a given A, a set of A's, or unrestricted A, we can find C for which there is a B such that C R B and B R A

The query is <ask>R::<q>R::A</q></ask>. This produces a list with C only. It is not possible to produce B; a partial workaround is to display all B1 such that C R B1, these include B: <ask>R::<q>R::A</q>[[R::*]]</ask>. If for A a set of pages is given, another limitation is that A cannot be displayed. There is not even a workaround like for B, unless there are annotations for the composite relation R.R.

Examples:

  • Grandparents of Cain, Irad, and Ham: <ask>parent of::<q>parent of::Cain||Irad||Ham</q>[[parent of::*]]</ask> gives all grandparents of the specified people, with their children (parents, uncles and aunts, without distinguishing these), but without indicating the grandchild:

warning.pngThe part "parent of" of the query was not understood. Results might not be as expected. The part "::" of the query was not understood. Results might not be as expected. The part "parent of" of the query was not understood. Results might not be as expected. The part "::" of the query was not understood. Results might not be as expected. The part "Cain" of the query was not understood. Results might not be as expected. The part "Irad" of the query was not understood. Results might not be as expected. The part "Ham" of the query was not understood. Results might not be as expected. Some subquery has no valid condition.

For the relations "has stop" and "stop of" this case is not applicable, because for both, a page cannot be both subject and object of the relation.

[edit] Overview of info related to a given page

Overview of info related to a given page P through relations and attributes, that can be obtained with queries:

  • for all R apply query R P
  • for all R1 and R2 apply query R1 R2 P

requesting for the selected pages as subject, all relations and attributes.

We can add page P itself to the selection, but in many cases this is not needed:

  • if P is the current page, the info is already in the factbox;
  • if there are R1, R2, and Q such that P R1 Q and Q R2 P, then P is already in the selection.

The results of these queries do not only provide much info, but also many links for quick navigation, where one takes up to three steps at a time.

Note however, that if e.g. only "parent of" is annotated and not "child of" the results take only 2 steps up and only one step down at a time in the ancestor tree.

[edit] Overview of info related to a given attribute value

Overview of info related to a given attribute value V through relations and attributes, that can be obtained with queries:

  • for all A apply query A V
  • for all R and A apply query R A V

requesting for the selected pages as subject, all relations and attributes.

In view of the nature of V, it may be possible to dispense with some A's because for them having value V may be unlikely or irrelevant.

[edit] Chains with more links

While a query can reach pages at "a distance of 3", larger distances to a given page can be covered, of course, by making not the given page but related pages starting points of the queries. However, this gives a sequence of separate overviews with much duplication.



All categories | properties | types

Advice on Annotation | Ask | Attribute name | Browsing and searching | Category | Chains of relations and attributes | Custom units | Namespace | Relation name | Selection | SearchTriple | Sorting | Templates in SMW


Personal tools