当前位置: 首页>>代码示例>>Java>>正文


Java KbIndividual类代码示例

本文整理汇总了Java中com.cyc.kb.KbIndividual的典型用法代码示例。如果您正苦于以下问题:Java KbIndividual类的具体用法?Java KbIndividual怎么用?Java KbIndividual使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


KbIndividual类属于com.cyc.kb包,在下文中一共展示了KbIndividual类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toString

import com.cyc.kb.KbIndividual; //导入依赖的package包/类
@Override
@Deprecated
public String toString() {
  StringBuilder result = new StringBuilder()
          .append("/**\n"
          + " * This code was autogenerated by ModelGenerator program. The ModelGenerator\n"
          + " * creates Java Interfaces and Classes by introspecting the Cyc Knowledge Base.\n"
          + " * It is strongly recommended not to make any changes to this file. \n"
          + " * This will allow regeneration of code when the Cyc KB model changes with fewer\n"
          + " * downstream changes. Please extend the generated Interface to add \n"
          + " * functionality.\n"
          + " * \n"
          + " * The interface corresponds to " + this.getCycName() + " in the Cyc KB. \n"
          + " * <p>\n"
          + " * \n"
          + " * @author ModelGenerator\n"
          + " * @author Vijay Raj\n"
          + " * @version \"%I%, %G%\"\n"
          + " * @since 0.90\n"
          + " */\n\n");
  result.append("package ")
          .append(this.getPackageName())
          .append((this.getDirName() != null) ? this.getDirName().replaceFirst("\\/", "") : null)
          .append(";\n\n\n");
  for (String i : imports) {
    result.append("import ").append(i).append(";\n");
  }
  result.append("\n\npublic interface " + this.getName() + " {\n\n")
          .append("    public " + KbIndividual.class.getSimpleName() + " getInstance();\n\n")
          .append("    public List<" + this.getName() + "> allSibling" + this.getName() + "s (String ctxStr) throws Exception;\n\n");
  for (MethodObj mo : this.getMethods()) {
    result.append("    " + mo.toString() + "\n\n");
  }
  result.append("}\n");
  return result.toString();
}
 
开发者ID:cycorp,项目名称:model-generator-suite,代码行数:37,代码来源:InterfaceObj.java

示例2: initKbIndividual

import com.cyc.kb.KbIndividual; //导入依赖的package包/类
private static KbIndividual initKbIndividual(String nameOrId) {
  try {
    return Cyc.getKbIndividualService().get(nameOrId);
  } catch (KbException ex) {
    return handleException(KbIndividual.class, nameOrId, ex);
  }
}
 
开发者ID:cycorp,项目名称:api-suite,代码行数:8,代码来源:Cyc.java

示例3: setupMarvinGardens

import com.cyc.kb.KbIndividual; //导入依赖的package包/类
/**
 * Ensure that _King Of Marvin Gardens_ exists in Cyc's KB, and has enough supporting knowledge to
 * be useful. This is known as "term elaboration".
 * 
 * @throws CreateException
 * @throws KbTypeException 
 */
protected void setupMarvinGardens()
        throws CreateException, KbTypeException {
  System.out.println();
  
  /* 
   Find or create an individual term in the KB to represent the movie  _King of Marvin Gardens_, 
   and simultaneously make it an instance of the DramaticMovies collection in the MassMediaDataMt 
   Context. Note that we could also have passed the String DramaticMovie and the context 
   MassMediaDataMt as parameters to the findOrCreate method. Also note that we assumed the
   collection DramaticMovie exists in the KB. If DramaticMovie were not in the KB, this code would
   throw an exception, and we would have to create it.
  */
  KbCollection dramaticMovie = KbCollection.get("DramaticMovie");
  kingOfMarvinGardens = KbIndividual
          .findOrCreate("TheKingOfMarvinGardens-TheMovie", dramaticMovie, massMediaDataMt);
  System.out.println("We've created _King of Marvin Gardens_: " + kingOfMarvinGardens);
  
  /* 
   Now, let's add the fact that the movie "The King of Marvin Gardens" has a restricted rating. 
  */
  restrictedRating = KbCollection.get("RestrictedRating");
  movieAdvisoryRating = BinaryPredicate.get("movieAdvisoryRating");
  Fact kingOfMarvinGardensRestrictedRating = Fact.findOrCreate(
          Sentence.get(movieAdvisoryRating, kingOfMarvinGardens, restrictedRating),
          massMediaDataMt);
  System.out.println("_King of Marvin Gardens_ is R-rated: " 
          + kingOfMarvinGardensRestrictedRating);
}
 
