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

    >> Web服务(Web Services,WS), 语义Web服务(Semantic Web Services, SWS)讨论区: WSDL, SOAP, UDDI, DAML-S, OWL-S, SWSF, SWSL, WSMO, WSML,BPEL, BPEL4WS, WSFL, WS-*,REST, PSL, Pi-calculus(Pi演算), Petri-net,WSRF,
    [返回] W3CHINA.ORG讨论区 - 语义网·描述逻辑·本体·RDF·OWLW3CHINA.ORG讨论区 - Web新技术讨论『 Web Services & Semantic Web Services 』 → 求助:owl-s api 中的matchmaker 例子出错,高人请指教 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 14319 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 求助:owl-s api 中的matchmaker 例子出错,高人请指教 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     tianshiwgq 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(高数修炼中)
      文章:23
      积分:148
      门派:XML.ORG.CN
      注册:2007/9/10

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给tianshiwgq发送一个短消息 把tianshiwgq加入好友 查看tianshiwgq的个人资料 搜索tianshiwgq在『 Web Services & Semantic Web Services 』的所有贴子 引用回复这个贴子 回复这个贴子 查看tianshiwgq的博客楼主
    发贴心情 求助:owl-s api 中的matchmaker 例子出错,高人请指教

    修改后的原代码:
    public class Matchmaker {    
        OWLKnowledgeBase kb;
        
        public static class Match {
            public static String[] MATCHES = {"EXACT", "SUBSUME", "RELAXED", "FAIL"};
            public static int EXACT   = 0;
            public static int SUBSUME = 1;
            public static int RELAXED = 2;
            public static int FAIL    = 3;        
            
            int matchType;
            boolean listMatch;
            Service outputService;
            Output output;
            Service inputService;
            Input input;
            
            public Match(int matchType, Output output, Input input) {
                this.matchType = matchType;
                this.outputService = output.getService();
                this.output = output;
                this.inputService = input.getService();
                this.input = input;
            }
            
            public String toString() {
                String str = "";
                
                str += MATCHES[matchType] + " ";
                if(listMatch)
                    str += ".LIST";
                str += outputService.getLocalName() + "." + output.getLocalName();
                str += " -> ";
                str += inputService.getLocalName() + "." + input.getLocalName();
                
                return str;
            }
        }
        
        public Matchmaker() {
            kb = OWLFactory.createKB();
      
           kb.setReasoner("Pellet");
        }

        public void addOntology( String ont )  throws FileNotFoundException, URISyntaxException {
            System.out.println( "Reading " + ont );
            kb.read( new URI( ont ) );
        }
        
        public void addOntology( URI ont )  throws FileNotFoundException {
            System.out.println( "Reading " + ont );
            kb.read( ont );
        }
        
        public List findServices(boolean getProducers) {
            String hasParameter = getProducers ? "process:hasOutput" : "process:hasInput";
            
            String queryString =
                "SELECT * " +            
                "WHERE " +
                "    (?process rdf:type process:Process)" +
                "    (?process " + hasParameter + " ?param)" +
                "USING " +
                "      process FOR <http://www.daml.org/services/owl-s/1.1/Process.owl#>";

            return kb.query( queryString );
        }

        public List findOutputs() {
            return findServices(true);
        }
        
        public List findInputs() {
            return findServices(false);        
        }
        
        public int getMatchType(OWLType outputType, OWLType inputType) {
            if(outputType.isEquivalent(inputType))
               return Match.EXACT;
            else if(outputType.isSubTypeOf(inputType))
               return Match.SUBSUME;        
            else if(inputType.isSubTypeOf(outputType))
                return Match.RELAXED;
            else
                return Match.FAIL;
        }

     public List displayAllMatches() {
      List matches = new ArrayList();
      
      System.out.println( "Computing matches..." );
      
      List producers = findOutputs();
      List consumers = findInputs();
      
      Iterator i = producers.iterator();
      while( i.hasNext() ) {
          ValueMap binding = (ValueMap) i.next();
          Output output = (Output) ((OWLIndividual) binding.getValue("param")).castTo(Output.class);
          OWLType outputType = output.getParamType();
          
          Iterator j = consumers.iterator();
          while( j.hasNext() ) {
              binding = (ValueMap) j.next() ;
           Input input = (Input) ((OWLIndividual) binding.getValue("param")).castTo(Input.class);
           OWLType inputType = input.getParamType();
           
    //       System.out.println("Trying " +
    //           URIUtils.getLocalName(outputType.getURI()) + " " +
    //           URIUtils.getLocalName(inputType.getURI()) + " " +
    //           producer.getLocalName() + " " +
    //           output.getLocalName() + " " +
    //           consumer.getLocalName() + " " +
    //           input.getLocalName()
    //       );
           
              int matchType = getMatchType(outputType, inputType);
              if(matchType != Match.FAIL)
                  matches.add(new Match(matchType, output, input));           
          }
      }
      
      return matches;
     }

        public static void printIterator(Iterator i) {
            if(i.hasNext()) {
             while (i.hasNext())
                 System.out.println( i.next() );
            }       
            else
                System.out.println("<EMPTY>");
            
            System.out.println();
        }
     
        public static void main(String[] args) throws FileNotFoundException, URISyntaxException {
            Matchmaker matchmaker = new Matchmaker();
            
            matchmaker.addOntology("http://localhost:8080/BNPrice.owl");
            matchmaker.addOntology("http://www.mindswap.org/2004/owl-s/1.1/BookFinder.owl");
            matchmaker.addOntology("http://www.mindswap.org/2004/owl-s/1.1/CurrencyConverter.owl");
            matchmaker.addOntology("http://www.mindswap.org/2004/owl-s/1.1/Dictionary.owl");
            matchmaker.addOntology("http://www.mindswap.org/2004/owl-s/1.1/ZipCodeFinder.owl");
            matchmaker.addOntology("http://www.mindswap.org/2004/owl-s/1.1/FindLatLong.owl");
            matchmaker.addOntology("http://www.mindswap.org/2004/owl-s/1.1/BabelFishTranslator.owl#");
            
            List matches = matchmaker.displayAllMatches();
            System.out.println();
            System.out.println("Matches:");        
            printIterator(matches.iterator());
        }
    }
    运行错误,如下,不知道为什么,总是读不到顶极本体
    Reading http://localhost:8080/BNPrice.owl
    WARNING: Cannot read file http://www.daml.org/services/owl-s/1.1/Service.owl
    WARNING: The import file http://www.daml.org/services/owl-s/1.1/Service.owl cannot be parsed
    WARNING: Cannot read file http://www.daml.org/services/owl-s/1.1/Process.owl
    WARNING: The import file http://www.daml.org/services/owl-s/1.1/Process.owl cannot be parsed
    WARNING: Cannot read file http://www.daml.org/services/owl-s/1.1/generic/ObjectList.owl
    WARNING: The import file http://www.daml.org/services/owl-s/1.1/generic/ObjectList.owl cannot be parsed
    WARNING: Cannot read file http://www.daml.org/services/owl-s/1.1/generic/Expression.owl
    WARNING: The import file http://www.daml.org/services/owl-s/1.1/generic/Expression.owl cannot be parsed
    WARNING: Cannot read file http://www.daml.org/services/owl-s/1.1/Service.owl
    WARNING: The import file http://www.daml.org/services/owl-s/1.1/Service.owl cannot be parsed
    WARNING: Cannot read file http://www.mindswap.org/ontologies/bibtex.owl
    WARNING: The import file http://www.mindswap.org/ontologies/bibtex.owl cannot be parsed
    WARNING: Cannot read file http://www.mindswap.org/2004/owl-s/concepts.owl
    WARNING: The import file http://www.mindswap.org/2004/owl-s/concepts.owl cannot be parsed
    WARNING: Cannot read file http://localhost:8080/Grounding.owl
    WARNING: The import file http://localhost:8080/Grounding.owl cannot be parsed
    Reading http://www.mindswap.org/2004/owl-s/1.1/BookFinder.owl
    WARNING: Cannot read file http://www.mindswap.org/2004/owl-s/1.1/BookFinder.owl
    Exception in thread "main" java.io.FileNotFoundException: The file http://www.mindswap.org/2004/owl-s/1.1/BookFinder.owl cannot be parsed
     at impl.jena.OWLReaderImpl.createInputSource(OWLReaderImpl.java:125)
     at impl.jena.OWLReaderImpl.createInputSource(OWLReaderImpl.java:109)
     at impl.jena.OWLReaderImpl.read(OWLReaderImpl.java:169)
     at impl.jena.OWLKnowledgeBaseImpl.read(OWLKnowledgeBaseImpl.java:245)
     at examples.Matchmaker.addOntology(Matchmaker.java:76)
     at examples.Matchmaker.main(Matchmaker.java:170)


       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/12/5 12:05:00
     
     Patty 美女呀,离线,快来找我吧!
      
      
      等级:大一(高数修炼中)
      文章:16
      积分:136
      门派:XML.ORG.CN
      注册:2008/6/14

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给Patty发送一个短消息 把Patty加入好友 查看Patty的个人资料 搜索Patty在『 Web Services & Semantic Web Services 』的所有贴子 引用回复这个贴子 回复这个贴子 查看Patty的博客2
    发贴心情 
    我也有这样的问题,请问你解决了没有啊,网络上的这些文件貌似都不能访问,
        BNPrice.owl,BookFinder.owl,CurrencyConverter.owl,Dictionary.owl");,ZipCodeFinder.owl,FindLatLong.owl,BabelFishTranslator.owl,
    我把这些都放到本地了,但是还有顶层本体文件啊,不可能都复制到本地吧。

    不知道有没有其他朋友碰到,是怎么解决的,
    希望知道的朋友解释下。

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/12/20 10:41:00
     
     Patty 美女呀,离线,快来找我吧!
      
      
      等级:大一(高数修炼中)
      文章:16
      积分:136
      门派:XML.ORG.CN
      注册:2008/6/14

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给Patty发送一个短消息 把Patty加入好友 查看Patty的个人资料 搜索Patty在『 Web Services & Semantic Web Services 』的所有贴子 引用回复这个贴子 回复这个贴子 查看Patty的博客3
    发贴心情 
    可能是使用代理上网 的 原因
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/12/21 21:24:00
     
     tianshiwgq 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(高数修炼中)
      文章:23
      积分:148
      门派:XML.ORG.CN
      注册:2007/9/10

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给tianshiwgq发送一个短消息 把tianshiwgq加入好友 查看tianshiwgq的个人资料 搜索tianshiwgq在『 Web Services & Semantic Web Services 』的所有贴子 引用回复这个贴子 回复这个贴子 查看tianshiwgq的博客4
    发贴心情 
    谢谢,问题已解决,确实是代理的问题
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/12/22 9:30:00
     
     xiaoliwu 美女呀,离线,快来找我吧!
      
      
      等级:大一新生
      文章:2
      积分:56
      门派:XML.ORG.CN
      注册:2009/4/15

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给xiaoliwu发送一个短消息 把xiaoliwu加入好友 查看xiaoliwu的个人资料 搜索xiaoliwu在『 Web Services & Semantic Web Services 』的所有贴子 引用回复这个贴子 回复这个贴子 查看xiaoliwu的博客5
    发贴心情 
    求:从一个owl-s服务文档中提取precondition部分的谓词,用的Maryland的API
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2009/4/15 22:17:00
     
     yhxiao1983 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:4
      积分:80
      门派:XML.ORG.CN
      注册:2008/2/22

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给yhxiao1983发送一个短消息 把yhxiao1983加入好友 查看yhxiao1983的个人资料 搜索yhxiao1983在『 Web Services & Semantic Web Services 』的所有贴子 引用回复这个贴子 回复这个贴子 查看yhxiao1983的博客6
    发贴心情 
    以下是引用tianshiwgq在2008-12-22 9:30:00的发言:
    谢谢,问题已解决,确实是代理的问题

    我在家用电信的宽带上网,应该不是代理吧?可也有同样的问题。下到本地缓存可以,但总不能所有的都下下来。请问是如何解决的?

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2009/8/14 3:42:00
     
     charliezon 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:3
      积分:70
      门派:XML.ORG.CN
      注册:2006/5/12

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给charliezon发送一个短消息 把charliezon加入好友 查看charliezon的个人资料 搜索charliezon在『 Web Services & Semantic Web Services 』的所有贴子 引用回复这个贴子 回复这个贴子 查看charliezon的博客7
    发贴心情 
    能全部都下下来吧
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2010/6/1 11:47:00
     
     charliezon 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:3
      积分:70
      门派:XML.ORG.CN
      注册:2006/5/12

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给charliezon发送一个短消息 把charliezon加入好友 查看charliezon的个人资料 搜索charliezon在『 Web Services & Semantic Web Services 』的所有贴子 引用回复这个贴子 回复这个贴子 查看charliezon的博客8
    发贴心情 
    不包括mindswap提供的本体和其他领域本体的话,加起来只用到了以下owl文件:
    ActorDefault.owl
    Service.owl
    Profile.owl
    Process.owl
    Grounding.owl
    Resource.owl
    ProfileDeprecatedElements.owl
    ProfileAddtionalParameters.owl
    generic/Expression.owl
    generic/ObjectList.owl

    全部下下来,然后修改部分文件中import的url就可以了。命名空间不要修改。

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2010/6/2 16:31:00
     
     hyb22ndf 美女呀,离线,快来找我吧!
      
      
      等级:大一(高数修炼中)
      文章:14
      积分:103
      门派:XML.ORG.CN
      注册:2012/3/1

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给hyb22ndf发送一个短消息 把hyb22ndf加入好友 查看hyb22ndf的个人资料 搜索hyb22ndf在『 Web Services & Semantic Web Services 』的所有贴子 点击这里发送电邮给hyb22ndf  引用回复这个贴子 回复这个贴子 查看hyb22ndf的博客9
    发贴心情 匹配
    能不能把那个匹配的代码给我看看,急!!!

    ----------------------------------------------
    等待就是浪费青春

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2012/4/26 11:26:00
     
     zkblsb 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:2
      积分:59
      门派:XML.ORG.CN
      注册:2012/6/6

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给zkblsb发送一个短消息 把zkblsb加入好友 查看zkblsb的个人资料 搜索zkblsb在『 Web Services & Semantic Web Services 』的所有贴子 引用回复这个贴子 回复这个贴子 查看zkblsb的博客10
    发贴心情 
    服务器代理的问题,找找空间商,看看他那是不是出错了。

    [url=http://www.xtzt.com/]中空玻璃设备[/url]|[url=http://www.xtzt.com/]中空玻璃机器[/url]|[url=http://www.xtzt.com/]中空玻璃生产线[/url]|

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2012/6/6 9:20:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 Web Services & Semantic Web Services 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/4/19 12:39:47

    本主题贴数10,分页: [1]

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