Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#38 working API or ExportOwl description

v2.0
open
Cycorp API
API (1)
5
2009-09-24
2009-09-24
No

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

Discussion

  • 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:

    exportOwl.setSelectedCycForts(cycAccess.getAllSpecs(rootCollection));

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

    exportOwl.export(OntologyExport.EXPORT_SELECTED_TERMS)

    Good luck.

     
  • 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,

    Daniel.

     
  • 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!

    David