Skip navigation links
Cyc Core API

Package com.cyc.kb

Interfaces for manipulating CycL-based java objects, both for the purpose of making assertions and for retrieving terms and values via simple queries.

See: Description

Package com.cyc.kb Description

Interfaces for manipulating CycL-based java objects, both for the purpose of making assertions and for retrieving terms and values via simple queries.

Because methods accessing a Cyc server may not return instantaneously, developers are strongly advised to avoid using KB API methods inside AWT threads (or any threads on which a UI is critically dependent).

The underlying API throws IOException and UnknownHostExeception to indicate some arbitrary IO issue and Cyc server not being at the specified location respectively. In the KB API both of these exceptions are wrapped inside a KbRuntimeException throughout the API and the cause field is set appropriately.

The main uses of the KB API fall into two broad categories: (a) making terms and assertions, and (b) running queries. You may get terms, assertions, and queries via the static #get(...) and #findOrCreate(...) factory methods on the interfaces themselves; sub-classes also have such factory methods. These factory methods will retrieve the relevant object from the KB, and can be set to create the object on the Cyc server if it doesn't already exist on the server. E.g.:

 Context.get("SomeMt");
 
 KbTerm.findOrCreate("SomeTerm");
 
 Sentence.get(predicate, arg1, arg2);
 
 Assertion.get("someassertionid");
 
 Query.get(sentence, context);
 

Once the objects exists, the #get(...) and #findOrCreate(...) methods on Assertion, Fact, and Rule can be used to create the actual assertions. The KB API generally allows the creation and retrieval of Cyc KB objects (KbIndividuals, KbCollections, Facts, etc.) from a variety of forms including their string representations, their IDs, and from the objects that will comprise them. The string-based factory methods in Assertion and its sub-class factories are a convenient way to create assertions without needing to first create the KbCollection and KbIndividual objects, but they do require correct syntax, and the terms must already exist on the Cyc server.

The API provides many methods that take Strings as inputs. This leads to most methods having CreateException and KbTypeException. To limit the types of exceptions in method signatures, we wrap them in IllegalArgumentException. This is done only to the methods where the focus is not the creation of a new term.

All factory methods throw exceptions as CreateException, KbTypeException, or a subclass of those exceptions.

In many cases, the KB API includes methods that specify a context and similar methods that don't require a context parameter. Default contexts for asserting and querying can be set on a thread-by-thread basis using SessionOptions.setDefaultContext(com.cyc.kb.DefaultContext).

Skip navigation links
Cyc Core API

Copyright © 2015–2018 Cycorp, Inc. All rights reserved.