Jump to content

OpenCyc Ontology UDF


Recommended Posts

So I've been poking around with learning how to use OpenCyc for a long time, but never got motivated to do it. Since I've gotten so into AutoIt, and since learning how to do something like this in another language would have taken a lot of time, I finally decided that I'd just bite the bullet and create a UDF that utilized the OpenCyc transport layer.

So, without further ado...

OpenCyc is:

# The entire Cyc ontology containing hundreds of thousands of terms, along with millions of assertions relating the terms to each other, forming an upper ontology whose domain is all of human consensus reality.

# English strings corresponding to all concept terms, to assist with search and display.

# A compiled version of the Cyc Inference Engine and the Cyc Knowledge Base Browser.

# Documentation and self-paced learning materials to help users achieve a basic- to intermediate-level understanding of the issues of knowledge representation and application development using Cyc.

# A specification of CycL, the language in which Cyc (and hence OpenCyc) is written.

# A specification of the Cyc API for application development.

# NEW! Links between Cyc concepts and WordNet synsets.

What that means for a developer:

Common sense reasoning.

-If you need an application to distinguish between objects and concepts, and you need it to happen dynamically and with full justification along the way, OpenCyc provides that level of sophistication.

Natural Language processing.

-You can utilize the structured knowledgebase to allow your applications to quickly get at word definitions, sentence structures, and other language related attributes.

And finally: the UDF.

And a very simple example script:

#include "openCyc.au3"
HotKeySet('a', '_Test'); Set up an A hotkey to send the message
HotKeySet('{ESC}', '_Close'); Call a close function to close the script when someone presses escape

$Connection = _cycConnect()

While 1


Func _Test()
    MsgBox(0, "OpenCyc Message", _fiFind('"'& "Thing" & '"'))

Func _Close()
    Exit; Close the script

How to use:

Download OpenCyc

Unzip the OpenCyc folder somewhere accessible, but not in your way.

Navigate to "opencyc-1.0.2-Win32\opencyc-1.0\scripts"

Run run-cyc.bat

This part will take time. Cyc will build an initial "world", which is the sum of all it's interrelated concepts and relations. It takes probably 10-20 minutes to load the first time. After that, it will take only seconds to load up.

Once the world is loaded, you will see "CYC(1)" in the command prompt. This means the server is ready for action.

Run the example script and press the A key.

Voila! You've successfully started learning how to use one of the most powerful and flexible inference engines.


Most functions are not yet up to speed on optional parameters. Where you find in the Cyc documentation the ability to pass optional parameters, you will most likely not be able to until I get around to fixing this.

Otherwise, all functions are documented here: http://www.opencyc.org/doc/opencycapi

The wrapped functions are simply the NAME-OF-THE-FUNCTION written in camel case, AutoIt style, nameOfTheFunction().

All parameters are passed as strings. Some formatting of the strings you pass as parameters will probably be required. Check OpenCyc docs for examples :)

That's it! I'll be posting updates when I can, and more examples of how to use it, and the powerful capabilities it can add to your applications.

Link to comment
Share on other sites

Here's a list of all 449 functions:


































































































































































































































































































































































































































































Edited by Jrowe
Link to comment
Share on other sites


I think a bit more of a detailed example on how to use this might help.

Looks good though, and with a bit more of an explanation i think this may be very helpful :)

My scripts:AppLauncherTRAY - Awesome app launcher that runs from the system tray NEW VERSION! | Run Length Encoding - VERY simple compression in pure autoit | Simple Minesweeper Game - Fun little game :)My website

Link to comment
Share on other sites

This is rough, but lets you query whether the contents of InputBox1 belong to any of the same groups as InputBox2

