开发者

Semantic Mediawiki property calculation

I installed the MediaWiki-extension Semantic MediaWiki recently. In this extension you can define properties. They are like categories for values. If I define two properties like this:开发者_Go百科

[[StartYear::2000]] [[EndYear::2005]]

Is it possible to make calculations based on these properties if I do a semantic search. For example:

{{#ask: [[Category:Project]] [[EndYear]] - [[StartYear]] = 5 }}

to get all projects with a duration of 5 years?

best, UP


AFAICT, you can't do calculations in #ask queries, but you can do calculations, using the ParserFunction #expr:. It'd be, er, complicated to mix these together, but it should be possible. Comment if you successfully try it, and if I get a chance, I'll edit this answer with whatever I find out.


For this you would need to pre-process the interval for each project page.

If you are using a template, you can easily create do it with the following code:

[[Interval::{{#expr:{{{StartYear}}} - {{{EndYear}}}}}| ]]

Then you can query it this way:

{{#ask: [[Category:Project]] [[Interval::5]]}}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