以文本方式查看主题

-  W3CHINA.ORG讨论区 - 语义网·描述逻辑·本体·RDF·OWL  (http://bbs.xml.org.cn/index.asp)
--  『 Semantic Web(语义Web)/描述逻辑/本体 』  (http://bbs.xml.org.cn/list.asp?boardid=2)
----  [求助]Jena 抓 owl:thing 的 subclass問題?  (http://bbs.xml.org.cn/dispbbs.asp?boardid=2&rootid=&id=73114)


--  作者:j08102728
--  发布时间:3/16/2009 9:07:00 PM

--  [求助]Jena 抓 owl:thing 的 subclass問題?
小弟請問各位大大:
Jena 如何抓取owl:thing的subclass(owl:thing的第一層),因為我用 ontModel.listNamedClasses()去抓取,它會所有定義的subclass和super-subclass的抓出來,但小弟只想抓取 owl:thing的第一層,該如何去抓取呢?


--  作者:jpz6311whu
--  发布时间:3/16/2009 9:36:00 PM

--  
可以递归调用,找到所有类的父类,父类的父类,直到父类没有父类了,就是第一层了:
Interface OntClass
ExtendedIterator listSuperClasses(boolean direct)Answer an iterator over all of the classes that are super-classes of this class. Each element of the iterator will be an OntClass. See listSubClasses( boolean ) for a full explanation of the direct parameter.


Parameters:
direct - If true, only answer the directly adjacent classes in the super-class relation: i.e. eliminate any class for which there is a longer route to reach that child under the super-class relation.
Returns:
an iterator over the resources representing this class's sub-classes.
Throws:
OntProfileException - If the Profile.SUB_CLASS_OF() property is not supported in the current language profile.


--  作者:yolanda8487
--  发布时间:3/16/2009 10:50:00 PM

--  
使用 listHierarchyRootClasses 方法,不过注意加载本体的时候要用OWL_MEM_MICRO_RULE_INF这个参数,否则结果不正确
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
8,503.906ms