Details of the second lab: rule system

Allikas: Lambda
Redaktsioon seisuga 20. märts 2009, kell 09:54 kasutajalt Tammet (arutelu | kaastöö) (→Suggestions and links)
Mine navigeerimisribale Mine otsikasti

Main goal of the lab: extending the dataset obtained from rdfa by automatically derived context-based information.

The lab will build upon your first rdfa lab.

What will you have to do

Concretely, you will have:

  • Look at your rdfa pages and invent/create sensible small rule files in the Otter syntax for deriving new data from physically present rdfa data.
    • It may happen that the rdfa pages from the first lab do not contain really suitable/interesting data for this. In that case, create new pages.
    • The rdfa pages should indicate (by having a corresponding link in the rdfa data) which rule set should be used. You should have at least two different rdfa pages and two different rulesets, one for each page.
    • The rule file should be such that no contradiction arises and the set of derived facts is still maintainable (not millions of new facts).
  • Write a program which takes your first lab output, finds an indicated rule file and builds a new Otter syntax file containing both rules and the data obtained from the rdfa page.
  • Then let the same program call Otter with the newly built file and send the result to a result file.
  • Write a program which takes the output file, parses out the derived facts (fact has just one atom and no variables) and adds these to the original rdfa-parsed dataset.
  • Finally print out the extended dataset: the original facts and newly derived facts from this dataset.

You may write just one program for all these tasks or several different. In the latter case you will also have to write a "master" program (as a shell script or bat file, for example) calling these subprograms.

The final resulting program should take a page url or file name as a single input and produce a list of all found and derived facts as output.

Suggestions and links

How to prepare the input file: probably the simplest way is to prepare separate temporary files for rdfa output in otter format, the otter file header, the otter file bottom part and the rule file. Then concatenate these files together.

It is significantly harder (and unnecessary) to attempt to create a full otter format input string in one program, than it is to create separate files and concatenate them.

As said, probably the simplest way to create the required system is to write several small programs/scripts for subtasks and then write a master shell script or bat file calling all these programs one by one and using their output files as input to following programs.

How to get the derived facts from the Otter output file? Just look for rows with a string indicating that this is a derived fact (for example, rows with *KEPT*) and cut out the relevant part. Pure string manipulation, in other words.

Otter prover:

Download, experiment, then read documentation:

Tiny example otter input with rdf data and a rule