|
JTP API Documentation | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.beans.beancontext.BeanContextChildSupport | +--java.beans.beancontext.BeanContextSupport | +--jtp.context.BasicReasoningContext | +--jtp.frame.listen.Context | +--jtp.context.rdf.RDFReasoningContext
Field Summary | |
protected IterativeDeepening |
idr
|
static String |
RDF_REF
|
static URL |
RDF_RULES
|
static URL |
RDF_TRIPLES
|
Fields inherited from class jtp.frame.listen.Context |
ONE_VALUE, TRIPLE, VALUE_LINK, VC |
Fields inherited from class jtp.context.BasicReasoningContext |
tracer |
Fields inherited from class java.beans.beancontext.BeanContextSupport |
bcmListeners, children, designTime, locale, okToUseGui |
Fields inherited from class java.beans.beancontext.BeanContextChildSupport |
beanContext, beanContextChildPeer, pcSupport, rejectedSetBCOnce, vcSupport |
Fields inherited from interface java.beans.beancontext.BeanContext |
globalHierarchyLock |
Fields inherited from interface java.beans.DesignMode |
PROPERTYNAME |
Constructor Summary | |
RDFReasoningContext()
|
Method Summary | |
ReasoningStepIterator |
ask(String query)
Submits a KIF-formatted query. |
ReasoningStepIterator |
ask(URL premise,
String query)
Premise is loaded with loadKB(URL) , and query is then passed to ask(String) . |
int |
assertKifString(String assertion)
Deprecated. Use tellKifString(String) . |
int |
assertString(String assertion)
Deprecated. Use tellString(String) . |
KIF2CNF |
getKifParser()
|
com.hp.hpl.jena.rdf.model.Model |
getModelForAssertions(Snapshot snap)
|
jtp.fol.rdf.RDFParser |
getRDFParser()
|
ReasoningStepIterator |
inconsistencies()
|
void |
loadKB(URL url)
Loads KBs with an RDF parser. |
void |
loadKB(URL url,
FirstOrderLogicParser p)
Loads KBs with the specified parser. |
void |
loadKB(URL url,
URL publicLocation,
FirstOrderLogicParser p)
Loads KBs with the specified parser. |
void |
loadKifKB(URL url)
Loads url with a KIF parser. |
void |
loadRDFKB(com.hp.hpl.jena.rdf.model.Model model,
URL publicLocation)
Loads a KB stored in a Jena model. |
void |
loadRDFKB(URL url,
URL publicLocation)
Loads content of RDF KBs. |
void |
setMaxDepth(int m)
Sets both the telling and asking systems' maximum depth . |
void |
setUp()
|
int |
tell(Object assertion)
Processes the assertion (without parsing it as in tellString(String) ) as well as forward-chained information. |
int |
tellKifString(String assertion)
Stores the assertion as well as its forward-chained information. |
int |
tellString(String assertion)
Stores the triples represented in a RDF-formatted string as well as forward-chained information. |
int |
tellString(String assertion,
FirstOrderLogicParser parser)
Stores the triples represented in the string as well as forward-chained information. |
int |
tellString(String assertion,
URL location)
Stores the triples represented in a RDF-formatted string as well as forward-chained information. |
int |
tellString(String assertion,
URL location,
FirstOrderLogicParser parser)
Stores the assertion as well as its forward-chained information. |
void |
untell(Object assertion)
Attempts to untell assertion via the undo manager. |
void |
untellString(String assertion)
|
void |
writeRDF(Writer writer,
Snapshot snap,
String baseUri,
Map prefixes)
A method for writing a portion of JTP's KB in RDF/XML format. |
Methods inherited from class jtp.frame.listen.Context |
addLink, addListener, addRule, addRule, createContentHolders, createEmptyContentHolders, getDamlParser, getFrameKB, loadSpecs, loadSpecs, orderLiterals, setFrameKB |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.beans.beancontext.BeanContextChild |
addPropertyChangeListener, addVetoableChangeListener, getBeanContext, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext |
Methods inherited from interface java.util.Collection |
equals, hashCode |
Field Detail |
public static final URL RDF_RULES
public static final URL RDF_TRIPLES
public static final String RDF_REF
protected IterativeDeepening idr
Constructor Detail |
public RDFReasoningContext()
Method Detail |
public jtp.fol.rdf.RDFParser getRDFParser()
public KIF2CNF getKifParser()
getKifParser
in class Context
public void setMaxDepth(int m)
BasicReasoningContext
depth
.
Fires a PropertyChangeEvent.
setMaxDepth
in class BasicReasoningContext
m
- maximum depth of inferencepublic void setUp()
setUp
in class Context
public int assertKifString(String assertion) throws ReasoningException
tellKifString(String)
.
ReasoningException
public int tellKifString(String assertion) throws ReasoningException
assertion
- a KIF-formatted string to assert.
ReasoningException
public int assertString(String assertion) throws ReasoningException
tellString(String)
.
assertString
in class BasicReasoningContext
ReasoningException
public int tellString(String assertion) throws ReasoningException
tellString
in class BasicReasoningContext
assertion
- a RDF-formatted string. The string must be enclosed by <rdf:RDF> </rdf:RDF> tags.
ReasoningException
public int tellString(String assertion, URL location) throws ReasoningException
tellString
in class BasicReasoningContext
assertion
- a RDF-formatted string. The string must be enclosed by <rdf:RDF> </rdf:RDF> tags.location
- a URL that should be used to resolve namespaces
ReasoningException
BasicReasoningContext.tellString(String)
public int tellString(String assertion, FirstOrderLogicParser parser) throws ReasoningException
parser
is used to parse
the string into CNFSentence
s.
assertion
- a string to assertparser
- a parser that can parse assertion
ReasoningException
public int tellString(String assertion, URL location, FirstOrderLogicParser parser) throws ReasoningException
assertion
- a string to assert.location
- a URL that should be used to resolve namespacesparser
- a parser that can parse assertion
ReasoningException
public int tell(Object assertion) throws ReasoningException
tellString(String)
) as well as forward-chained information.
tell
in class BasicReasoningContext
assertion
- an Object that can be handled by some telling reasoner, e.g., Literal
ReasoningException
public void loadKB(URL url, URL publicLocation, FirstOrderLogicParser p) throws ReasoningException, IOException
url
- a URL that points to a KBpublicLocation
- if the language that you are using relies on the base URI of the document to determine the fully-qualified names of objects in the document, this url will be used as the base URIp
- a Parser that can parse the KB's format
ReasoningException
IOException
public void loadKB(URL url, FirstOrderLogicParser p) throws ReasoningException, IOException
url
- a URL that points to a KBp
- a Parser that can parse the KB's format
ReasoningException
IOException
public void loadRDFKB(URL url, URL publicLocation) throws ReasoningException, IOException
publicLocation
will be used as the
base URL for all relative elements.
url
- a URL that points to a KB in RDF formatpublicLocation
- if the language that you are using relies on the base URI of the document to determine the fully-qualified names of objects in the document, this url will be used as the base URI
ReasoningException
IOException
public void loadRDFKB(com.hp.hpl.jena.rdf.model.Model model, URL publicLocation) throws ReasoningException, IOException
model
- the model to load.
ReasoningException
IOException
public void loadKB(URL url) throws ReasoningException, IOException
loadKB
in class BasicReasoningContext
url
- a URL that points to a KB in RDF format
ReasoningException
IOException
public void loadKifKB(URL url) throws ReasoningException, IOException
ReasoningException
IOException
public ReasoningStepIterator ask(URL premise, String query) throws ReasoningException, IOException
loadKB(URL)
, and query is then passed to ask(String)
.
premise
- a RDF KB containing data to be asserted.query
- a KIF-formatted query string.
ReasoningStepIterator
that contains results of
asking query
ReasoningException
IOException
ask(String)
public ReasoningStepIterator ask(String query) throws ReasoningException
The query must be a conjunction or disjunction of positive literals. The literals should usually be triples. The query may contain variables. An answer will be returned if bindings can be found for all variables in the query. Here are some examples:
(|http://www.w3.org/1999/02/22-rdf-syntax-ns#|::type ?x |http://www.daml.org/2001/03/daml+oil-ex#|::|Person|) (and (|http://www.w3.org/2000/01/rdf-schema#|::|subClassOf| |http://www.daml.org/2001/03/daml+oil-ex#|::|MarriedPerson| ?restr) (|http://www.daml.org/2001/03/daml+oil#|::|onProperty| ?restr ?prop)) (or (|http://www.w3.org/1999/02/22-rdf-syntax-ns#|::type ?x |http://www.daml.org/2001/03/daml+oil-ex#|::|TallThing|) (|http://www.w3.org/1999/02/22-rdf-syntax-ns#|::type ?x |http://www.daml.org/2001/03/daml+oil-ex#|::|Person|))
Note that the non-variables in the query are symbols of the form package::name. Symbol names will be downcased unless they are escaped as above. Queries can contain integers, floats, and strings.
If you wish to use a
variable for the relation (property) in a literal, then you
should use the holds
construct. E.g.,
(holds ?prop |http://www.daml.org/2001/03/daml+oil-ex#|::|HumanBeing| |http://www.daml.org/2001/03/daml+oil-ex#|::|Person|)
Bindings for variables can only be constants in the knowledge base. Here is an example of a provable query which will fail in the DamlReasoningContext because a binding cannot be provided for the variable. Note that an abbreviated syntax is used for this example. If the KB contains only these statements:
(rdfs:subClassOf Person Restr_00) (daml:onProperty Restr_00 father) (daml:cardinality Restr_00 1) (rdf:type Fred Person)and the query is:
(father Fred ?x)An answer will not be returned even though it is provable from the KB that Fred has a father because there is no constant to which ?x can be bound.
ask
in class BasicReasoningContext
query
- the query string
ReasoningStepIterator
containing proofs (if any)
of the query
ReasoningException
public void untellString(String assertion) throws CannotUndoException, ReasoningException
CannotUndoException
ReasoningException
public void untell(Object assertion) throws ReasoningException
BasicReasoningContext
assertion
via the undo manager.
After the assertion
has been untold, the assertions that needed to be retold will all be
wrapped in a new MultipleTellEdit, so calling BasicReasoningContext.undo()
will
perform differently after an untell than it would have before the
untell.
Executing SnapshotUndoManager.revertToSnapshot(Snapshot)
will
still work assuming the user took the Snapshot
before
the user originally told the assertion.
untell
in class BasicReasoningContext
assertion
- a previously asserted object.
ReasoningException
public void writeRDF(Writer writer, Snapshot snap, String baseUri, Map prefixes)
writer
- a Writer to which the RDF file will be writtensnap
- a snapshot of the KB taken at some previous pointbaseUri
- the base URI for relative URI calculations. Note: There should probably not be a '#' on the end.prefixes
- a map in which the keys are prefixes and the values are namespaces. Both prefixes and namespaces should be Strings. Unfortunately, there's not a way to specify a default namespace; an empty string as a prefix causes unexpected results. Map can be null. Note: There probably should be '#' characters on the end of the namespaces.public com.hp.hpl.jena.rdf.model.Model getModelForAssertions(Snapshot snap)
snap
- a snapshot of the KB taken at some previous point
public ReasoningStepIterator inconsistencies()
|
JTP API Documentation | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |