コード例 #1
0
  /**
   * Provides the main method for an EELD DAML export.
   *
   * @parameter args the optional command line arguments
   */
  public static void main(String[] args) {
    try {
      cycAccess =
          new CycAccess(
              CycConnection.DEFAULT_HOSTNAME,
              CycConnection.DEFAULT_BASE_PORT,
              CycConnection.DEFAULT_COMMUNICATION_MODE,
              CycAccess.DEFAULT_CONNECTION);
      /*
          new CycAccess(CycConnection.DEFAULT_HOSTNAME,
                        3620,
                        CycConnection.DEFAULT_COMMUNICATION_MODE,
                        CycAccess.DEFAULT_CONNECTION);
      */
      ExportDaml exportDaml = new ExportDaml(cycAccess);
      exportDaml.verbosity = ExportDaml.DEFAULT_VERBOSITY;
      // exportDaml.verbosity = 9;

      String choice = "eeld-core";
      if (args.length > 0) choice = args[0];

      Log.current.println("Choosing KB selection: " + choice);
      // These require the Cycorp IKB or full KB to work as setup below.
      if (choice.equals("all")) {
        exportDaml.includeUpwardClosure = false;
        exportDaml.title = "Open Cyc Ontology";
        exportDaml.outputPath = "open-cyc.daml";
        exportDaml.export(ExportDaml.EXPORT_ENTIRE_KB);
      }
      if (choice.equals("eeld-core")) {
        exportDaml.cycKbSubsetCollectionGuid = eeldSharedOntologyCoreConstantGuid;
        exportDaml.cycKbSubsetFilterGuid = ikbConstantGuid;
        exportDaml.title = "EELD Shared Core Ontology";
        exportDaml.outputPath = "eeld-shared-core-ontology.daml";
        exportDaml.export(ExportDaml.EXPORT_KB_SUBSET);
      } else if (choice.equals("eeld")) {
        exportDaml.cycKbSubsetCollectionGuid = eeldSharedOntologyConstantGuid;
        exportDaml.cycKbSubsetFilterGuid = ikbConstantGuid;
        exportDaml.title = "EELD Shared Ontology";
        exportDaml.outputPath = "eeld-shared-ontology.daml";
        CycList kbSubsetCollections = new CycList();
        kbSubsetCollections.add(cycAccess.getKnownConstantByName("EELDSyntheticDataConstant"));
        kbSubsetCollections.add(cycAccess.getKnownConstantByName("EELDNaturalDataConstant"));
        CycList applicableBinaryPredicates =
            cycAccess.getApplicableBinaryPredicates(kbSubsetCollections);
        applicableBinaryPredicates.remove(cycAccess.isa);
        applicableBinaryPredicates = applicableBinaryPredicates.sort();
        Log.current.println(
            "applicableBinaryPredicates: \n" + applicableBinaryPredicates.cyclify());
        exportDaml.applicableBinaryPredicates = applicableBinaryPredicates;
        exportDaml.export(ExportDaml.EXPORT_KB_SUBSET);

      } else if (choice.equals("transportation-device")) {
        Guid transportationDeviceGuid =
            CycObjectFactory.makeGuid("bd58d540-9c29-11b1-9dad-c379636f7270");
        exportDaml.rootTermGuid = transportationDeviceGuid;
        exportDaml.cycKbSubsetFilterGuid = counterTerrorismConstantGuid;
        exportDaml.export(ExportDaml.EXPORT_KB_SUBSET_BELOW_TERM);
      } else {
        System.out.println("specified choice not found - " + choice);
        System.exit(1);
      }
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }
  }