當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。