Sign in to follow this  
Followers 0
JRowe

OpenCyc Ontology UDF

11 posts in this topic

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

WEnd

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

Func _Close()
    _cycClose()
    Exit; Close the script
EndFunc

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.

SOME NOTES:

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Here's a list of all 449 functions:

CODE
_constantP()

_constantExternalId()

_constantInternalId()

_constantName()

_findConstant()

_findConstantByExternalId()

_findConstantByInternalId()

_createConstant()

_findOrCreateConstant()

_renameConstant()

_uniquifyConstantName()

_removeConstant()

_constantCount()

_validConstantNameChar()

_validConstantName()

_constantCompleteExact()

_constantComplete()

_constantApropos()

_nartP()

_nartId()

_findNartById()

_nartHlFormula()

_nartElFormula()

_removeNart()

_nartCount()

_fortP()

_elFortP()

_fortElFormula()

_removeFort()

_fortCount()

_assertionP()

_assertionId()

_assertionCnf()

_assertionFormula()

_assertionIstFormula()

_assertionMentionsTerm()

_assertionMt()

_assertionDirection()

_forwardAssertion()

_backwardAssertion()

_directionP()

_codeAssertion()

_assertionTruth()

_assertionHasTruth()

_truthP()

_assertionStrength()

_assertionHasMetaAssertions()

_findAssertionById()

_findAssertion()

_findAssertionAnyMt()

_findAllAssertions()

_findGaf()

_findGafAnyMt()

_findAllGafs()

_getAssertedArgument()

_assertedAssertion()

_deducedAssertion()

_assertionElIstFormula()

_assertionHasDependentsP()

_assertionCount()

_negated()

_negate()

_clauseP()

_senseP()

_makeClause()

_negLits()

_posLits()

_clauseEqual()

_emptyClause()

_emptyClause()

_clauseLiteral()

_clauseWithoutLiteral()

_groundClauseP()

_cnfP()

_gafCnf()

_cnfFormula()

_cnfFormulaFromClauses()

_dnfFormula()

_dnfFormulaFromClauses()

_atomicClauseP()

_hlTermP()

_hlModuleP()

_argumentP()

_assertedArgumentP()

_argumentEqual()

_argumentTruth()

_argumentStrength()

_deductionP()

_deductionId()

_findDeductionById()

_deductionAssertion()

_deductionCount()

_supportP()

_supportModule()

_supportMt()

_supportTruth()

_supportStrength()

_supportSentence()

_hlSupportP()

_makeHlSupport()

_elVar()

_variableP()

_findVariableById()

_variableId()

_defaultElVarForHlVar()

_fullyBoundP()

_variableCount()

_indexedTermP()

_removeTermIndices()

_keyExceptionRuleIndex()

_keyFunctionRuleIndex()

_keyGafArgIndex()

_keyGenlMtRuleIndex()

_keyGenlsRuleIndex()

_keyIsaRuleIndex()

_keyNartArgIndex()

_keyPredicateExtentIndex()

_keyPredicateRuleIndex()

_numExceptionRuleIndex()

_numFunctionExtentIndex()

_numFunctionRuleIndex()

_numGafArgIndex()

_numGenlMtRuleIndex()

_numGenlsRuleIndex()

_numIndex()

_numIsaRuleIndex()

_numMtIndex()

_numNartArgIndex()

_numOtherIndex()

_numPredicateExtentIndex()

_numPredicateRuleIndex()

_relevantNumFunctionExtentIndex()

_relevantNumGafArgIndex()

_relevantNumNartArgIndex()

_relevantNumPredicateExtentIndex()

_mapTerm()

_mapTermSelective()

_mapTermGafs()

_mapMtContents()

_mapMtIndex()

_mapOtherIndex()

_gatherIndex()

_gatherIndexInAnyMt()

_gatherExceptionRuleIndex()

_gatherFunctionExtentIndex()

_gatherFunctionRuleIndex()

_gatherGafArgIndex()

_gatherGenlMtRuleIndex()

_gatherGenlsRuleIndex()

_gatherIsaRuleIndex()

_gatherMtIndex()

_gatherNartArgIndex()

_gatherOtherIndex()

_gatherPredicateExtentIndex()

_gatherPredicateRuleIndex()

_gatherTermAssertions()

_fpredValue()

_fpredValueInMt()

_fpredValueInMts()

_fpredValueInAnyMt()

