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


Java KBTriple.getSubject方法代码示例

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


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

示例1: 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

示例2: 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.getSubject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。