--------------------------------------------------------------------- Jkp A Java KIF Parser version 1.0 http://www.cs.umbc.edu/~xluan1/jkp ----------------------------------------------------------------------------- Last Updated: March 7, 1997 Latest Version: jkp1.0 --------------------------------- Contents: 1. General Description 2. Checklist and installation guide 3. Use JKP from your java code 4. SKIF specification(informal) -------------------------------- 1. General Description: JKP, the Java Kif Parser, is part of my term project. Current version of this parser is aimed at SKIF, a subset of KIF (Knowledge Interchange Format). This subset is sufficent to support Horn-Clause-Based logical inference, which also meets the need of my project. I may extend it to handle the whole KIF when I feel like to do so, or if someone needs such a "compete" parser. A few works about KIF: KIF(Knowledge Interchange Format s a formal language for the interchange of knowledge among disparate computer programs (written by different programmers, at different times, in different languages, and so forth). For more details about KIF, check out http://logic.stanford.edu/kif/kif.html. When a KIF sentence is parsed with jkp, the result is a Java Kif object, which is an internal represention of the sentence. This internal representation reveals the logical structure of the corresponding sentence and is ready for further manipulation, for example, converting to another logical language and then feeding it to the corresponding inference engine. If someone wants to write a inference engine for KIF, that would be better. This version of jkp has been experimentally integrated with the UMBC CIIMPLEX project demonstration, and works just fine. For simplicity, we select a subset of KIF. See next section for a detailed decription of SKIF. 2. Checklist and installation guide . download the tar file jkp.tar.Z . uncompress jkp.tar.Z . tar xvf jkp.tar ---- it will create three direcotries: - jbf, the Java Bison Parser Runtime (package name: jbf) - regexp, a regular expression package used by jbf - jkp, the jkp package. - jkp/doc is the class documentation in HTML format. . add proper path to CLASSPATH. E.g: you install the package in a directory called ".../parser", that is, jkp, jbf and regexp are all subdirectories of parser, then add the path parser (full path) to CLASSPATH. . The package has been compiled, ready to use. . A document in HTML is in the directory jkp/doc, you can read it with a web browser. . To run an example: java jkp.Main < test jkp.Main.java is also a good example on how to use this parser in your Java code. 3. Use JKP from your java code See jkp/Main.java for an example. ---- further document will come soon. One thing need to point out is that although we provide a method objType() in the class KifObj to return the type ID of a kif object, you can of course use the operator InstanceOf to determine exactly what kind of KIF object you get after the parsing. E.g, KifObj obj = KifParser.parse(kifString); if (obj InstanceOf KifConjunction) ... ------------- Below is SKIF specification ------------------------ 4. SKIF, a Subset of KIF SKIF is a necessary subset of KIF to support Horn clause based logical inference. An informal specification is given below: Some notations ============== [] denotes zero or one * denotes zero or more + denotes one or more I. Forms /* The top-level entities */
::= II. Sentences /* Similar to FOPL sentences. */ ::= | | ::= true | false ::= ( *) /* similar to FOPL predicates */ ::= (not ) | (and +) | (or +) | (=> + ) | (<= +) | (<=> ) III. Terms ::= | | | | | ::= ( *, []) IV. Lexemes /* Basic lexical elements */ ::= | | \ /* any non-nomralcharacter can be included in a word if it is preceded by the "escape" character '\' */ ::= ? /* regular vairables */ ::= @ /* sequence variables for functions and relations of varying length argument lists */ ::= "" ::= | | \ ::= every character except " and \ /* quotable is a string of strchars. Every character, except " and \, is a strchar. Use \" and \\ to include " and \ in quotaion marks. */ ::= any member of except variables(starting with ? or @) and those reserved. ::= [+|-]+ :: = [+|-]*.+ | [+|-]+.* ::= [(E|e)] | (E|e) /* reserved words: */ listof, quote, if, cond, not, and, or, forall, exists, defobject, deffunction, defrelation, deflogical There are four categories of constants. KIF does not provide syntactic specifications to differentiate them. Instead, users must make the choices and use these constant consistently throughout. The four categories are: ::= /* for object names */ ::= /* for function names */ ::= | /* for relation or predicate names */ ::= = | \= | < | > | =< | >= ::= /* unclear */ V. Alphabet /* ASCII codes */ ::= | | | ::= A | B | C | ... | Z | a | b | c | ... | z | 0 | 1 | 2 ... | 9 ::= < | > | = | + | - | * | / | & | ^ | ~ | _ | @ | $ | & | : | . | ! | ? ::= white space /* used to separate lexemes, otherwise ignored */ ::= any ASCII code other than normal, special and white. ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9