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


Java KbTerm类代码示例

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


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

示例1: wrapped

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

示例2: rename

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

示例3: addQuotedIsa

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

示例4: instantiates

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

示例5: basicTermLookup

import com.cyc.kb.KbTerm; //导入依赖的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

示例6: getSources

import com.cyc.kb.KbTerm; //导入依赖的package包/类
/**
 * Get the attributed sources used in inferring this answer. Generally, results will include SKSI
 * sources, or terms used in meta-assertions using sourceOfTerm-NonTrivial or its specializations.
 * Note that this method works by introspecting on the inference object, and will not work if the
 * inference has already been destroyed when this is called. The canonical way of ensuring that
 * the inference is not destroyed immediately is to call 
 * {@link com.cyc.query.Query#retainInference()}, though there are other ways of ensuring the 
 * inference is not immediately destroyed, such as 
 * {@link com.cyc.query.Query#setBrowsable(boolean)} and 
 * {@link com.cyc.query.Query#setContinuable(boolean)}.
 *
 * @return A set of KbTerms that are the attributed sources for this answer.
 */
Set<KbTerm> getSources();
 
开发者ID:cycorp,项目名称:api-suite,代码行数:15,代码来源:QueryAnswer.java

示例7: get

import com.cyc.kb.KbTerm; //导入依赖的package包/类
/**
 * Get the <code>KbTerm</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 #$Thing.
 *
 * @param nameOrId the string representation or the HLID of the term
 *
 * @return a new KbTerm
 *
 * @throws KbTypeException
 * @throws CreateException
 */
KbTerm get(String nameOrId) throws KbTypeException, CreateException;
 
开发者ID:cycorp,项目名称:api-suite,代码行数:13,代码来源:KbTermService.java

示例8: findOrCreate

import com.cyc.kb.KbTerm; //导入依赖的package包/类
/**
 * Find or create a <code>KbTerm</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>#$Thing</code>. If there is already an object in the KB called
 * <code>nameOrId</code>, it will be returned.
 *
 * @param nameOrId the string representation or the HLID of the term
 *
 * @return a new KbTerm
 *
 * @throws KbTypeException
 * @throws CreateException
 */
KbTerm findOrCreate(String nameOrId) throws CreateException, KbTypeException;
 
开发者ID:cycorp,项目名称:api-suite,代码行数:15,代码来源:KbTermService.java


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