_fpredValueInRelevantMts()

_predValues()

_predValuesInMt()

_predValuesInMts()

_predValuesInAnyMt()

_predValuesInRelevantMts()

_predRefs()

_predRefsInMt()

_predRefsInMts()

_predRefsInAnyMt()

_predRefsInRelevantMts()

_somePredValue()

_somePredValueInMt()

_somePredValueInMts()

_somePredValueInAnyMt()

_somePredValueInRelevantMts()

_predUVHolds()

_predUVHoldsInMt()

_predUVHoldsInMts()

_predUVHoldsInAnyMt()

_predUVHoldsInRelevantMts()

_predValueTuples()

_predValueTuplesInMt()

_predValueTuplesInMts()

_predValueTuplesInAnyMt()

_predValueTuplesInRelevantMts()

_reflexivePredicate()

_irreflexivePredicate()

_symmetricPredicate()

_asymmetricPredicate()

_antiSymmetricPredicate()

_transitivePredicate()

_relation()

_commutativeRelation()

_commutativeFunction()

_binaryPredicate()

_argnIsa()

_minArgnIsa()

_argnIsaOf()

_argnGenl()

_minArgnGenl()

_argnGenlOf()

_definingDefns()

_necessaryDefns()

_sufficientDefns()

_allSufficientDefns()

_arity()

_resultIsa()

_creator()

_creationTime()

_comment()

_assertedBy()

_assertedWhen()

_reviewer()

_allTermAssertions()

_isaRelevantAssertions()

_assertionsMentioningTerms()

_primitiveCollection()

_predsForPair()

_collectionsCoextensional()

_collectionsDisjoint()

_collectionsIntersect()

_countAllInstances()

_elStrengthP()

_elToHl()

_elToHlQuery()

_assertionElFormula()

_elWffSyntax()

_elWffSyntax+arity()

_ground()

_elFormulaOk()

_elQueryOk()

_diagnoseElFormula()

_minIsa()

_maxNotIsa()

_allIsa()

_unionAllIsa()

_allNotIsa()

_allInstances()

_mapAllIsa()

_anyWrtAllIsa()

_mapAllInstances()

_mapInstances()

_isa()

_isaAny()

_anyIsaAny()

_notIsa()

_instances()

_instances()

_isaSiblings()

_maxFloorMtsOfIsaPaths()

_whyIsa()

_whyNotIsa()

_allInstancesAmong()

_allIsaAmong()

_allIsasWrt()

_instanceSiblings()

_maxInstances()

_minNotInstances()

_notIsaAmong()

_unionAllInstances()

_minGenls()

_maxNotGenls()

_maxSpecs()

_minNotSpecs()

_genlSiblings()

_specSiblings()

_allGenls()

_allGenlsWrt()

_unionAllGenls()

_allGenlsIf()

_allNotGenls()

_allSpecs()

_allSpecsIf()

_allDependentSpecs()

_unionAllSpecs()

_genl()

_spec()

_anyGenl()

_allGenl()

_anySpec()

_allSpec()

_anyGenlAny()

_anyGenlAll()

_notGenl()

_anyNotGenl()

_collectionLeaves()

_minCols()

_maxCols()

_minCeilingCols()

_maxFloorCols()

_anyDisjointCollectionPair()

_anyDisjointCollectionPair()

_whyCollectionsDisjoint()

_anyGenlIsa()

_lighterCol()

_shallowerCol()

_maxFloorMtsOfGenlsPaths()

_whyNotAssertGenls()

_mapAllGenls()

_anyAllGenls()

_mapAllSpecs()

_anyAllSpecs()

_allGenlsAmong()

_allNotSpec()

_allNotSpecs()

_allSpecAny()

_allSpecsAmong()

_specSiblings()

_whyGenl()

_whyNotGenl()

_minGenlPredicates()

_minGenlInverses()

_maxNotGenlPredicates()

_maxNotGenlInverses()

_maxSpecPredicates()

_maxSpecInverses()

_minNotSpecPredicates()

_minNotSpecInverses()

_genlPredicateSiblings()

_genlInverseSiblings()

_specPredicateSiblings()

_specInverseSiblings()

_allGenlPredicates()

_allGenlInverses()

_allNotGenlPredicates()

_allNotGenlInverses()

_allSpecPredicates()

_allSpecInverses()

_allSpecPredsWrtType()

_allSpecPredsWrtArg()

