#38 working API or ExportOwl description

API (1)

Hi, I have been using OpenCyc for several months and i want to extract just a subset of all the classes from the OWL file. I want that, given a class, i can extract it, all of its children and their children below -in short, all the subtree below the given class.
I saw the API and it includes a file ExtractOwl.class, but I haven't been able to make it work. Does this program do what I need? Otherwise, which alternative -even non-OWL- could you suggest me?
Thanks in advance.

Daniel Macias


  • David Baxter

    David Baxter - 2009-09-24

    Hi Daniel,

    I assume you're referring to org.opencyc.xml.ExportOwl.

    This should do what you need. First, you'll need a CycAccess object. Suppose your CycAccess instance is called "cycAccess" and your root collection is called "rootCollection". Create your ExportOwl instance like so:

    exportOwl = new ExportOwl(cycAccess);

    Then set the terms you want to export like so:


    Set your destination using exportOwl.setOutputPath(), then do the export like so:


    Good luck.

  • Daniel Macias Galindo

    Hi David,

    Thanks for the response, it is working very well indeed!
    Just wondering if I can get the names of the categories with short English names rather than long IDs, to visualise the ontology in an tool s.a. Protege.
    Thanks again,


  • David Baxter

    David Baxter - 2009-09-28

    Glad to hear you got it working. Not sure about getting the more readable names, but here are a couple of ideas.

    ExportOwl uses the private field "shouldUseExternalIDForName" to gate this behavior. It's set to "true", and doesn't have a non-private way to set it to "false". If you have the source code and can recompile it, you could either add a public accessor or hardcode it to "false" and see if that results in the behavior you want.

    The other option is to experiment with ExportOwl.setApplicableBinaryPredicates to tell the exporter which binary predicates you want to use. Make sure it includes #$prettyString-Canonical and then tell Protege to use this as the display string for the ontology.

    Good luck!



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks