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


Java KBTriple类代码示例

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


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

示例1: moveDatatypeParent

import edu.isi.wings.ontapi.KBTriple; //导入依赖的package包/类
@Override
public boolean moveDatatypeParent(String dtypeid, String fromtypeid, String totypeid) {
  KBObject cls = this.kb.getConcept(dtypeid);
  KBObject fromcls = this.kb.getConcept(fromtypeid);
  KBObject tocls = this.kb.getConcept(totypeid);
  ArrayList<KBObject> oldprops = this.kb.getPropertiesOfClass(fromcls, false);
  ArrayList<KBObject> newprops = this.kb.getPropertiesOfClass(tocls, false);
  ArrayList<KBObject> removedProps = new ArrayList<KBObject>(); 
  for(KBObject oldprop : oldprops) {
    if(!newprops.contains(oldprop)) {
      removedProps.add(oldprop);
    }
  }
  
  for(KBObject ind : this.kb.getInstancesOfClass(cls, false)) {
    for(KBObject prop : removedProps) {
      for(KBTriple triple : this.kb.genericTripleQuery(ind, prop, null)) 
        this.libkb.removeTriple(triple);
    }
  }
  
  if(!this.ontkb.setSuperClass(dtypeid, totypeid))
    return false;
  
  return true;
}
 
开发者ID:IKCAP,项目名称:turbosoft,代码行数:27,代码来源:DataKB.java

示例2: fetchEnumerationsFromKB

import edu.isi.wings.ontapi.KBTriple; //导入依赖的package包/类
private void fetchEnumerationsFromKB() {
  try {
    KBAPI allkb = fac.getKB(uniongraph, OntSpec.PLAIN);
    KBObject rdftype = ontkb.getProperty(KBConstants.RDFNS() + "type");
    MetadataType enumtype = this.vocabulary.getType(KBConstants.ONTNS() + "EnumerationEntity");
    //MetadataType swtype = this.vocabulary.getType(KBConstants.ONTNS() + "Software");
    
    enumerations = new HashMap<String, List<MetadataEnumeration>>();
    
    for(MetadataType type : this.vocabulary.getSubTypes(enumtype)) {
      List<MetadataEnumeration> typeenums = new ArrayList<MetadataEnumeration>();
      KBAPI kb = enumkb;
      //if(vocabulary.isA(type, swtype))
          kb = allkb;
      for(KBTriple t : kb.genericTripleQuery(null, rdftype, ontkb.getConcept(type.getId()))) {
        MetadataEnumeration menum = new MetadataEnumeration();
        KBObject inst = t.getSubject();
        menum.setId(inst.getID());
        menum.setName(inst.getName());
        menum.setType(type.getId());
        String label = this.ontkb.getLabel(inst);
        if(label == null)
          label = inst.getName();
        menum.setLabel(label);

        typeenums.add(menum);
      }
      enumerations.put(type.getId(), typeenums);
    }
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:KnowledgeCaptureAndDiscovery,项目名称:ontosoft,代码行数:34,代码来源:SoftwareRepository.java

示例3: createEntailments

import edu.isi.wings.ontapi.KBTriple; //导入依赖的package包/类
private ArrayList<KBTriple> createEntailments(KBAPI kb, KBObject obj, 
    KBObject cls, KBObject typeProp, ArrayList<KBTriple> triples) {
  for(KBObject supercls : kb.getSuperClasses(cls, false)) {
    KBTriple triple = this.ontologyFactory.getTriple(obj, typeProp, supercls);
    triples.add(triple);
    kb.addTriple(triple);
    triples = this.createEntailments(kb, obj, supercls, typeProp, triples);
  }
  return triples;
}
 
开发者ID:IKCAP,项目名称:turbosoft,代码行数:11,代码来源:SoftwareKB.java

示例4: removeAllTriplesWith

import edu.isi.wings.ontapi.KBTriple; //导入依赖的package包/类
public static void removeAllTriplesWith(KBAPI kb, String id, boolean prop) {
	KBObject obj = kb.getResource(id);
	ArrayList<KBTriple> triples = kb.genericTripleQuery(obj, null, null);
	if (prop) {
		obj = kb.getProperty(id);
		triples.addAll(kb.genericTripleQuery(null, obj, null));
	}
	triples.addAll(kb.genericTripleQuery(null, null, obj));
	for (KBTriple triple : triples)
		kb.removeTriple(triple);
}
 
开发者ID:IKCAP,项目名称:turbosoft,代码行数:12,代码来源:KBUtils.java

示例5: renameTripleNamespace

import edu.isi.wings.ontapi.KBTriple; //导入依赖的package包/类
public static void renameTripleNamespace(KBAPI kb, String oldns, String newns) {
	ArrayList<KBTriple> triples = kb.genericTripleQuery(null, null, null);
	for (KBTriple t : triples) {
		kb.removeTriple(t);
		t.setSubject(renameKBObjectNamespace(kb, t.getSubject(), oldns, newns));
		t.setPredicate(renameKBObjectNamespace(kb, t.getPredicate(), oldns, newns));
		t.setObject(renameKBObjectNamespace(kb, t.getObject(), oldns, newns));
		kb.addTriple(t);
	}
}
 
开发者ID:IKCAP,项目名称:turbosoft,代码行数:11,代码来源:KBUtils.java

示例6: createStandardName

import edu.isi.wings.ontapi.KBTriple; //导入依赖的package包/类
private KBObject createStandardName(StandardName sname, HashMap<String, String> labels) {
  KBObject objProp = propMap.get("hasObject");
  KBObject qProp = propMap.get("hasQuantity");
  KBObject opProp = propMap.get("hasOperator");
  KBObject opProp2 = propMap.get("hasSecondOperator");
  
  KBObject obj = kb.getIndividual(sname.getObjectId());
  if (obj == null) 
    obj = this.createObject(new SNObject(sname.getObjectId()), labels);
  
  KBObject qobj = kb.getIndividual(sname.getQuantityId());
  if (qobj == null)
    qobj = this.createQuantity(new SNQuantity(sname.getQuantityId()), labels);

  KBObject opobj1 = null;
  KBObject opobj2 = null;
  ArrayList<String> opids = sname.getOperatorIds();
  if (opids.size() > 0) {
    opobj1 = kb.getIndividual(opids.get(0));
    if (opobj1 == null) {
      opobj1 = this.createOperator(new SNOperator(opids.get(0)), labels);
    }
    if (opids.size() > 1) {
      opobj2 = kb.getIndividual(opids.get(1));
      if (opobj2 == null) 
        opobj2 = this.createOperator(new SNOperator(opids.get(1)), labels);
    }
  }
  
  // Check if a Standard name already exists with the combination above
  KBObject snameobj = null;
  for (KBTriple t : kb.genericTripleQuery(null, objProp, obj)) {
    KBObject snobj = t.getSubject();
    KBObject snqobj = kb.getPropertyValue(snobj, qProp);
    if (snqobj.getID().equals(qobj.getID())) {
      
      KBObject snopobj1 = kb.getPropertyValue(snobj, opProp);
      if(opobj1 != null && snopobj1 == null)
        continue;
      if(opobj1 == null && snopobj1 != null)
        continue;
      if (opobj1 != null && !opobj1.getID().equals(snopobj1.getID()))
          continue;
      
      KBObject snopobj2 = kb.getPropertyValue(snobj, opProp2);
      if(opobj2 != null && snopobj2 == null)
        continue;
      if(opobj2 == null && snopobj2 != null)
        continue;
      if (opobj2 != null && !opobj2.getID().equals(snopobj2.getID()))
        continue;
      
      // Everything matches !
      snameobj = snobj;
      break;
    }
  }
  
  // If it doesn't exist, then create one
  if(snameobj == null) {
    KBObject cls = conceptMap.get(this.ontns + "StandardName");
    snameobj = this.writerkb.createObjectOfClass(sname.getID(), cls);
    this.writerkb.setLabel(snameobj, sname.getLabel());
    
    this.writerkb.setPropertyValue(snameobj, objProp, obj);
    this.writerkb.setPropertyValue(snameobj, qProp, qobj);
    if(opobj1 != null)
      this.writerkb.setPropertyValue(snameobj, opProp, opobj1);
    if(opobj2 != null)
      this.writerkb.setPropertyValue(snameobj, opProp2, opobj1);
    this.addURIEntityProvenance(snameobj, sname);
  }
  
  return snameobj;
}
 
开发者ID:IKCAP,项目名称:turbosoft,代码行数:76,代码来源:SoftwareKB.java


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