W3C home > Mailing lists > Public > public-cwm-talk@w3.org > July to September 2004

How do you do 'table lookup' with n3?

From: Jones, David H <david.h.jones@boeing.com>
Date: Tue, 7 Sep 2004 17:40:06 -0700
Message-ID: <80A0914E4AFDE145B3888E6A107CF65A024B4801@xch-nw-05.nw.nos.boeing.com>
To: <public-cwm-talk@w3.org>

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.


David H. Jones
Boeing Phantom Works, 
Mathematics & Computing Technology
425-865-2964 (FAX)
Received on Wednesday, 8 September 2004 00:40:39 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:01:04 UTC