/** Test of getSources method, of class CycBackedInferenceAnswer. */
  @Test
  public void testGetSources() throws Exception {
    System.out.println("getSources");
    // TODO -- Find or create a sourced query available in OpenCyc KB.
    assumeNotOpenCyc();
    final CycConstant WHH_WP =
        getCyc()
            .getLookupTool()
            .find("#$TestFactEntrySource-WikipediaArticle-WilliamHenryHarrison");
    // (#$ContextOfPCWFn #$TestFactEntrySource-WikipediaArticle-WilliamHenryHarrison)
    final ELMt WHH_WP_MT =
        ELMtCycNaut.makeELMtCycNaut(CycArrayList.makeCycList(CONTEXT_OF_PCW_FN, WHH_WP));

    InferenceAnswer inferenceAnswer =
        getFirstInferenceAnswer(ISA_WILLIAM_HENRY_HARRISON_US_PRESIDENT_STRING, WHH_WP_MT);
    final Collection<InformationSource> sources =
        inferenceAnswer.getSources(
            new InformationSourceImpl.CycCitationGenerator(CHICAGO_MANUAL_OF_STYLE_STANDARD));
    assertFalse(sources.isEmpty());
    for (final InformationSource source : sources) {
      assertNotNull("No citation string for " + source.getCycL(), source.getCitationString());
      if (CycClientManager.getClientManager().fromCycAccess(getCyc()).isFullKB()) {
        // TODO: should we add an assertion for the icon?
        assertNotNull("No icon for " + source.getCycL(), source.getIconURL());
      }
    }
  }
Exemplo n.º 2
0
 private Object ensureCommandReturnsSerializable(Object cmd) {
   if (cmd instanceof String) {
     cmd = "(progn " + (String) cmd + " nil)";
   } else if (cmd instanceof CycArrayList) {
     cmd = CycArrayList.list("progn", cmd, "nil");
   }
   return cmd;
 }