开发者ID:cycorp,项目名称:example-code,代码行数:36,代码来源:BasicWalkthrough.java

示例4: createQueryViaString

import com.cyc.kb.KbIndividual; //导入依赖的package包/类
/**
 * Construct a query from a String containing a CycL sentence and run it. Although it's generally
 * preferable to construct Queries via a Sentence of KbObjects (less error-prone), there are 
 * certainly times when you may want to read raw Strings (user input, prototyping, etc.)
 * 
 * <p>Here we will retrieve the query answers as a synchronous QueryResultSet, which is very
 * similar to a JDBC ResultSet.
 * 
 * @throws KbTypeException
 * @throws CreateException
 * @throws QueryConstructionException
 * @throws KbException 
 */
public void createQueryViaString()
        throws KbTypeException, CreateException, QueryConstructionException, KbException {
  System.out.println();
  
  /* 
   Note that the #$ prefix for constant names is not required, and that the
   toString method on KBObjects yields a string that can be used in this kind
   of method.
   */
  try (Query query = Query.get(
          "(and (movieActors ?MOVIE " + nicholson + ")" +
          "     (movieAdvisoryRating ?MOVIE RestrictedRating))",
          "InferencePSC")) {
    query.getInferenceParameters()
            .setMaxAnswerCount(10)
            .setMaxTime(2)
            .setBrowsable(true);
    
    /*
     Calling Query#getResultSet() will force an inference to run, if this has not already 
     happened.
     */
    System.out.println("Retrieving query answers as a synchronous QueryResultSet...");
    QueryResultSet results = query.getResultSet();
    
    System.out.println("Status: " + query.getStatus());
    System.out.println("Is inference suspended? "
            + InferenceStatus.SUSPENDED.equals(query.getStatus()));
    System.out.println("Number of results: " + results.getCurrentRowCount());
    while (results.next()) {
      KbIndividual binding = results.getKbObject("?MOVIE", KbIndividual.class);
      System.out.println(" - " + binding);
    }
  } finally {
    System.out.println("Done with query!");
  }
}
 
开发者ID:cycorp,项目名称:example-code,代码行数:51,代码来源:BasicWalkthrough.java

示例5: getCreator

import com.cyc.kb.KbIndividual; //导入依赖的package包/类
@Override
public KbIndividual getCreator() {
  return wrapped().getCreator();
}
 
开发者ID:cycorp,项目名称:api-suite,代码行数:5,代码来源:KbTermWrapper.java

示例6: quote

import com.cyc.kb.KbIndividual; //导入依赖的package包/类
@Override
public KbIndividual quote() throws KbTypeException, CreateException {
  return wrapped().quote();
}
 
开发者ID:cycorp,项目名称:api-suite,代码行数:5,代码来源:KbObjectWrapper.java

示例7: toQuoted

import com.cyc.kb.KbIndividual; //导入依赖的package包/类
@Override
public KbIndividual toQuoted() throws KbTypeException, CreateException {
  return wrapped().toQuoted();
}
 
开发者ID:cycorp,项目名称:api-suite,代码行数:5,代码来源:KbObjectWrapper.java

示例8: wrapped

import com.cyc.kb.KbIndividual; //导入依赖的package包/类
@Override
protected abstract KbIndividual wrapped();
 
开发者ID:cycorp,项目名称:api-suite,代码行数:3,代码来源:KbIndividualWrapper.java

示例9: basicTermLookup

import com.cyc.kb.KbIndividual; //导入依赖的package包/类
/**
 * Perform some simple term lookup and creation. Most of the methods in the KB API and the Query 
 * API will accept both Strings and KB objects for their arguments.  But it's good practice to
 * create the KB object versions, and use them.  In this file, we'll alternate back and forth 
 * between using KB object and using Strings for these arguments.  Here's how you retrieve the KB
 * objects.
 * 
 * @throws KbTypeException
 * @throws CreateException 
 * @throws DeleteException 
 */
