#########
# WCL/POWDER rules

@keywords is, of, a.
@prefix : <http://www.w3.org/2007/01/lbl22/label#>.
@prefix powder: <http://www.w3.org/2007/01/lbl22/label#>.

@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix s: <http://www.w3.org/2000/01/rdf-schema#> .

@prefix webarch: <webarch@@#>.

@prefix log: <http://www.w3.org/2000/10/swap/log#>. #@@ move down
@prefix str: <http://www.w3.org/2000/10/swap/string#>.

{ ?X a [ suitableForAll ?C ].
  ?Y a ?C.
} => { ?X suitableFor ?Y }.


####
# URI stuff
inDomain s:domain webarch:InformationResource; s:range webarch:DomainName.

# @@See also URISpaces submission
{ ?DOC log:uri [ uriDomain ?D ] } => { ?DOC inDomain ?D }.
{ ?DOC inDomain [ is subdomain of ?D] } => { ?DOC inDomain ?D }.

{
 ?I a webarch:URI.
 (?I "http://([^/]+)/") str:search (?DOMAIN). }
=> { ?I uriDomain ?DOMAIN }.

{
  ?LONGER a webarch:DomainName.
  (?LONGER "[^\\.]*\\.(.*)") str:search (?SHORTER).
} => { ?SHORTER subdomain ?LONGER }.

{
  ?DOC a webarch:InformationResource.
  ?DOC log:uri [ uriDomain ?D ].
  ?D2 a webarch:DomainName.
  ?D str:doesNotContain ?D2. #@@ a little sloppy?
  ?C2 owl:complementOf [ owl:onProperty inDomain; owl:hasValue ?D2].
} => { ?DOC a ?C2 }.


uriPath s:range webarch:URIPath.
pathPrefix s:domain webarch:URIPath; s:range webarch:URIPath.
inPath s:range webarch:URIPath.

{ ?DOC log:uri ?I. ?I uriDomain ?D. (?I ?D) uriPath ?P.
  ( ?D ?P ) str:concatenation ?TXT.
 }
 => { ?DOC inPath ?TXT }.

# a bit contrived for example 4, but might work reasonably well
{
  ?IND owl:onProperty inDomain; owl:hasValue ?D.
  ?INPATH owl:onProperty inPath; owl:hasValue ?P.
  ?DOC inDomain ?D.
  ?DOC log:uri [ str:doesNotContain ?P ].
  ?C owl:intersectionOf (?IND [owl:complementOf ?INPATH]).
} => { ?DOC a ?C }.

  
{ ?I uriDomain ?D.
  (?I "\\w+://[^/]*(/.*)") str:search (?TXT).
} => { (?I ?D) uriPath ?TXT }.

{ (?I ?D) uriPath [ pathPrefix ?P ] } => { (?I ?D) uriPath ?P }.

{
  ?LONGER a webarch:URIPath.
  (?LONGER "(/[^/]*)+/[^/]+$") str:search (?SHORTER).
} => { ?LONGER pathPrefix ?SHORTER }.



#@@ help cwm fire rules
{ ?DOC a webarch:InformationResource; log:uri ?I }
=> { ?I a webarch:URI }.
  
