edu.cs.ai.kreator.parser.groundatom
Class QueryAndGroundAtomParsingFacility

java.lang.Object
  extended by edu.cs.ai.kreator.parser.groundatom.QueryAndGroundAtomParsingFacility

public class QueryAndGroundAtomParsingFacility
extends java.lang.Object


Field Summary
static org.apache.log4j.Logger LOG
           
 
Constructor Summary
QueryAndGroundAtomParsingFacility()
           
 
Method Summary
static LanguageFactory constructLanguageFactoryFromGroundAtomExpressions(java.io.File groundAtomFile)
          Creates a LanguageFactory which contains the predicates and constants parsed from a ground atom expressions file (for details see parseGroundAtomExpressions(File, LanguageFactory)).
static LanguageFactory constructLanguageFactoryFromGroundAtomExpressions(java.lang.String groundAtomString)
          Creates a LanguageFactory which contains the predicates and constants parsed from a ground atom expressions string (for details see parseGroundAtomExpressions(String, LanguageFactory)).
static java.util.List<AtomExpression> parseGroundAtomExpressions(java.io.File groundAtomFile, LanguageFactory langFactory)
          Parses several ground atom expressions from a file.
static java.util.List<AtomExpression> parseGroundAtomExpressions(java.lang.String groundAtomString, LanguageFactory langFactory)
          Parses several ground atom expressions from a string.
static java.util.List<Query> parseQueries(java.io.File queriesFile, LanguageFactory langFactory)
          Parses a file containing a query in each line.
static java.util.List<Query> parseQueries(java.lang.String queriesString, LanguageFactory langFactory)
          Parses a string containing multiple queries separated by a newline.
static Query parseQuery(java.lang.String queryString, LanguageFactory langFactory)
          Parses a query in KReator's unified-syntax from a string i.e. a querying atom expression (possibly) conditioned by several evidence atoms expressions, whereas the constants must begin with a lower-case character.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.log4j.Logger LOG
Constructor Detail

QueryAndGroundAtomParsingFacility

public QueryAndGroundAtomParsingFacility()
Method Detail

parseQuery

public static Query parseQuery(java.lang.String queryString,
                               LanguageFactory langFactory)
                        throws ParsingException
Parses a query in KReator's unified-syntax from a string i.e. a querying atom expression (possibly) conditioned by several evidence atoms expressions, whereas the constants must begin with a lower-case character. The "?-" at the beginning of the query string and the evidence part "| ..." are both optional.

Examples:
"alarm(james) | neighborhood(james)=average";
"alarm(james) | lives_in(james,austin), !tornado(austin)"
"?- cold(arne)=true | contact(arne, bianca)=true, cold(bianca)=false".

Parameters:
queryString - a query string in KReator's unified-syntax
langFactory - the LanguageFactory that defines the predicates and constants, etc. used in the query
Returns:
a Query object representing the supplied query string
Throws:
ParsingException

parseQueries

public static java.util.List<Query> parseQueries(java.io.File queriesFile,
                                                 LanguageFactory langFactory)
                                          throws java.io.IOException,
                                                 ParsingException
Parses a file containing a query in each line. For details about the syntax of a query see parseQuery(String, LanguageFactory).

Parameters:
queriesFile - a file with queries in KReator's unified-syntax in each line
langFactory - the LanguageFactory that defines the predicates and constants, etc. used in the queries
Returns:
a list of Query objects parsed from the supplied file
Throws:
IOExceptionp
ParsingException
java.io.IOException

parseQueries

public static java.util.List<Query> parseQueries(java.lang.String queriesString,
                                                 LanguageFactory langFactory)
                                          throws ParsingException
Parses a string containing multiple queries separated by a newline. For details about the syntax of a query see parseQuery(String, LanguageFactory).

Parameters:
queriesString - a string with a queries in KReator's unified-syntax separated by newlines
langFactory - the LanguageFactory that defines the predicates and constants, etc. used in the queries
Returns:
a list of Query objects parsed from the supplied multi-line string
Throws:
IOExceptionp
ParsingException

parseGroundAtomExpressions

public static java.util.List<AtomExpression> parseGroundAtomExpressions(java.io.File groundAtomFile,
                                                                        LanguageFactory langFactory)
                                                                 throws java.io.IOException,
                                                                        ParsingException
Parses several ground atom expressions from a file. For details about the syntax of ground atom expressions see the examples in parseQuery(String, LanguageFactory). The expressions can by separated by "," or ";" and/or by a newline. The LanguageFactory which has to be supplied can be created by calling constructLanguageFactoryFromGroundAtomExpressions(File).

Parameters:
groundAtomFile - a file with several ground atom expressions in KReator's unified-syntax
langFactory - the LanguageFactory that defines the predicates and constants, etc. used in the expressions
Returns:
a list of AtomExpression objects parsed from the supplied file
Throws:
java.io.IOException
ParsingException

parseGroundAtomExpressions

public static java.util.List<AtomExpression> parseGroundAtomExpressions(java.lang.String groundAtomString,
                                                                        LanguageFactory langFactory)
                                                                 throws ParsingException
Parses several ground atom expressions from a string. For details about the syntax of ground atom expressions see the examples in parseQuery(String, LanguageFactory). The expressions can by separated by "," or ";" and/or by a newline. The LanguageFactory which has to be supplied can be created by calling constructLanguageFactoryFromGroundAtomExpressions(String).

Parameters:
groundAtomString - a string with several ground atom expressions in KReator's unified-syntax
langFactory - the LanguageFactory that defines the predicates and constants, etc. used in the expressions
Returns:
a list of AtomExpression objects parsed from the supplied string
Throws:
ParsingException

constructLanguageFactoryFromGroundAtomExpressions

public static LanguageFactory constructLanguageFactoryFromGroundAtomExpressions(java.io.File groundAtomFile)
                                                                         throws java.io.IOException,
                                                                                ParsingException
Creates a LanguageFactory which contains the predicates and constants parsed from a ground atom expressions file (for details see parseGroundAtomExpressions(File, LanguageFactory)). Since the ground atom expressions contain no type information, all constants will be from the default type.

Parameters:
groundAtomFile - a file with several ground atom expressions in KReator's unified-syntax
Returns:
a LanguageFactory which contains the predicates and constants parsed from a ground atom expressions
Throws:
java.io.IOException
ParsingException

constructLanguageFactoryFromGroundAtomExpressions

public static LanguageFactory constructLanguageFactoryFromGroundAtomExpressions(java.lang.String groundAtomString)
                                                                         throws java.io.IOException,
                                                                                ParsingException
Creates a LanguageFactory which contains the predicates and constants parsed from a ground atom expressions string (for details see parseGroundAtomExpressions(String, LanguageFactory)). Since the ground atom expressions contain no type information, all constants will be from the default type.

Parameters:
groundAtomString - a string with several ground atom expressions in KReator's unified-syntax
Returns:
a LanguageFactory which contains the predicates and constants parsed from a ground atom expressions
Throws:
java.io.IOException
ParsingException