示例#1
0
  private void loadKB(String kbURL, String guidelineId) {

    System.out.println("Starting to load KB");
    System.out.println("------------------------------------------------------------------");
    try {
      PCAImp = new PCAServer_i();
      PCAImp.kbManager = new KBHandler(kbURL); // Sever loads the KB
      // java.util.Date finishedKB = new java.util.Date();
      // logger.warn("finished loading KB "+(finishedKB.getTime() - startTime.getTime())+ "
      // milliseconds after start.");
      pca = PCAImp.open_pca_session();
      if ((guidelineId != null) && (guidelineId != "")) {
        pca.setGuideline(guidelineId); // Specifies the guideline to use
      } else logger.error("No GUIDELINEID specified");
    } catch (Exception se) {
      logger.error("Exception raised during initialization " + se.toString());
      System.exit(1);
    }
    pca.finishSession();
    System.out.println("------------------------------------------------------------------");
    System.out.println("Done loading KB");
  }
示例#2
0
  public void removeForwardReferences() {
    KnowledgeBase kb = this.getKnowledgeBase();
    Slot branches = kb.getSlot("branches");
    Slot followed_by = kb.getSlot("followed_by");
    // logger.debug("Slot "+branches.getName());
    // logger.debug("Slot "+followed_by.getName());
    Slot label = kb.getSlot("label");
    Collection steps = getOwnSlotValues(kb.getSlot("steps"));
    for (Iterator iterater = steps.iterator(); iterater.hasNext(); ) {
      Instance step = (Instance) iterater.next();
      // logger.debug("removeForwardReferences: node ="+step.getOwnSlotValue(label));
      /*for (Iterator slots=step.getOwnSlots().iterator(); slots.hasNext();){
      	logger.debug("has slot "+((Slot)slots.next()).getName());
      }*/
      try {
        if (step.hasOwnSlot(branches)) {
          /*logger.debug("removeForwardReferences: "+ step.getOwnSlotValue(label)+
          " has branches"); */
          step.setOwnSlotValues(branches, new ArrayList());
        } else if (step.hasOwnSlot(followed_by)) {
          /* logger.debug("removeForwardReferences: "+ step.getOwnSlotValue(label)+
          " has followed_by value "+step.getOwnSlotValue(followed_by));*/
          step.setOwnSlotValue(followed_by, null);
        } else
          logger.error(
              "removeForwardReferences: "
                  + step.getOwnSlotValue(label)
                  + "has no followed_by or branches slot");
      } catch (Exception e) {

        logger.error(
            "Exception making " + step.getOwnSlotValue(label) + " null, Message: " + e.getMessage(),
            e);
      }
    }
  }