新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> 本版讨论Semantic Web(语义Web,语义网或语义万维网, Web 3.0)及相关理论,如:Ontology(本体,本体论), OWL(Web Ontology Langauge,Web本体语言), Description Logic(DL, 描述逻辑),RDFa,Ontology Engineering等。
    [返回] 中文XML论坛 - 专业的XML技术讨论区W3CHINA.ORG讨论区 - Web新技术讨论『 Semantic Web(语义Web)/描述逻辑/本体 』 → Jena文档《An Introduction to RDF and the Jena RDF API》的译文 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 707517 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: Jena文档《An Introduction to RDF and the Jena RDF API》的译文 举报  打印  推荐  IE收藏夹 
       本主题类别: RDF/RDFS | Jena | 中译文档    
     clandy 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(猛啃高等数学)
      文章:18
      积分:160
      门派:XML.ORG.CN
      注册:2006/5/26

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给clandy发送一个短消息 把clandy加入好友 查看clandy的个人资料 搜索clandy在『 Semantic Web(语义Web)/描述逻辑/本体 』的所有贴子 引用回复这个贴子 回复这个贴子 查看clandy的博客61
    发贴心情 

    好贴!学习ing
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2007/10/23 2:04:00
     
     30983638 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(高数修炼中)
      文章:20
      积分:137
      门派:XML.ORG.CN
      注册:2007/11/12

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给30983638发送一个短消息 把30983638加入好友 查看30983638的个人资料 搜索30983638在『 Semantic Web(语义Web)/描述逻辑/本体 』的所有贴子 引用回复这个贴子 回复这个贴子 查看30983638的博客62
    发贴心情 
    翻译得不错
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2007/11/24 15:25:00
     
     gazi945 帅哥哟,离线,有人找我吗?
      
      
      等级:大二(研究C++)
      文章:44
      积分:230
      门派:W3CHINA.ORG
      注册:2007/11/23

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给gazi945发送一个短消息 把gazi945加入好友 查看gazi945的个人资料 搜索gazi945在『 Semantic Web(语义Web)/描述逻辑/本体 』的所有贴子 引用回复这个贴子 回复这个贴子 查看gazi945的博客63
    发贴心情 
    实在是好东西
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2007/11/25 20:22:00
     
     chairmanwei 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(高数修炼中)
      文章:29
      积分:185
      门派:XML.ORG.CN
      注册:2007/8/19

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给chairmanwei发送一个短消息 把chairmanwei加入好友 查看chairmanwei的个人资料 搜索chairmanwei在『 Semantic Web(语义Web)/描述逻辑/本体 』的所有贴子 引用回复这个贴子 回复这个贴子 查看chairmanwei的博客64
    发贴心情 
    赞楼主一个先~
    不过这篇相对简单,不翻译无所谓,呵呵。
    要是把推理的api翻译出来,那就好了,嘿嘿~~
    楼主不是对你的工作不敬啊~
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2007/11/25 21:13:00
     
     supergg 帅哥哟,离线,有人找我吗?
      
      
      等级:大二(研究汇编)
      文章:31
      积分:235
      门派:XML.ORG.CN
      注册:2007/4/8

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给supergg发送一个短消息 把supergg加入好友 查看supergg的个人资料 搜索supergg在『 Semantic Web(语义Web)/描述逻辑/本体 』的所有贴子 访问supergg的主页 引用回复这个贴子 回复这个贴子 查看supergg的博客65
    发贴心情 

    ----------------------------------------------
    基于本体的知识库设计与实现!http://hi.baidu.com/ecgql

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2007/11/27 10:24:00
     
     delin 美女呀,离线,快来找我吧!
      
      
      等级:大一新生
      文章:0
      积分:55
      门派:XML.ORG.CN
      注册:2007/11/29

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给delin发送一个短消息 把delin加入好友 查看delin的个人资料 搜索delin在『 Semantic Web(语义Web)/描述逻辑/本体 』的所有贴子 引用回复这个贴子 回复这个贴子 查看delin的博客66
    发贴心情 
    赞一个!正在学习中!
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2007/12/20 18:22:00
     
     廋鹤一只 美女呀,离线,快来找我吧!
      
      
      等级:大二(研究汇编)
      文章:36
      积分:240
      门派:XML.ORG.CN
      注册:2005/12/31

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给廋鹤一只发送一个短消息 把廋鹤一只加入好友 查看廋鹤一只的个人资料 搜索廋鹤一只在『 Semantic Web(语义Web)/描述逻辑/本体 』的所有贴子 引用回复这个贴子 回复这个贴子 查看廋鹤一只的博客67
    发贴心情 
    thanks
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2007/12/23 22:02:00
     
     myldb_sw 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(猛啃高等数学)
      文章:9
      积分:104
      门派:XML.ORG.CN
      注册:2007/10/27

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给myldb_sw发送一个短消息 把myldb_sw加入好友 查看myldb_sw的个人资料 搜索myldb_sw在『 Semantic Web(语义Web)/描述逻辑/本体 』的所有贴子 引用回复这个贴子 回复这个贴子 查看myldb_sw的博客68
    发贴心情 
    非常谢谢,正准备学习如何使用Jena

    ----------------------------------------------
    请各位指教!谢谢!

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/1/14 21:10:00
     
     guffey 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(猛啃高等数学)
      文章:13
      积分:132
      门派:XML.ORG.CN
      注册:2007/7/17

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给guffey发送一个短消息 把guffey加入好友 查看guffey的个人资料 搜索guffey在『 Semantic Web(语义Web)/描述逻辑/本体 』的所有贴子 引用回复这个贴子 回复这个贴子 查看guffey的博客69
    发贴心情 
    55楼,现在的jena版本好象改用sparql了,这几个例子怎么用sparql改写一下呢?
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/2/7 21:08:00
     
     guffey 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(猛啃高等数学)
      文章:13
      积分:132
      门派:XML.ORG.CN
      注册:2007/7/17

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给guffey发送一个短消息 把guffey加入好友 查看guffey的个人资料 搜索guffey在『 Semantic Web(语义Web)/描述逻辑/本体 』的所有贴子 引用回复这个贴子 回复这个贴子 查看guffey的博客70
    发贴心情 
    import java.util.ArrayList;
    import java.util.List;

    import com.hp.hpl.jena.db.*;
    import com.hp.hpl.jena.graph.Node;
    import com.hp.hpl.jena.graph.Triple;
    import com.hp.hpl.jena.query.Query;
    import com.hp.hpl.jena.query.QueryExecution;
    import com.hp.hpl.jena.query.QueryExecutionFactory;
    import com.hp.hpl.jena.query.QueryFactory;
    import com.hp.hpl.jena.query.QuerySolutionMap;
    import com.hp.hpl.jena.query.ResultSet;
    import com.hp.hpl.jena.query.ResultSetFormatter;
    import com.hp.hpl.jena.rdf.model.Model;
    import com.hp.hpl.jena.rdf.model.RDFNode;
    import com.hp.hpl.jena.sparql.algebra.Algebra;
    import com.hp.hpl.jena.sparql.algebra.Op;
    import com.hp.hpl.jena.sparql.algebra.op.OpBGP;
    import com.hp.hpl.jena.sparql.core.BasicPattern;
    import com.hp.hpl.jena.sparql.core.Var;
    import com.hp.hpl.jena.sparql.engine.QueryIterator;
    import com.hp.hpl.jena.sparql.engine.ResultSetStream;
    import com.hp.hpl.jena.sparql.engine.binding.Binding;
    import com.hp.hpl.jena.sparql.util.FmtUtils;
    import com.hp.hpl.jena.sparql.util.IndentedWriter;

    /**
    * Executes an RDQL query to find the hypernym of a given word
    */
    public class FindHypernym {

     /** MySQL driver classname */
     private static final String mysqlDriver = "com.mysql.jdbc.Driver";

     /** URL of database to use */
     private static final String DB_URL = "jdbc:mysql://localhost/jena";
     private static final String DB_TYPE = "MySQL";

     /** User credentials */
     private static final String DB_USER = "user";
     private static final String DB_PASSWORD = "password";

     /** Name of the Jena model to create */
     private static final String MODEL_NAME = "wordnet";

     static public final String NL = System.getProperty("line.separator");

     /**
      * Finds the hypernym of a word given on the commandline
      */
     private static void printUsage() {
      System.out.print("\nUsage:\n");
      System.out.print("\tFindHypernym <hyponym>\n\n");
      System.out.print("\thyponym\t- The word to find hypernyms for\n");
     }
     public static void doSearch(Model m,String s){
      String BASE = "http://www.cogsci.princeton.edu/~wn/schema/" ;
      //Var var_hyponym = Var.alloc("hyponym") ;
            Var var_firstconcept = Var.alloc("firstconcept") ;
            Var var_hypernym = Var.alloc("hypernym");
            Var var_secondconcept = Var.alloc("secondconcept");
            Var var_definition = Var.alloc("definition");
            
            //WorkingVar wvar_hyponym = new WorkingVar();
      //wvar_hyponym.setString(s);
      Var var_hyponym=Var.alloc("hyponym");
      System.out.println(var_hyponym.toString());
            BasicPattern bp = new BasicPattern() ;
            bp.add(new Triple(var_firstconcept, Node.createURI(BASE+"wordForm"), var_hyponym)) ;
            bp.add(new Triple(var_firstconcept, Node.createURI(BASE+"hyponymOf"), var_secondconcept)) ;
            bp.add(new Triple(var_secondconcept, Node.createURI(BASE+"wordForm"), var_hypernym)) ;
            bp.add(new Triple(var_secondconcept, Node.createURI(BASE+"glossaryEntry"), var_definition)) ;
            
            Op op = new OpBGP(bp) ;
            m.write(System.out, "TTL") ;
            System.out.println("--------------") ;
            System.out.print(op) ;
            System.out.println("--------------") ;

            // ---- Execute expression
            QueryIterator qIter = Algebra.exec(op, m.getGraph()) ;
            
            // -------- Either read the query iterator directly ...
            if ( false )
            {
                for ( ; qIter.hasNext() ; )
                {
                    Binding b = qIter.nextBinding() ;
                    Node n = b.get(var_hypernym) ;
                    System.out.println(FmtUtils.stringForNode(n)) ;
                    Node n1 = b.get(var_definition) ;
                    System.out.println(FmtUtils.stringForNode(n1)) ;
                    System.out.println(b) ;
                }
                qIter.close() ;
            }
            else
            {
                // -------- Or make ResultSet from it (but not both - reading an
                //          iterator consumes the current solution)
                List varNames = new ArrayList() ;
                varNames.add("hypernym") ;
                varNames.add("definition") ;
                ResultSet rs = new ResultSetStream(varNames, m, qIter);
                ResultSetFormatter.out(rs) ;
                qIter.close() ;
            }
            //System.exit(0) ;
     }
     public static void main(String args[]) {

      // Check that the user provided a single argument
      if (args.length != 1) {
       printUsage();
       System.exit(-1);
      }

      try {
       // Instantiate database driver
       Class.forName(mysqlDriver);
      } catch (ClassNotFoundException e) {
       System.err.println("MySQL driver class not found");
       System.exit(-1);
      }

      // Get a connection to the db
      DBConnection connection = new DBConnection(DB_URL, DB_USER,
        DB_PASSWORD, DB_TYPE);

      // Get hold of the existing wordnet model
      ModelRDB model = ModelRDB.open(connection, MODEL_NAME);
      
      String prolog = "PREFIX wn: <http://www.cogsci.princeton.edu/~wn/schema/>";
      // Create a query
      
      String queryString = prolog + NL + "SELECT ?hypernym ?definition "
        + "WHERE {?firstconcept wn:wordForm ?hyponym. "
        + "?firstconcept wn:hyponymOf ?secondconcept. "
        + "?secondconcept wn:wordForm ?hypernym. "
        + "?secondconcept wn:glossaryEntry ?definition.} ";
      
      Query query = QueryFactory.create(queryString);
      query.serialize(new IndentedWriter(System.out, true));
      System.out.println();
      
      RDFNode hyponym = model.createLiteral(args[0]);
      //store the node in a QuerySolutionMap
      QuerySolutionMap initialBindings = new QuerySolutionMap();
      initialBindings.add("hyponym", hyponym);
       
      QueryExecution qexec = QueryExecutionFactory.create(query, model,initialBindings);
      ResultSet results = qexec.execSelect();
      // Output the results
      System.out.println("Hypernyms found for '" + args[0] + "':");
      System.out.println();
      ResultSetFormatter.out(System.out, results, query);
      qexec.close();
      System.out.println("========================");
      //doSearch(model,args[0]);
      try {
       // Close the database connection
       connection.close();
      } catch (java.sql.SQLException e) {
      }
     }

     // results.close() ;
     /* Property formword=model.CreateResouces()
     /*
      * ResIterator iter = model.listSubjectsWithProperty(); if (iter.hasNext()) {
      * System.out.println("The database contains vcards for:"); while
      * (iter.hasNext()) { System.out.println(" " + iter.nextStatement()
      * .getProperty(VCARD.FN) .getString()); } } else { System.out.println("No
      * vcards were found in the database"); }
      */
    }

    运行结果:
      1 PREFIX  wn:   <http://www.cogsci.princeton.edu/~wn/schema/>
      2
      3 SELECT  ?hypernym ?definition
      4 WHERE
      5   { ?firstconcept
      6               wn:wordForm       ?hyponym ;
      7               wn:hyponymOf      ?secondconcept .
      8     ?secondconcept
      9               wn:wordForm       ?hypernym ;
    10               wn:glossaryEntry  ?definition .
    11   }

    Hypernyms found for 'tiger':

    --------------------------------------------------------------------------------------------
    | hypernym     | definition                                                                |
    ============================================================================================
    | "big cat"    | "any of several large cats typically able to roar and living in the wild" |
    | "cat"        | "any of several large cats typically able to roar and living in the wild" |
    | "soul"       | "a human being; \"there was too much for one person to do\""              |
    | "human"      | "a human being; \"there was too much for one person to do\""              |
    | "individual" | "a human being; \"there was too much for one person to do\""              |
    | "mortal"     | "a human being; \"there was too much for one person to do\""              |
    | "person"     | "a human being; \"there was too much for one person to do\""              |
    | "somebody"   | "a human being; \"there was too much for one person to do\""              |
    | "someone"    | "a human being; \"there was too much for one person to do\""              |
    --------------------------------------------------------------------------------------------
    嗯,好象是运行成功了,不明白preson,somebody怎么也是上位词了呢。
    还有根据Algebra例子写的一个doSearch方法没完成,请高手指点一下,谢谢!

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/2/7 22:34:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 Semantic Web(语义Web)/描述逻辑/本体 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/3/28 9:44:27

    本主题贴数86,分页:[1] ... [4] [5] [6] [7] [8] [9]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    4,050.781ms