semantic mediawiki property calculation

隐身守侯 提交于 2019-12-24 06:42:46

问题


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:

[[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


回答1:


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]]}}



回答2:


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.



来源:https://stackoverflow.com/questions/3574172/semantic-mediawiki-property-calculation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!