W3C home > Mailing lists > Public > public-cwm-talk@w3.org > January to March 2005

Re: @keywords: Notation3 Pre-Processor

From: Sean B. Palmer <sean+cwm@infomesh.net>
Date: Sun, 16 Jan 2005 06:57:03 +0000
Message-ID: <41EA103F.3080903@infomesh.net>
To: Tim Berners-Lee <timbl@w3.org>
CC: Yosi Scharf <syosi@mit.edu>, public-cwm-talk@w3.org

Tim Berners-Lee wrote:

> It does or doesn't output a @keywords keyword ... if it
> does presumably some old N3 parsers won't recognize it.

Right, though I thought the only issue was tokenization, and for that 
either method (empty @keywords declarations or removing them entirely) 
will work. Adding the capability to remove @keywords altogether and 
prefix the barenames with a colon instead is very simple; I've appended 
a patch for it [1]. It depends on which format you decide is best for 
the canonicalised N3 that parsers will be accepting. I guess removing 
@keywords entirely would probably be best.

I've modified n3pp.py online to be the patched version, and all of the 
tests still pass. For even further backwards compatibility, it'd have to 
add "@prefix : <#> ." at the top of each file of course.

Cheers,

[1] $ diff -Naur n3pp.py n3pp+new.py [[[
--- n3pp.py     2005-01-14 11:54:34.000000000 +0000
+++ n3pp+new.py 2005-01-16 06:31:38.000000000 +0000
@@ -46,6 +46,8 @@
     [a-zA-Z_][a-zA-Z0-9_]* # n3:barename
  )''')

+r_barename = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*$')
+
  class N3Tokenizer(object):
     def __init__(self):
        self.uri = None
@@ -94,9 +96,10 @@
        for token in self.tokens:
           if token in self.keywords:
              token = '@' + token
+         elif r_barename.match(token):
+            token = ':' + token
+
           if (token == '@keywords') and (not self.prev.startswith('"')):
-            # The "@keywords .\n" is for backwards-compatability
-            self.output.write('@keywords .\n')
              self.keywords = set()
              while True:
                 tok = self.tokens.next()
]]]

-- 
Sean B. Palmer, http://inamidst.com/sbp/
Received on Sunday, 16 January 2005 06:57:39 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:11:01 GMT