org.opencyc.xml
Class ExportDaml

java.lang.Object
  |
  +--org.opencyc.xml.ExportDaml

public class ExportDaml
extends java.lang.Object

DAML+OIL export for OpenCyc.

Author:
Stephen L. Reed

Copyright 2001 Cycorp, Inc., license is open source GNU LGPL.

the license

www.opencyc.org

OpenCyc at SourceForge

THIS SOFTWARE AND KNOWLEDGE BASE CONTENT ARE PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENCYC ORGANIZATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE AND KNOWLEDGE BASE CONTENT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Field Summary
static Guid counterTerrorismConstantGuid
          The #$CounterTerrorismConstant guid.
 CycFort cycKbSubsetCollection
          The CycKBSubsetCollection whose elements are exported to DAML.
 Guid cycKbSubsetCollectionGuid
          The CycKBSubsetCollection whose elements are exported to DAML.
protected  CycFort cycKbSubsetFilter
          The CycKBSubsetCollection whose elements are exported to DAML if they also generalizations of cycKbSubsetCollectionGuid collections or predicates above.
 Guid cycKbSubsetFilterGuid
          The guid which identifies the CycKBSubsetCollection whose elements are exported to DAML if they also generalizations of cycKbSubsetCollectionGuid collections or predicates above.
protected static int DEFAULT_VERBOSITY
          The default verbosity of the DAML export output.
static Guid eeldSharedOntologyConstantGuid
          The #$EELDSharedOntologyConstant guid.
static Guid eeldSharedOntologyCoreConstantGuid
          The #$EELDSharedOntologyCoreConstant guid.
static int EXPORT_KB_SUBSET
          Command indicating that the DAML export contains only the marked KB subset terms.
static int EXPORT_KB_SUBSET_BELOW_TERM
          Command indicating that the DAML export contains the collections whose direct or indirect genl is the collection term indentified by rootTermGuid.
static int EXPORT_KB_SUBSET_PLUS_UPWARD_CLOSURE
          Command indicating that the DAML export contains the marked KB subset terms plus all the terms in the upward closure to #$Thing.
protected  int exportCommand
          The command performed by the DAML extract process.
static Guid ikbConstantGuid
          The #$IKBConstant guid.
 boolean includeUpwardClosure
          Indicates whether the upward closure of terms should be exported.
 java.lang.String outputPath
          The DAML export path and file name.
 CycFort rootTerm
          Used in the export command EXPORT_KB_SUBSET_BELOW_TERM.
 Guid rootTermGuid
          Used in the export command EXPORT_KB_SUBSET_BELOW_TERM.
 java.lang.String title
          The DAML comment that titles the output file.
 int verbosity
          Sets verbosity of the DAML export output.
 
Constructor Summary
ExportDaml()
          Constructs a new ExportDaml object.
 
Method Summary
protected  java.util.ArrayList applyCycKbSubsetFilter(CycList constants)
          Removes terms from the given list which are not elements of cycKbSubsetFilter.
protected  void createClassNode(CycConstant cycConstant)
          Creates a DAML class node for a single Cyc collection.
protected  void createConstantNode(CycConstant cycConstant)
          Creates a DAML node for a single Cyc Constant.
protected  void createCycGuidNode()
          Creates the DAML node that defines the guid property.
protected  void createDamlOntologyNode()
          Creates a DAML Ontology node.
protected  void createIndividualNode(CycConstant cycConstant)
          Creates a DAML individual node for a single Cyc individual.
protected  void createPropertyNode(CycConstant cycConstant)
          Creates a DAML property node for a single Cyc binary predicate.
protected  void createRdfNode()
          Creates an RDF node.
 void export(int exportCommand)
          Exports the desired KB content into DAML.
protected  CycList filterSelectedConstants(CycList constants)
          Removes unselected terms from the given list.
protected  CycList gatherUpwardClosure(CycList selectedCycForts)
          Gather the updward closure of the selected CycForts with regard to isas and genls for collection terms, and with regard to genlPreds for predicate terms.
protected  boolean isFilteredDamlSelectedConstant(java.lang.Object object)
          Return True iff the object is a selected constant.
protected  boolean isFilteredSelectedConstant(java.lang.Object object)
          Return True iff the object is a instance of the desired KB subset collection
static void main(java.lang.String[] args)
          Provides the main method for a DAML export.
protected  void populateArg1Format(CycConstant cycConstant)
          Populates the argument 1 format for a Cyc predicate.
protected  void populateArg1Isa(CycConstant cycConstant)
          Populates the argument 1 type constaint for a Cyc predicate.
protected  void populateArg2Format(CycConstant cycConstant)
          Populates the argument 2 format for a Cyc predicate.
protected  void populateArg2Isa(CycConstant cycConstant)
          Populates the argument 2 type constaint for a Cyc predicate.
protected  void populateCoExtensionals(CycConstant cycConstant)
          Populates the coExtensionals for a Cyc collection.