protected void basicTermLookup()
        throws KbTypeException, CreateException, DeleteException {
  System.out.println();
  
  /* 
   KbObjects are requested from factories, and there is KB factory for each KbObject type.
   Here, we find or create an Individual term in the KB to represent the actor Jack Nicholson.
  */
  KbIndividual nicholsonIndividual = KbIndividual.findOrCreate("JackNicholson");
  System.out.println("Jack Nicholson as an individual: "
          + nicholsonIndividual);
  
  /* 
   And here, we request JackNicholson as a KbTerm, which is a super-type of KbIndividual. Note 
   that we're now using the get method, which should only be used if you're sure the term is in 
   the KB. This code shows how to test whether a term is in the KB (in a form that can be cast to 
   the desired type) before actually retrieving it. In most real-world cases, you won't run this
   test before every call to get. 
   */
  KbTerm nicholsonTerm = null;
  if (KbTerm.existsAsType("JackNicholson")) {
    nicholsonTerm = KbTerm.get("JackNicholson");
  }
  System.out.println("Jack Nicholson as a term: " + nicholsonTerm);
  
  /*
   We can also confirm that Jack Nicholson isn't, say, a KbCollection.
   */
  System.out.println("Is Jack Nicholson a collection? "
          + KbCollection.existsAsType("JackNicholson"));
  
  /*
   The KbObject factories are intelligent enough to return an instance of the most specific type.
   Because JackNicholson is an Individual, and because KbIndividual is a subclass of KbTerm,
   either factory will return an instance of KbIndividual. And, because of caching, they will 
   return the *same* instance of KbIndividual:
   */
  System.out.println("Are the KbTerm and KbIndividual for #$JackNicholson the exact same object? "
          + (nicholsonIndividual == nicholsonTerm));
  
  /*
   Now, let's check whether the movie _King of Marvin Gardens_ exists in Cyc's KB. Here is some
   slightly different syntax for checking whether it can be expressed as a KbIndividual:
  */
  System.out.println("Does Cyc already know that _King of Marvin Gardens_ is an individual? "
          + KbIndividual.existsAsType("TheKingOfMarvinGardens-TheMovie"));
  
  /*
   And here's a way to check whether the term exists at all:
   */
  System.out.println("Does _King of Marvin Gardens_ exist in Cyc's KB at all? "
          + Cyc.existsInKb("TheKingOfMarvinGardens-TheMovie"));
  
  /*
   For sake of the example, let's ensure that _King of Marvin Gardens_ does NOT exist in Cyc's KB.
   Of course, it needs to exist in order for us to delete it, and we could check 
   KbFactory#existsInKb() (like we just did above) to determine whether it exists. But for sake of
   the example let's assume that it's in the KB, and add some code for handling the case where it 
   isn't:
   */
  try {
    KbTerm.get("TheKingOfMarvinGardens-TheMovie").delete();
    System.out.println("TheKingOfMarvinGardens-TheMovie: deleted!");
  } catch (KbObjectNotFoundException e) {
    System.out.println("Apparently TheKingOfMarvinGardens-TheMovie wasn't in the KB,"
            + " but we'll just carry on: " + " (" + e.getMessage() + ")");
  }
}
 
开发者ID:cycorp,项目名称:example-code,代码行数:80,代码来源:BasicWalkthrough.java

示例10: get

import com.cyc.kb.KbIndividual; //导入依赖的package包/类
/**
 * Constructs a Query from a KbIndividual corresponding to #$CycLQuerySpecification.
 *
 * @param id
 *
 * @return the Query specified by <code>id</code>
 *
 * @throws QueryConstructionException
 *
 * <p>
 * <b>Note:</b> {@link QueryConstructionException} is thrown if the specified getQueryService term
 * has a getSentenceService whose outermost operator is #$ist and the getQueryService is loaded
 * from a Cyc server with a system level under 10.154917 (Nov. 2014). A workaround is to edit the
 * getQueryService in the KB, removing the #$ist from the getQueryService's getSentenceService,
 * and specifying it as the getQueryService mt using #$microtheoryParameterValueInSpecification.
 *
 * @throws KbException                      if <code>idStr</code> does not identify a
 *                                          KbIndividual.
 *
 * @throws UnsupportedCycOperationException when run against ResearchCyc 4.0q and earlier.
 *
 * @see com.cyc.Cyc.Constants#CYCL_QUERY_SPECIFICATION
 */
public static Query get(final KbIndividual id)
        throws QueryConstructionException, KbException, UnsupportedCycOperationException {
  return Cyc.getQueryService().getQuery(id);
}
 