(Is a dog a person comes back true because persons are humans are mammals are animals and dogs are animals. I'll be refining this, lol.)

#include <GUIConstants.au3>

#include "openCyc.au3"

#include <GuiEdit.au3>

#Region ### START Koda GUI section ### Form=


$Group1 = GUICtrlCreateGroup("Group1", 8, 8, 617, 289)


$Edit1 = GUICtrlCreateEdit("", 40, 48, 401, 89)

GUICtrlSetData(-1, "Edit1")

$List1 = GUICtrlCreateList("", 480, 48, 121, 240)

$Label1 = GUICtrlCreateLabel("List of Constants", 496, 24, 82, 17)

$Label3 = GUICtrlCreateLabel("Query Results", 200, 24, 70, 17)

$Button1 = GUICtrlCreateButton("ISA?", 40, 154, 83, 17, 0)

$Input1 = GUICtrlCreateInput("Input2", 272, 152, 121, 21)

$Input2 = GUICtrlCreateInput("Input1", 136, 152, 121, 21)

GUICtrlCreateGroup("", -99, -99, 1, 1)


#EndRegion ### END Koda GUI section ###

;connect to the local running instance of OpenCyc, or use _cycConnect("IP Address", "Port Number) if you know the

;IP and Port for a remote server

$Connection = _cycConnect()

While 1

$nMsg = GUIGetMsg()

Switch $nMsg




Case $Button1

GUICtrlSetData($Edit1, _CycQueryISA(GuiCtrlRead($Input2), GuiCtrlRead($Input1)))


For $Line_Count = 1 To _GUICtrlEdit_GetLineCount ($Edit1)

_GUICtrlEdit_Scroll ($Edit1, $SB_LINEDOWN)



Func _CycQueryISA($FirstTerm, $SecondTerm)

$FormFirstTerm = "#$" & $FirstTerm

$FormSecondTerm = "#$" & $SecondTerm

$Result = _isa($FormFirstTerm, $FormSecondTerm)

If StringLeft($Result,3) = "200" Then

$Answer = "Yes! A " & $FirstTerm & " is a " & $SecondTerm & "!"


$Answer = "Nope! A " & $FirstTerm & " is not a recognized " & $SecondTerm & "!"


Return $Answer


I've got some studying to do, and tutorials to go back through, and I'll try to keep this updated as I move along. However, I've got the commands working and an application sending data back and forth between itself and openCyc. The largest hurdle has been jumped.

Link to comment
Share on other sites

There aren't any limitations that I've encountered. I've seen some very creative uses, and read some of the whitepapers on things that just astounded me. Granted, this is just a foundation for more focussed applications, but it can do some pretty amazing things by itself.


I'm trying to work out how to integrate something like this into the AutoIt AIML parser. Something like this could make intelligent desktop agents easily within the reach of average AutoIt users.


Something like this could be applied to AutoIt output, after an ontology for the language has been mapped into the knowledgebase. Combine with an intelligent agent, and you could end up with something that can produce applications based on conversational specifications. There are thousands of algorithmic templates already waiting to be parsed and exploited on the AutoIt forums.

"Hey, Au3Agent. I'd like an AutoIt script with which I could drag files from my desktop onto a taskbar icon and have them uploaded to an ftp target, which I would specify in an input box. I want it in a GUI 100 by 100 pixels, with an upload button, a label with the selected file's path and name, and a cancel upload button. Write it to a file called myFTP.au3 in your scripts directory."

And last, but not least: http://www.cyc.com/doc/white_papers/Arthur_Thesis.pdf

This shows the ease with which you can incorporate outside corpora and retrieve useful statistical and relational data.

Artificial intelligence is a very specialized field. You'll find incredible solutions to almost any individual problem that's out there, but nobody has yet managed to tie everything together to achieve a 'real' intelligence. Maybe, though, if it becomes less specialized, and easier to use, then people who otherwise wouldn't be able to utilize what's out there can let their own intelligence provide solutions to the problems of General Artificial Intelligence.

IMHO, creativity is the only limitation. :)

There will be updates to the script in a few hours. Right now I'm studying how best to attack the problems that are happening. At the very least, I'll have a generic function system fully working.

Link to comment
Share on other sites

Once you entered the entire language into the ontology, and algorithmic concepts (think abstracted versions of UDFs,) then it could generate AutoIt scripts based on user input. It's a large task, but not a monumental one.

Link to comment
Share on other sites

It looks like the latest release of openCyc is missing lots of API functions. I have to wait til I run into one of the Cyc people and I'll see what happens from there.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...