[Previous] [Next] [Title]

2. Integrating a rulebase with other web resources


2.1. Publishing rulebases on web pages

In order to enable your rulebase to communicate with other rule bases, you must first publish it onto the web.

2.1.1. Creating a web page containing a rulebase

In order to create a permanent `home' for your rulebase and (eventually) to integrate the hypertext and text retrieval functions of the world-wide-web with it, you need to place your rulebase on its own web page. Below, there is first an explanation of how to embed a ysh knowledgebase in any web page, then in the next section there is a template which enables creation of a web page with no knowledge of HTML.

The HTML tags needed for wysh: <PRE><!--ysh> AND <!--/ysh--> </PRE>

Two pairs of HTML tags must be inserted on any web page that is to contain a rulebase, one before and one after the rulebase:

 (i) the <!--ysh> and <!--/ysh--> tags inform wysh where the rulebase starts and ends;

 (ii) the <PRE> and </PRE> tags ensure that the rulebase is treated as pre-formatted text, otherwise it would simply appear on the web page as one long line of text.

 These tags may only be used once on any page, enclosing the whole knowledgebase. No other HTML tags may be used within the knowledge base (this may later be changed, but must be observed for now). Any other HTML may appear before the <PRE><!--ysh> tags or after the <!--/ysh--> </PRE> tags.

 An example of how a small knowledgebase would appear on a web page is as follows:

<PRE>
<!--ysh>
RULE Freedom of Information Act 1982 (Cth) s11 PROVIDES
a person has a legally enforceable right under s11 to obtain access to a document ONLY IF 
        s11(a) applies OR 
        s11(b) applies
<!--/ysh--> 
</PRE>

Running a rulebase on another web page from the `manual start' page

The wysh manual start page allows you to run a knowledgebase which is located on another web page by inserting its address (URL) in the box pictured below. The example given is for the page containing the small FOI example discussed in this exercise.


 

After inserting the URL, click on the `Consult!' button to run the rulebase.


 
 

Running your rulebase from your own web page

The preferable way to run a rulebase contained on a separate web page is to insert a HTML instruction (`tag') on the page which enables you to run the rulebase from that page. The general format of the tag is:
<A HREF="http://wysh.austlii.edu.au/do/wysh?rulebase=URL OF PAGE">LINK TEXT</A>
In this tag, `URL OF PAGE' is to be replaced by the address of the page containing the rulebase, and `LINK TEXT' is to be replaced by the text you wish to appear as the hypertext link which is used to start the consultation running. The following example could beused for the FOI rulebase, and would cause the words `Run consultations' to appear as the hypertext link:
<A HREF="http://wysh.austlii.edu.au/do/wysh?rulebase=http://www2.austlii.edu.au/~graham/wysh/foi1.html">
Run consultations</A> using the FOI s11 knowledgebase

2.1.2. The wysh template