protected  void populateComment(CycConstant cycConstant)
          Populates the comment for a Cyc term.
protected  void populateDisjointWiths(CycConstant cycConstant)
          Populates the disjointWiths for a Cyc collection.
protected  void populateGenlPreds(CycConstant cycConstant)
          Populates the genlPreds for a Cyc predicate.
protected  void populateGenls(CycConstant cycConstant)
          Populates the genls for a Cyc term.
protected  void populateIsas(CycConstant cycConstant)
          Populates the isas for a Cyc term.
protected  void setup()
          Sets up the DAML export process.
protected  java.lang.String translateTerm(CycConstant cycConstant)
          Translates a Cyc term into a kind of DAML node: DAML Thing, DAML class, DAML property or DAML transitive property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXPORT_KB_SUBSET

public static final int EXPORT_KB_SUBSET
Command indicating that the DAML export contains only the marked KB subset terms. cycKbSubsetCollectionGuid contains the KB subset collection's guid. cycKbSubsetFilterGuid contains the guid for the KB subset term that filters membership in the upward closure.

EXPORT_KB_SUBSET_PLUS_UPWARD_CLOSURE

public static final int EXPORT_KB_SUBSET_PLUS_UPWARD_CLOSURE
Command indicating that the DAML export contains the marked KB subset terms plus all the terms in the upward closure to #$Thing. cycKbSubsetCollectionGuid contains the KB subset collection's guid.

EXPORT_KB_SUBSET_BELOW_TERM

public static final int EXPORT_KB_SUBSET_BELOW_TERM
Command indicating that the DAML export contains the collections whose direct or indirect genl is the collection term indentified by rootTermGuid. cycKbSubsetFilterGuid contains the guid for the KB subset term that filters membership in the export set.

exportCommand

protected int exportCommand
The command performed by the DAML extract process.

DEFAULT_VERBOSITY

protected static final int DEFAULT_VERBOSITY
The default verbosity of the DAML export output. 0 --> quiet ... 9 -> maximum diagnostic input.

verbosity

public int verbosity
Sets verbosity of the DAML export output. 0 --> quiet ... 9 -> maximum diagnostic input.

includeUpwardClosure

public boolean includeUpwardClosure
Indicates whether the upward closure of terms should be exported. If so, the upward closure terms are filtered by cycKbSubsetFilterGuid below.

cycKbSubsetCollection

public CycFort cycKbSubsetCollection
The CycKBSubsetCollection whose elements are exported to DAML.

counterTerrorismConstantGuid

public static final Guid counterTerrorismConstantGuid
The #$CounterTerrorismConstant guid.

eeldSharedOntologyCoreConstantGuid

public static final Guid eeldSharedOntologyCoreConstantGuid
The #$EELDSharedOntologyCoreConstant guid.

eeldSharedOntologyConstantGuid

public static final Guid eeldSharedOntologyConstantGuid
The #$EELDSharedOntologyConstant guid.

ikbConstantGuid

public static final Guid ikbConstantGuid
The #$IKBConstant guid.

cycKbSubsetCollectionGuid

public Guid cycKbSubsetCollectionGuid
The CycKBSubsetCollection whose elements are exported to DAML.

cycKbSubsetFilterGuid

public Guid cycKbSubsetFilterGuid
The guid which identifies the CycKBSubsetCollection whose elements are exported to DAML if they also generalizations of cycKbSubsetCollectionGuid collections or predicates above. #$IKBConstant (not in OpenCyc)

cycKbSubsetFilter

protected CycFort cycKbSubsetFilter
The CycKBSubsetCollection whose elements are exported to DAML if they also generalizations of cycKbSubsetCollectionGuid collections or predicates above. #$IKBConstant (not in OpenCyc)

rootTermGuid

public Guid rootTermGuid
Used in the export command EXPORT_KB_SUBSET_BELOW_TERM. The DAML export contains the collections whose direct or indirect genl is the collection term indentified by this value.

rootTerm

public CycFort rootTerm
Used in the export command EXPORT_KB_SUBSET_BELOW_TERM. The DAML export contains the collections whose direct or indirect genl is this collection term.

outputPath

public java.lang.String outputPath
The DAML export path and file name.

title

public java.lang.String title
The DAML comment that titles the output file.
Constructor Detail

ExportDaml

public ExportDaml()
Constructs a new ExportDaml object.
Method Detail

main

public static void main(java.lang.String[] args)
Provides the main method for a DAML export.

export

public void export(int exportCommand)
            throws java.net.UnknownHostException,
                   java.io.IOException,
                   CycApiException
Exports the desired KB content into DAML.

setup

protected void setup()
              throws java.net.UnknownHostException,
                     java.io.IOException,
                     CycApiException
Sets up the DAML export process.

createRdfNode

protected void createRdfNode()
Creates an RDF node.

createDamlOntologyNode

protected void createDamlOntologyNode()
Creates a DAML Ontology node.

createConstantNode

