写耶拿内置插件 [英] writing Jena built-ins

查看:113
本文介绍了写耶拿内置插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写 Jena内置以返回值从我给出的算法开始,然后对该值进行比较,例如,

I'm trying to write a Jena built-in to return a value from an algorithm I have been given and then do a comparison against that value, e.g.,

String rule = "[exRule: (?d rdf:type ex:abc)" +
              "<-" +
              // ...extract ?a, ?b to use as inputs to the rule
          "greaterThan(myBuiltIn(?a, ?b), 1)" +  // Is return value greater than 1
      "]";

首先, Jena文档说最简单的实验方法是查看builtins目录中的示例,但是我的安装中似乎没有这个,我在Windows 7上使用Jena 2.6.4。我在哪里可以找到它?我是否需要从其他地方下载?

So, first the Jena documentation says that the easiest way to experiment with this is to look at the examples in the builtins directory, however I don't seem to have this in my installation, I'm using Jena 2.6.4 on Windows 7. Where can I find this? Do I need to download it from elsewhere?

其次,我不确定如何从我的内置中获取返回值。如果我只是使用硬连线值调用 myBuiltIn(2,1)我知道它被调用,因为我已经添加到内置的 bodyCall中的一些调试输出()方法。但是,如果我将它传递给 greaterThan(),那么我就不会再看到这个了。还在被叫吗?

Secondly, I'm unsure how to pick up the return value from my builtin. If I simply call myBuiltIn(2, 1) using hardwired values I know it's being called due to some debug output I've added to the builtin's bodyCall() method. However, if I pass it to greaterThan(), then I no longer see this. Is it still being called?

推荐答案

@Joshua

我找到了如何实现这一点。

I found how to implement this.

首先,你应该创建一个从 BaseBuiltin 扩展的新类,如下所示 http://sadl.sourceforge.net/CustomJenaBuiltins.html

First of all, you should create a new class that extend from BaseBuiltin like this http://sadl.sourceforge.net/CustomJenaBuiltins.html

然后将其添加到builtinRegistry类

and then add it into builtinRegistry class

这篇关于写耶拿内置插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