The page pictured below can be accessed as `wysh template' from the wysh index page, and is located at http://www2.austlii.edu.au/~graham/wysh/wysh_template.html

 The purpose of this template is to enable those who are unfamiliar with HTML to copy this page, `fill in the blanks' for a couple of pieces of information, paste their ysh knowledgebase into the page, and then place it on a web server (such as sandpit) so it can run.

 To use the template, you need 4 pieces of information: (i) your name (it gets harder); (ii) the name you wish to give your page (eg `FOI s11' for the small example above); (iii) the URL (address) of your page; and (iv) the rulebase that you wish to incorporate in the page.


 

wysh template - http://www2.austlii.edu.au/~graham/wysh/wysh_template.html


 
 

Copying and editing the wysh template using Netscape Gold

First, go to the template using Netscape Gold. Use  to open this page in the editor. Since it is not a page already on your local drive, the `Save Remote Document' window will appear - OK to continue. Use `Save As' to save the page with a sensible name for your project (eg `foi.htm').

 Now use Netscape Gold to edit the following items in the template:

Finally, save the changes, and test that the page is correct by viewing it in the browser ( ).

 WARNING - Do not use Netscape Composer to edit these wysh template pages - it inserts garbage characters which stop it running. Netscape Gold does, however, seem to be OK. If there are problems, just edit the file in a word processor (and remember to save it as 'text only') or text editor.

2.1.3. Publishing your wysh page onto the web

Follow the same instructions for publishing your pages as are found in 3.1. Publishing your pages onto the web in the 'Building a web site for law' Tutorial.

Saving your file - instructions for file names

Some versions of Netscape Gold convert file names to UPPER CASE when publishing them - so it may be safest to have an UPPER CASE name for your file to start with.

If you are dong this tutorial in a computer lab in class, please save all files with a numbered version of your first initial and surname, to a maximum of 8 digits. For example, John Bradshaw would save files named JBRADSH1.HTM, JBRADSH2.HTM, JBRADSH3.HTM etc. This will make it much easier to identify files and `clean up' the aiail directory when needed.

2.1.4. Appendix: HTML source of the wysh_template.html file

You can skip this - but if you want to understand the html that allows wysh rulebases to be published on the web, this example shows you what to do.
<HTML>
<HEAD>
   <TITLE>wysh example - YOUR TITLE</TITLE>
</HEAD>
<BODY>

<H1><IMG SRC="http://www.austlii.edu.au/images/ysh.gif" HEIGHT=32 WIDTH=32 ALIGN=BOTTOM>wysh example - YOUR TITLE </H1>

<P><B>Author: YOUR NAME</P></B>

<P>This is a demonstration of rule-based inferencing using the ysh inferencing engine and the wysh interface to ysh. It has been written as a student project for the purposes of <A HREF="http://www2.austlii.edu.au/~graham/CAL/">LAWS 4619 -  Developing Computer Applications to Law (B)</A> at the University of New South Wales Faculty of Law. This project must not be relied upon or used for the purpose of legal advice. <BR>Further information and examples can be found in the <A HREF="http://www.austlii.edu.au/links/World/Subjects/Computerisation_of_Law/Web_Tools/wysh/">wysh index</A>. </P>

<P>
<HR></P>

<H4><A HREF="http://www2.austlii.edu.au/do/wysh?rulebase=URL OF YOUR PAGE GOES HERE">Run consultations</A> using the YOUR TITLE knowledgebase</H4>

<HR>
<P>
<H3>YOUR TITLE knowledgebase</H3>

<PRE><!--ysh-->

[PASTE YOUR KNOWLEDGEBASE HERE, REPLACING THIS LINE OF TEXT ONLY]

<!--/ysh-->
</PRE>
<HR>
<P><A HREF="http://www.austlii.edu.au/austlii/personnel.html#andrew">Andrew Mowbray</A> wrote the ysh inference engine (1991-94).<BR> <A HREF="http://www.austlii.edu.au/austlii/personnel.html#geoff">Geoffrey King</A> wrote the wysh web interface to ysh (1996 - ) (further details on the <A HREF="http://www.austlii.edu.au/austlii/wysh/">wysh pages</A>).<BR>
<A HREF="http://www.austlii.edu.au/">AustLII</A>'s research on legal inferencing via the web is funded by the Australian Research Council.</P>

</BODY>
</HTML>

2.2. Hypertext links from wysh rulebases

Hypertext links may be created from a knowledgebase, so that whenever a word or phrase or Act or section reference appears in an inferencing dialogue, explanation or report, it will appear as a hypertext link.

 See 5. Integration of Wysh rulebases into AustLII and the World Wide Web in the Wysh Developers' Manual.

2.2.1. Automatic links to AustLII from the `wysh manual start page'

Links to names of Acts (and sections within Acts) that are located on AustLII can be added automatically to your knowledgebase (ie you do not have to create tags for each link in your knowledgebase. Automatic links are not created to words defined in Acts.

There are two ways to create automatic links from rulebases.

 The first method is simple and useful for testing. On the `wysh manual start page (Enhanced version)', simply check the box which appears after the `Paste the rulebase here:' window:

 The automatic creation of links works both with rulebases entered under the `Enter a URL of a rulebase:' window, and the `Paste the rulebase here:' window.

2.2.2. Automatic links to AustLII when consultations run from your own page (&markup=ON)

Automated links can also be created from a web page containing a rulebase . The expression `&markup=ON' must be added to the URL which starts the consultation.

 For example:

http://www2.austlii.edu.au/do/wysh?rulebase=http://sandpit.austlii.edu.au/~aial/foitest/foi_s11.html&markup=ON


is the URL that appears under the `Run consultation' link on the `FOI s11
(start here)' page.

wysh template has been amended

The URL under the `Run consultation' link on the wysh template has been amended to read:

http://www2.austlii.edu.au/do/wysh?rulebase=URL OF YOUR PAGE GOES HERE&markup=ON


When replacing `URL OF YOUR PAGE GOES HERE', make sure you do not delete
`&markup=ON' (assuming you want automated links), and make sure that
there is no blank space before `&markup=ON', or any blank space after
`=`.

2.2.3. Explicit links in a rulebase (the LINK ... TO ... keywords)

In addition to automatic links to AustLII, specific links can be specifed in the rulebase. The keywords LINK and TO are used to specify in a rulebase that a particular word or phrase is always to appear as a hypertext link to a particular URL. This is very useful for creating links to definitions or cases.

 LINK ...TO ... can be used to create links from a rulebase to anywhere on the world-wide-web, not just to AustLII.

Example

LINK document of an agency TO             http://www2.austlii.edu.au/au/legis/cth/consol_act/foia1982222/s4.html#document_of_an_agency

RULE Freedom of Information Act 1982 (Cth) s11(a) PROVIDES
s11(a) applies ONLY IF
        the document is a document of an agency AND
        the document is not an exempt document

2.2.4. Searches from wysh rulebases

It is also possible to use LINK ...TO ... to create links from a rulebase to a stored search

anywhere on the world-wide-web, not just to AustLII

Example

LINK official document of a Minister TO http://search.austlii.edu.au/do/sinosrch.pl?query=official+document+of+a+Minister&searchscope=Title+%26+Text&selection=All+AustLII+Databases&numhits=200&searchtype=Freeform

RULE Freedom of Information Act 1982 (Cth) s11(b) PROVIDES
s11(b) applies ONLY IF
        the document is an official document of a Minister AND
        the document is not an exempt document

2.3. `Co-operative inferencing' - rulebases on multiple pages

`Co-operative inferencing', as we are tentatively calling it, is the most interesting and innovative aspect of wysh. It allows different rulebase developers to place rulebases on any web page anywhere in the world and to declare that consultations using their rulebase will also use any other rulebases located elsewhere on the web that they specify are to be `included'. In this sense, rulebase development becomes a `co-operative' activity where developers can contribute their small (or not so small) rulebases to a larger enterprise.

2.3.1. The INCLUDE keyword

The use of the keyword INCLUDE in a rulebase, followed by the URL of another page containing a wysh rulebase, will cause the second rulebae to be loaded with the first rulebase, and the two run together.

More than two rulebases can be declared to be INCLUDEd. There is no limit on the number.

 It does not matter if an INCLUDEd rulebase INCLUDEs the rulebase that INCLUDEd it - ie wysh ignores recursion and does not go into some endless loop of loading the same rulebases.

 It is useful to make the URLs of INCLUDEd rulebases live links, so that users of a knowledgebase can conveniently view all knowledgebases which are to be included in a consultation. See the `FOI s11 (start here)' rulebase for examples.

Example

INCLUDE http://sandpit.austlii.edu.au/~aial/foitest/foi_s11_b.html 
INCLUDE http://sandpit.austlii.edu.au/~aial/foitest/foi_s11_a.html 
PERSON a person
THING the document
GOAL RULE Freedom of Information Act 1982 (Cth) s11 PROVIDES
a person has a legally enforceable right under s11 to obtain access to a document ONLY IF 
        s11(a) applies OR 
        s11(b) applies

2.3.2. At least one GOAL rule must be specified

As in the example above, you must specify which rule is the GOAL RULE that is to start the consultation, because the operation of INCLUDE means that you cannot be certain which rule wysh will consider is the first one appearing in your knowledgebase.

If more than one GOAL RULE is specified in a set of `co-operative' rulebases, the user will be given a choiice of which rule is to start the consultation. GOAL RULEs may be declared in any rulebase.

2.3.3. LINK ... TO... does not yet work `globally' over a set of `co-operative' rulebases

For example, in the `FOI s11 (start here)' knowledgebase:
INCLUDE http://sandpit.austlii.edu.au/~aial/foitest/foi_s11_b.html 
INCLUDE http://sandpit.austlii.edu.au/~aial/foitest/foi_s11_a.html 
LINK document TO http://www2.austlii.edu.au/au/legis/cth/consol_act/foia1982222/s4.html#document
does not yet result in `document' being hypertext linked from all three knowledgebases, but only from the one in which it occurs.

 This is being changed so that LINK ... TO ... declarations will be `global' unless you declare them to be local.

 2.2. Expanding your ysh rulebase

This exercise aims to guide you to some of the more important parts of the ysh/wysh Developers Manual. Use the list below as a check-list of important things to understand about ysh.

2.3.4. Attributes

Understand how to name boolean (true/false) attributes, and the importance of consistency.

 Understand how to name a non-boolean attribute type, and how to declare one (if you need to).

 See 2.8. Attributes (or 'Facts') in the Wysh Developers' Manual.

2.3.5. Constants

Understand what constants ysh can recognise automatically - and how they need to be named.

 See 2.9. Constants in the Wysh Developers' Manual.

2.3.6. Q&A dialogues

Understand how ysh generates dialogues, and how you may need to occasionally teach it about a new verb using the VERBS declaration . For extensive examples of the use of VERBS declarations, see the Copyright and Privacy rulebases in 1. above.

 See Generating questions and explanations in the Wysh Developers' Manual.

 Don't bother with your own attribute translations (p30) unless you have to.

2.3.7. Named subjects

This has been covered adequately above, but it is important that named subject be used well and extensively.

 See 3.2. Named subjects - names of people and things in the Wysh Developers' Manual.

2.3.8. Goals

Understand what goal rules are (they appear as choices at the start of a wysh consultation), and why you need to give them understandable names.

 See 4.2. Goals - LISTED rules and GOAL rules in the Wysh Developers' Manual.

2.3.9. Types of rules

You will usually only need RULE and GOAL rules, but there are other types.

 See 4.4. Types of rules in the Wysh Developers' Manual.

2.3.10. Statements

You need to know how to use IF-THEN, IF-THEN-ELSE and ONLY IF statements, and the differences between them (eg the difference between how to represent types of legal definitions - inclusive and exclusive).

 Assertions and assignments (ASSERT and IS statements) are sometimes useful.

 DETERMINE statements should be avoided, as they destroy the declarativce nature of the rulebase. Ditto for CALL statements.

 See 4.5. Statements in the Wysh Developers' Manual.

2.3.11. Date and number operators

These are only needed if you need to compare dates or amounts, or perform operations on them.

 See 4.6. Expressions - the use of operators in the Wysh Developers' Manual. for these and the other operators listed below.

2.3.12. AND, OR and WITH operators

Understand the limits on how AND and OR operate, and how the more complex operators can overcome these limits if needed.

 Use the AND/OR operator instead of BEGIN-END operators.

2.3.13. Read the style guidelines!

You will save yourself a lot of problems if you understand these guidelines - their overall message is `keep it simple and modular'.

 See 4.7. Some style guidelines for Wysh applications in the Wysh Developers' Manual.


[Previous] [Next] [Title]