开发者ID:cycorp,项目名称:api-suite,代码行数:28,代码来源:Query.java

示例11: saveAs

import com.cyc.kb.KbIndividual; //导入依赖的package包/类
/**
 * Saves this Query as a new query term with the specified name.
 *
 * @param name The name by which to save the query.
 *
 * @return  the new term
 * @throws  KbException
 * @throws  SessionCommunicationException  if there is a problem communicating with Cyc
 * @throws  QueryConstructionException     if there was a problem constructing the new query
 * @see     Query#save()
 */
KbIndividual saveAs(String name) 
        throws KbException, SessionCommunicationException, QueryConstructionException;
 
开发者ID:cycorp,项目名称:api-suite,代码行数:14,代码来源:ModifiableQuerySpecification.java

示例12: getQuery

import com.cyc.kb.KbIndividual; //导入依赖的package包/类
/**
 * Constructs a Query from a KbIndividual corresponding to a <tt>#$CycLQuerySpecification</tt>.
 *
 * @param id
 *
 * @return the Query specified by <code>id</code>
 *
 * @throws QueryConstructionException       if the specified query term has a sentence whose
 *                                          outermost operator is #$ist and the query is loaded
 *                                          from a Cyc server with a system level under 10.154917
 *                                          (Nov. 2014). A workaround is to edit the query in the
 *                                          KB, removing the #$ist from the query's sentence, and
 *                                          specifying it as the query mt using
 * <tt>#$microtheoryParameterValueInSpecification</tt>.
 * @throws KbException                      if <code>idStr</code> does not identify a KbIndividual
 * @throws UnsupportedCycOperationException when run against ResearchCyc 4.0q and earlier
 *
 * @see com.cyc.Cyc.Constants#CYCL_QUERY_SPECIFICATION
 */
Query getQuery(final KbIndividual id)
        throws QueryConstructionException, KbException, UnsupportedCycOperationException;
 
开发者ID:cycorp,项目名称:api-suite,代码行数:22,代码来源:QueryService.java

示例13: getId

import com.cyc.kb.KbIndividual; //导入依赖的package包/类
/**
 * For saved queries (aka "KBQs") this returns the Cyc term that identifies the query. To change 
 * the id of an existing query, see {@link ModifiableQuerySpecification#saveAs(String)}
 *
 * @return  the id term
 */
KbIndividual getId();
 
开发者ID:cycorp,项目名称:api-suite,代码行数:8,代码来源:QuerySpecification.java

示例14: get

import com.cyc.kb.KbIndividual; //导入依赖的package包/类
/**
 * Get the <code>KbIndividual</code> with the name <code>nameOrId</code>. Throws exceptions if
 * there is no KB term by that name, or if it is not already an instance of #$Individual.
 *
 * @param nameOrId the string representation or the HLID of the #$Individual
 *
 * @return a new KbIndividual
 *
 * @throws KbTypeException
 * @throws CreateException
 */
@Override
KbIndividual get(String nameOrId) throws KbTypeException, CreateException;
 
开发者ID:cycorp,项目名称:api-suite,代码行数:14,代码来源:KbIndividualService.java

示例15: findOrCreate

import com.cyc.kb.KbIndividual; //导入依赖的package包/类
/**
 * Find or create a <code>KbIndividual</code> object named <code>nameOrId</code>. If no object
 * exists in the KB with the name <code>nameOrId</code>, one will be created, and it will be
 * asserted to be an instance of <code>#$Individual</code>. If there is already an object in the
 * KB called <code>nameOrId</code>, and it is already a <code>#$Individual</code>, it will be
 * returned. If it is not already a <code>#$Individual</code>, but can be made into one by
 * addition of assertions to the KB, such assertions will be made, and the object will be
 * returned. If the object in the KB cannot be turned into a <code>#$Individual</code> by adding
 * assertions (i.e. some existing assertion prevents it from being a <code>#$Individual</code>), a
 * <code>KbTypeConflictException</code>will be thrown.
 *
 * @param nameOrId the string representation or the HLID of the #$Individual
 *
 * @return a new KbIndividual
 *
 * @throws KbTypeException
 * @throws CreateException
 */
@Override
KbIndividual findOrCreate(String nameOrId) throws CreateException, KbTypeException;
 
开发者ID:cycorp,项目名称:api-suite,代码行数:21,代码来源:KbIndividualService.java


注:本文中的com.cyc.kb.KbIndividual类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。