_allNotSpecPredicates()

_allNotSpecInverses()

_specPredicate()

_genlPredicate()

_genlInverse()

_specInverse()

_anyGenlPredicate()

_notGenlPredicate()

_notGenlInverse()

_anyNotGenlPredicate()

_intersectingPredicates()

_whyGenlPredicate()

_whyNotGenlPredicate()

_whyGenlInverse()

_whyNotGenlInverse()

_minPredicates()

_maxPredicates()

_minCeilingPredicates()

_maxFloorPredicates()

_maxFloorMtsOfGenlPredicatePaths()

_maxFloorMtsOfGenlInversePaths()

_mapAllGenlPreds()

_someAllGenlPreds()

_mapAllSpecPreds()

_someAllSpecPreds()

_allGenlPredsAmong()

_genlPredicates()

_genlInverses()

_notGenlInverses()

_notGenlPredicates()

_notSpecInverses()

_notSpecPredicates()

_someAllGenlInverses()

_specInverses()

_specPredicates()

_unionAllGenlInverses()

_unionAllGenlPredicates()

_unionAllSpecInverses()

_unionAllSpecPredicates()

_gtAllAccessible()

_gtAllDependentInferiors()

_gtAllInferiors()

_gtAllSuperiors()

_gtAnySuperiorPath()

_gtCoInferiors()

_gtCoSuperiors()

_gtCompletesCycle()

_gtComposeFnAllInferiors()

_gtComposeFnAllSuperiors()

_gtComposePredAllInferiors()

_gtComposePredAllSuperiors()

_gtCycles()

_gtHasInferior()

_gtHasSuperior()

_gtInferiors()

_gtLeaves()

_gtMaxFloors()

_gtMaxInferiors()

_gtMaxInferiorsExcluding()

_gtMaxNodes()

_gtMinCeilings()

_gtMinNodes()

_gtMinSuperiors()

_gtMinSuperiorsExcluding()

_gtRedundantInferiors()

_gtRedundantSuperiors()

_gtRoots()

_gtSuperiors()

_gtWhyCompletesCycle()

_gtWhySuperior()

_allGenlAttributes()

_allGenlAttributesIf()

_allGenlAttributesWrt()

_argnGenlAttribute()

_argnGenlAttributeOf()

_minArgnGenlAttribute()

_allSpecAttributes()

_allSpecAttributesIf()

_fiFind()

_fiComplete()

_fiCreate()

_fiFindOrCreate()

_fiKill()

_fiRename()

_fiLookup()

_fiAssert()

_fiUnassert()

_fiEdit()

_fiBlast()

_fiAsk()

_fiContinueLastAsk()

_fiAskStatus()

_fiTmsReconsiderFormula()

_fiTmsReconsiderMt()

_fiTmsReconsiderGafs()

_fiTmsReconsiderTerm()

_fiHypothesize()

_fiProve()

_fiGetError()

_fiGetWarning()

_cycFindOrCreate()

_cycCreate()

_cycCreateNewEphemeral()

_cycCreateNewPermanent()

_cycKill()

_cycRecreate()

_cycRename()

_cycMerge()

_cycAssert()

_cycUnassert()

_cycEdit()

_cycQuery()

_cycContinueQuery()

_cycAddArgument()

_cycRemoveAllArguments()

_cycRemoveArgument()

_cycRewrite()

_cycTmsReconsiderSentence()

Edited by Jrowe

Share this post


Link to post
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

Share this post


Link to post
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.)

CODE
#include <GUIConstants.au3>

#include "openCyc.au3"

#include <GuiEdit.au3>

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

$Form1 = GUICreate("Form1", 633, 304, 193, 125, BitOR($WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS))

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

GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM+$GUI_DOCKHCENTER+$GUI_DOCKVCENTER+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)

$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)

GUISetState(@SW_SHOW)

#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 $GUI_EVENT_CLOSE

_cycClose()

Exit

Case $Button1

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

EndSwitch

For $Line_Count = 1 To _GUICtrlEdit_GetLineCount ($Edit1)

_GUICtrlEdit_Scroll ($Edit1, $SB_LINEDOWN)

Next

WEnd

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 & "!"

Else

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

EndIf

Return $Answer

EndFunc

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.

Share this post


Link to post
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.

http://www.cyc.com/doc/white_papers/Cyn_description.pdf

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.

http://freshmeat.net/articles/view/1910/

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.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0