protected void createConstantNode(CycConstant cycConstant)
                           throws java.net.UnknownHostException,
                                  java.io.IOException,
                                  CycApiException
Creates a DAML node for a single Cyc Constant.

createClassNode

protected void createClassNode(CycConstant cycConstant)
                        throws java.net.UnknownHostException,
                               java.io.IOException,
                               CycApiException
Creates a DAML class node for a single Cyc collection.

createIndividualNode

protected void createIndividualNode(CycConstant cycConstant)
                             throws java.net.UnknownHostException,
                                    java.io.IOException,
                                    CycApiException
Creates a DAML individual node for a single Cyc individual.

createCycGuidNode

protected void createCycGuidNode()
Creates the DAML node that defines the guid property.

createPropertyNode

protected void createPropertyNode(CycConstant cycConstant)
                           throws java.net.UnknownHostException,
                                  java.io.IOException,
                                  CycApiException
Creates a DAML property node for a single Cyc binary predicate.

translateTerm

protected java.lang.String translateTerm(CycConstant cycConstant)
                                  throws java.net.UnknownHostException,
                                         java.io.IOException,
                                         CycApiException
Translates a Cyc term into a kind of DAML node: DAML Thing, DAML class, DAML property or DAML transitive property.
Returns:
the kind of DAML node: DAML Thing, DAML class, DAML property or DAML transitive property

populateComment

protected void populateComment(CycConstant cycConstant)
                        throws java.net.UnknownHostException,
                               java.io.IOException,
                               CycApiException
Populates the comment for a Cyc term.

applyCycKbSubsetFilter

protected java.util.ArrayList applyCycKbSubsetFilter(CycList constants)
                                              throws java.net.UnknownHostException,
                                                     java.io.IOException,
                                                     CycApiException
Removes terms from the given list which are not elements of cycKbSubsetFilter.
Returns:
the filtered list

filterSelectedConstants

protected CycList filterSelectedConstants(CycList constants)
Removes unselected terms from the given list.
Returns:
the filtered list

isFilteredDamlSelectedConstant

protected boolean isFilteredDamlSelectedConstant(java.lang.Object object)
Return True iff the object is a selected constant. (DAML does not now contain non-binary predicates nor function terms.)
Returns:
True iff the object is a selected constant

isFilteredSelectedConstant

protected boolean isFilteredSelectedConstant(java.lang.Object object)
                                      throws java.net.UnknownHostException,
                                             java.io.IOException,
                                             CycApiException
Return True iff the object is a instance of the desired KB subset collection

populateIsas

protected void populateIsas(CycConstant cycConstant)
                     throws java.net.UnknownHostException,
                            java.io.IOException,
                            CycApiException
Populates the isas for a Cyc term.

populateGenls

protected void populateGenls(CycConstant cycConstant)
                      throws java.net.UnknownHostException,
                             java.io.IOException,
                             CycApiException
Populates the genls for a Cyc term.

populateGenlPreds

protected void populateGenlPreds(CycConstant cycConstant)
                          throws java.net.UnknownHostException,
                                 java.io.IOException,
                                 CycApiException
Populates the genlPreds for a Cyc predicate.

populateArg1Isa

protected void populateArg1Isa(CycConstant cycConstant)
                        throws java.net.UnknownHostException,
                               java.io.IOException,
                               CycApiException
Populates the argument 1 type constaint for a Cyc predicate.

populateArg2Isa

protected void populateArg2Isa(CycConstant cycConstant)
                        throws java.net.UnknownHostException,
                               java.io.IOException,
                               CycApiException
Populates the argument 2 type constaint for a Cyc predicate.

populateArg1Format

protected void populateArg1Format(CycConstant cycConstant)
                           throws java.net.UnknownHostException,
                                  java.io.IOException,
                                  CycApiException
Populates the argument 1 format for a Cyc predicate.

populateArg2Format

protected void populateArg2Format(CycConstant cycConstant)
                           throws java.net.UnknownHostException,
                                  java.io.IOException,
                                  CycApiException
Populates the argument 2 format for a Cyc predicate.

populateDisjointWiths

protected void populateDisjointWiths(CycConstant cycConstant)
                              throws java.net.UnknownHostException,
                                     java.io.IOException,
                                     CycApiException
Populates the disjointWiths for a Cyc collection.

populateCoExtensionals

protected void populateCoExtensionals(CycConstant cycConstant)
                               throws java.net.UnknownHostException,
                                      java.io.IOException
Populates the coExtensionals for a Cyc collection.

gatherUpwardClosure

protected CycList gatherUpwardClosure(CycList selectedCycForts)
                               throws java.net.UnknownHostException,
                                      java.io.IOException,
                                      CycApiException
Gather the updward closure of the selected CycForts with regard to isas and genls for collection terms, and with regard to genlPreds for predicate terms.
Returns:
the updward closure of the selected CycForts with regard to genls for collection terms, and with regard to genlPreds for predicate terms