本文整理汇总了Java中com.cyc.kb.KbPredicate类的典型用法代码示例。如果您正苦于以下问题:Java KbPredicate类的具体用法?Java KbPredicate怎么用?Java KbPredicate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KbPredicate类属于com.cyc.kb包,在下文中一共展示了KbPredicate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMethodPredicates
import com.cyc.kb.KbPredicate; //导入依赖的package包/类
/**
* This returns an ordered list of the Predicates which underly the class's
* MethodObjs, with no duplicate elements. This is valuable because a single
* predicate may be the basis for multiple MethodObjs (getters, setters, etc.)
*
* @return
*/
public List<KbPredicate> getMethodPredicates() {
Set<KbPredicate> set = new HashSet<KbPredicate>();
for (MethodObj method : getMethods()) {
set.add(method.getPredicate());
}
List<KbPredicate> list = new ArrayList(set);
Collections.sort(list, new Comparator<KbPredicate>() {
@Override
public int compare(KbPredicate o1, KbPredicate o2) {
if ((o2 == null) || !(o2 instanceof KbPredicate)) {
return 1;
}
return o1.toString().compareTo(o2.toString());
}
});
return list;
}
示例2: testRelationContexts
import com.cyc.kb.KbPredicate; //导入依赖的package包/类
@Test
public void testRelationContexts() throws KbException {
final Context collectionCtx = ContextFactory.get("UniversalVocabularyMt");
final Context defaultPredCtx = ContextFactory.get("EverythingPSC");
final Context Relation1Ctx = ContextFactory.get("CyclistsMt");
final KbPredicate predicate1 = KbPredicateFactory.get("cyclistPrimaryProject");
final KbPredicate predicate2 = KbPredicateFactory.get("groupsReviewer");
final ContextMap map = new SimpleContextMap(collectionCtx, defaultPredCtx);
((SimpleContextMap) map).getRelationContexts().put(predicate1, Relation1Ctx);
assertFalse(collectionCtx.equals(defaultPredCtx));
assertFalse(collectionCtx.equals(Relation1Ctx));
assertFalse(defaultPredCtx.equals(Relation1Ctx));
assertFalse(predicate1.equals(predicate2));
assertEquals(collectionCtx, map.getCollectionContext());
assertEquals(Relation1Ctx, map.getRelationContext(predicate1));
assertEquals(defaultPredCtx, map.getRelationContext(predicate2));
}
示例3: getPredicate
import com.cyc.kb.KbPredicate; //导入依赖的package包/类
public final KbPredicate getPredicate() {
/*
* TODO: this method should be modified or eliminated once MethodObj
* extends ModelObj<Predicate>
*/
try {
return KbPredicateFactory.get(getCycName());
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
示例4: initKbPredicate
import com.cyc.kb.KbPredicate; //导入依赖的package包/类
private static KbPredicate initKbPredicate(String nameOrId) {
try {
return Cyc.getKbPredicateService().get(nameOrId);
} catch (KbException ex) {
return handleException(KbPredicate.class, nameOrId, ex);
}
}
示例5: generateMethodObjFromPredicate
import com.cyc.kb.KbPredicate; //导入依赖的package包/类
public static MethodObj generateMethodObjFromPredicate(String predStr, KbCollection c) throws Exception{
MethodObj m = new MethodObj();
m.setVisibility("public");
m.setName(predStr);
KbPredicate p = KbPredicateFactory.get(predStr);
int pArity = p.getArity();
//int foundClassInPos = -1;
for (int i=1; i<=pArity; i++){
java.util.Collection<KbCollection> ac = p.getArgIsa(i, "UniversalVocabularyMt");
Set<KbCollection> cset = new HashSet<KbCollection>();
cset.addAll(c.getGeneralizations("UniversalVocabularyMt"));
cset.add(c);
System.out.println("Arg Pos: " + i + " Collections: " + ac);
System.out.println("C generalizations: " + cset);
KbCollection firstArgConstraint = ac.iterator().next();
if (cset.contains(firstArgConstraint)){
//foundClassInPos = i;
m.setArgPos(i);
} else {
m.addArgument(new ArgumentObj(firstArgConstraint.toString(), i));
/*
if (ac.get(0).toString().equals("Date")){
m.setArgumentTypes("java.util.Date");
} else {
m.setArgumentTypes(ac.get(0).toString());
}*/
}
}
//if (foundClassInPos == -1){
if (m.getArgPos() == null){
System.out.println("Could not find the location of " + c + " in predicate " + p);
} else {
System.out.println("Arguments: " + m.getArguments());
}
return m;
}
示例6: wrapped
import com.cyc.kb.KbPredicate; //导入依赖的package包/类
@Override
protected abstract KbPredicate wrapped();
示例7: getSpecializations
import com.cyc.kb.KbPredicate; //导入依赖的package包/类
@Override
public Collection<KbPredicate> getSpecializations() {
return wrapped().getSpecializations();
}
示例8: addSpecialization
import com.cyc.kb.KbPredicate; //导入依赖的package包/类
@Override
public KbPredicate addSpecialization(KbPredicate moreSpecific, Context ctx)
throws KbTypeException, CreateException {
return wrapped().addSpecialization(moreSpecific, ctx);
}
示例9: getGeneralizations
import com.cyc.kb.KbPredicate; //导入依赖的package包/类
@Override
public Collection<KbPredicate> getGeneralizations() throws KbException {
return wrapped().getGeneralizations();
}
示例10: getGeneralizationSentence
import com.cyc.kb.KbPredicate; //导入依赖的package包/类
@Override
public Sentence getGeneralizationSentence(KbPredicate moreGeneral)
throws KbTypeException, CreateException {
return wrapped().getGeneralizationSentence(moreGeneral);
}
示例11: getInverseGeneralizationSentence
import com.cyc.kb.KbPredicate; //导入依赖的package包/类
@Override
public Sentence getInverseGeneralizationSentence(KbPredicate moreGeneral)
throws KbTypeException, CreateException {
return wrapped().getInverseGeneralizationSentence(moreGeneral);
}
示例12: addGeneralization
import com.cyc.kb.KbPredicate; //导入依赖的package包/类
@Override
public KbPredicate addGeneralization(KbPredicate moreGeneral, Context ctx)
throws KbTypeException, CreateException {
return wrapped().addGeneralization(moreGeneral, ctx);
}
示例13: isGeneralizationOf
import com.cyc.kb.KbPredicate; //导入依赖的package包/类
@Override
public boolean isGeneralizationOf(KbPredicate moreSpecific, Context ctx) {
return wrapped().isGeneralizationOf(moreSpecific, ctx);
}
示例14: setupActorBackgroundKnowledge
import com.cyc.kb.KbPredicate; //导入依赖的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));
}
示例15: getNlPreds
import com.cyc.kb.KbPredicate; //导入依赖的package包/类
/**
*
* @return the list of agreement predicates to use
*/
List<KbPredicate> getNlPreds();