本文整理汇总了Java中com.cyc.kb.BinaryPredicate类的典型用法代码示例。如果您正苦于以下问题:Java BinaryPredicate类的具体用法?Java BinaryPredicate怎么用?Java BinaryPredicate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BinaryPredicate类属于com.cyc.kb包,在下文中一共展示了BinaryPredicate类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initBinaryPredicate
import com.cyc.kb.BinaryPredicate; //导入依赖的package包/类
private static BinaryPredicate initBinaryPredicate(String nameOrId) {
try {
return Cyc.getBinaryPredicateService().get(nameOrId);
} catch (KbException ex) {
return handleException(BinaryPredicate.class, nameOrId, ex);
}
}
示例2: setupMarvinGardens
import com.cyc.kb.BinaryPredicate; //导入依赖的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);
}
示例3: addArg1
import com.cyc.kb.BinaryPredicate; //导入依赖的package包/类
@Override
public Fact addArg1(BinaryPredicate binPred, Object arg1, Context ctx) throws KBTypeException, CreateException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
示例4: addArg2
import com.cyc.kb.BinaryPredicate; //导入依赖的package包/类
@Override
public Fact addArg2(BinaryPredicate binPred, Object arg2, Context ctx) throws KBTypeException, CreateException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
示例5: wrapped
import com.cyc.kb.BinaryPredicate; //导入依赖的package包/类
@Override
protected abstract BinaryPredicate wrapped();
示例6: setupActorBackgroundKnowledge
import com.cyc.kb.BinaryPredicate; //导入依赖的package包/类
/**
* Add general background knowledge about actors. Later, this will be leveraged to associated Jack
* Nicholson with the movie _King of Marvin Gardens_.
*
* @throws CreateException
* @throws KbTypeException
*/
protected void setupActorBackgroundKnowledge()
throws CreateException, KbTypeException {
System.out.println();
/*
Since we will be talking about Jack Nicholson, we have to make sure Cyc knows about actors.
Most Cyc releases will already have this term, but just in case, here's how you go about
creating it. Don't worry if it's already in your Cyc KB. These operations are idempotent, so
running them in a Cyc that already has the terms won't do anything bad. When in doubt, the
following idiom is most useful.
*/
actorInMovies = KbCollection.findOrCreate("ActorInMovies");
/*
Let's also convey the fact that all movie actors are people. (Our apologies to the highly
trained animals who have sometimes carried movies on their shoulders). We assume the collection
Person already exists and we only have to specify the name to retrieve it.
*/
actorInMovies.addGeneralization(KbCollection.get("Person"));
/*
We need a way to relate actors to the movies they are in. Let's call the relation
"movieActors". This particular predicate already exists in Cyc, but if it didn't, this is how
you would create it.
*/
movieActors = BinaryPredicate.findOrCreate("movieActors");
System.out.println("Binary predicate associating actors with movies: " + movieActors);
/*
It is always a good idea to put constraints on the arguments of predicates for semantic
validity. The following establishes in the KB (in the MassMediaDataMt context) that the first
argument of movieActors must be an instance of the collection Movie-CW and the second argument
must be an instance of the collection ActorInMovies. (Note that #$DramaticMovie is a spec of
#$Movie-CW, so #$TheKingOfMarvinGardens-TheMovie will be a valid argument for arg1.)
*/
System.out.println("Asserting constraints on #$movieActors,"
+ " these might take a little while to propagate...");
movieActors.addArgIsa(1, KbCollection.get("Movie-CW"), Context.get("MassMediaDataMt"));
movieActors.addArgIsa(2, KbCollection.get("ActorInMovies"), Context.get("MassMediaDataMt"));
/*
Of course, some movie actors have a starring role. To add this more specific knowledge to the
KB, we need a more specific predicate; let's call it "movieActors-WithStarringRole". Again,
this predicate already exists in most Cyc KBs, so the following will typically retrieve, rather
than create, the predicate in most Cyc KBs.
*/
System.out.println("Asserting constraints on #$movieActors-WithStarringRole,"
+ " these might take a little while to propagate...");
movieActorsWithStarringRole = BinaryPredicate.findOrCreate("movieActors-WithStarringRole");
movieActorsWithStarringRole.addArgIsa(1, KbCollection.get("Movie-CW"), Context.get("MassMediaDataMt"));
movieActorsWithStarringRole.addArgIsa(2, KbCollection.get("ActorInMovies"), Context.get("MassMediaDataMt"));
/*
Finally, let's establish that movieActors is a generalization of
movieActorsWithStarringRole
*/
movieActorsWithStarringRole.addGeneralization(KbPredicate.get("movieActors"), Context.get("UniversalVocabularyMt"));
/*
Now, let's view all of the specializations on #$movieActors.
*/
System.out.println("Specializations of #$movieActors:");
movieActors.getSpecializations()
.forEach(spec -> System.out.println(" - " + spec));
}
示例7: get
import com.cyc.kb.BinaryPredicate; //导入依赖的package包/类
/**
* Get the <code>BinaryPredicate</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 #$BinaryPredicate.
*
* @param nameOrId the string representation or the HLID of the #$BinaryPredicate
*
* @return a new BinaryPredicate
*
* @throws KbTypeException
* @throws CreateException
*/
@Override
BinaryPredicate get(String nameOrId) throws KbTypeException, CreateException;
示例8: findOrCreate
import com.cyc.kb.BinaryPredicate; //导入依赖的package包/类
/**
* Find or create a <code>BinaryPredicate</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>#$BinaryPredicate</code>. If there is already an object in
* the KB called <code>nameOrId</code>, and it is already a <code>#$BinaryPredicate</code>, it
* will be returned. If it is not already a <code>#$BinaryPredicate</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>#$BinaryPredicate</code> by
* adding assertions (i.e. some existing assertion prevents it from being a
* <code>#$BinaryPredicate</code>), a <code>KbTypeConflictException</code>will be thrown.
*
* @param nameOrId the string representation or the HLID of the #$BinaryPredicate
*
* @return a new BinaryPredicate
*
* @throws KbTypeException
* @throws CreateException
*/
@Override
BinaryPredicate findOrCreate(String nameOrId) throws CreateException, KbTypeException;