- From: Lund, Ben <B.Lund@nature.com>
- Date: Wed, 8 Sep 2004 10:20:00 +0100
- To: "'Jones, David H'" <david.h.jones@boeing.com>
- Cc: public-cwm-talk@w3.org
Hi David, Jones, David H wrote: > I'd like to be able to look up arbitrary values in a > table-like structure of rdf properties, but haven't been able > figure out how to do it using n3. > > Can some one show an example of how to do this. Below is my attempt. > > @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . > @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . > @prefix owl: <http://www.w3.org/2002/07/owl#> . > @prefix log: <http://www.w3.org/2000/10/swap/log#>. > @prefix math: <http://www.w3.org/2000/10/swap/math#>. > @prefix string: <http://www.w3.org/2000/10/swap/string#>. > > # Lookup table > [:letterGrade "A"; :numberGrade 10]. > [:letterGrade "B"; :numberGrade 7]. > [:letterGrade "C"; :numberGrade 5]. > [:letterGrade "D"; :numberGrade 3]. > [:letterGrade "F"; :numberGrade 1]. > > :Dave :myLetterGrade "B". > :Kathy :myLetterGrade "A". > > #Attempts at table lookup > #{?y. ?x. :temp :val ?x.:numberGrade. ?y.:myLetterGrade > string:equalIgnoringCase ?x.:letterGrade } => {?y > :myNumberGrade :temp.:val}. > {?y.:myLetterGrade string:equalIgnoringCase ?x.:letterGrade } > => {?y :myNumberGrade ?x.:numberGrade}. > > #Intended inferred properties > #:Dave :myNumberGrade 5. > #:Kathy :myNumberGrade 7. > You should explicitly name a variable for the node you want. Changing your rule to: ---- { ?y.:myLetterGrade string:equalIgnoringCase ?x.:letterGrade . ?x :numberGrade ?num . } => { ?y :myNumberGrade ?num } . ---- gives you what you need. $ cwm table.n3 results.n3 --filter=rules.n3 #Processed by Id: cwm.py,v 1.144 2003/09/14 20:20:20 timbl Exp # using base file:/home/ben/devel/temp/ # Notation3 generation by # notation3.py,v 1.146 2003/09/14 20:20:24 timbl Exp # Base was: file:/home/ben/devel/temp/ @prefix : <results.n3#> . @prefix log: <http://www.w3.org/2000/10/swap/log#> . @prefix math: <http://www.w3.org/2000/10/swap/math#> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix string: <http://www.w3.org/2000/10/swap/string#> . @prefix table: <table.n3#> . :Dave :myNumberGrade 7 . :Kathy :myNumberGrade 10 . #ENDS (table.n3 contains the table, results.n3 contains the myLetterGrade statements and rules.n3 contains the rule) Ta, Ben --- ******************************************************************************** DISCLAIMER: This e-mail is confidential and should not be used by anyone who is not the original intended recipient. If you have received this e-mail in error please inform the sender and delete it from your mailbox or any other storage mechanism. Neither Macmillan Publishers Limited nor any of its agents accept liability for any statements made which are clearly the sender's own and not expressly made on behalf of Macmillan Publishers Limited or one of its agents. Please note that neither Macmillan Publishers Limited nor any of its agents accept any responsibility for viruses that may be contained in this e-mail or its attachments and it is your responsibility to scan the e-mail and attachments (if any). No contracts may be concluded on behalf of Macmillan Publishers Limited or its agents by means of e-mail communication. Macmillan Publishers Limited Registered in England and Wales with registered number 785998 Registered Office Brunel Road, Houndmills, Basingstoke RG21 6XS ********************************************************************************
Received on Wednesday, 8 September 2004 09:20:38 UTC