Dan Bolser | 10 Mar 00:58 2011
Picon

Recursive ask using format=template, stuck at depth of 3?

Hi,

I wrote a nice 'recursive' template to traverse a DAG here:
http://scratchpad.referata.com/wiki/Template:Part_of_what

It works by calling itself with an ask using it's given input and then
the result of the ask and so on up the DAG ... (recursion always makes
me a little dizzy).

It works great except it only calls itself a maximum of 3 times, as
evidenced by comparing the results of these two pages:
* http://scratchpad.referata.com/wiki/Piston
* http://scratchpad.referata.com/wiki/Engine

I couldn't find the appropriate setting in the manual to bump this
'maximum recursion' value. The equivalent value for MediaWiki can be
found here, but note the default setting is a whopping 40:

http://www.mediawiki.org/wiki/Manual:$wgMaxTemplateDepth

Any tips appreciated.

Cheers,
Dan.

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
(Continue reading)

Alex M. Hendler | 10 Mar 08:39 2011

Re: Recursive ask using format=template, stuck at depth of 3?

Dan, 

I believe the setting you're looking for is 

SMWResultPrinter::$maxRecursionDepth = x;

Place that after your enableSemantics statement in LocalSettings.php,
where x = [desired depth]-1. 

The reason you can't get beyond 3 levels on Referata is that (I believe)
it uses the default max. depth of 2. includes/SMW_QueryPrinter.php
explains the recursion settings very well. 

The developers can correct me if I am wrong, but I believe that
recursion is intentionally not more publicly documented (i.e., outside
of source code) because it can do odd and perhaps unpredictable things
to semantics as well as performance if you increase it above 2. 

You can sometimes fool the system into recursing beyond
maxRecursionDepth, but that is not something I would encourage anyone to
do intentionally (it also prints out very messy results). 

Hope this helps, 
Alex

----Original Message-----
From: Dan Bolser <dan.bolser@...>
To: Semantic MediaWiki Users <semediawiki-user@...>
Subject: [Semediawiki-user] Recursive ask using format=template, stuck
at depth of 3?
(Continue reading)

Dan Bolser | 10 Mar 11:00 2011
Picon

Re: Recursive ask using format=template, stuck at depth of 3?

Thanks Alex.

I read the document you suggested:
http://semantic-mediawiki.org/doc/SMW__QueryPrinter_8php-source.html

but I expected to see why the settings are what they are (i.e. why so
low), which I don't see.

Do you think those 'odd' issues that you mention would to this simple
recursive query? Perhaps I'm being naive, but it seems to work so well
up to the given depth... would performance degrade super-linearly with
increased depth?

Alternatively, the Semantic TreeView extension looks promising:

* http://smwforum.ontoprise.com/smwforum/index.php/Help:Description_of_the_tree_parser_function
* http://smwforum.ontoprise.com/smwforum/index.php/Help:Description_of_the_generateTree_parser_function

but it isn't clear from the documentation if you need to install halo
or not (some places state halo as a requirement, while other
information suggests that it isn't) ... I guess I'll just suck it and
see... The biggest problem is that it expects a tree while I have a
DAG... Not sure what that'll do to it.

Any other suggested extensions for navigating relations? (Other than
Special:Browse of course!)

Cheers,
Dan.

(Continue reading)

Alex M. Hendler | 10 Mar 13:27 2011

Re: Recursive ask using format=template, stuck at depth of 3?

Hi Dan, 

I am not sure what "your own risk!" means, but whenever I see an
exclamation point in the body of a comment that is not telling you how
super-cool a feature is, I get a bit scared. 

That said, I can foresee a problem if you set recursion depth too high
and someone made an error such that a page that gets returned by the
query is "part of" the querying page, then you just end up with loopy
(literally) query results. 

As for performance, in my experience (still yet to be confirmed by
others) maxRecursionDepth > 2 may cause odd property inheritance
behavior if you embed or transclude pages. See
https://bugzilla.wikimedia.org/show_bug.cgi?id=27445 

I hope this helps point you in the right direction in terms of doing
what you need to do (it looks like maybe a template with known levels of
properties, e.g., [[-Part of::x]] passed through sufficient levels of
arrays/arraymaps and #if: statements would be a good bet); hopefully
someone else will be able to better answer your performance question. 

As for SemanticTreeView, it looks like it must be installed with Halo,
but the Ontoprise folks may have a different view of that.

-Alex

-
----Original Message-----
From: Dan Bolser <dan.bolser@...>
(Continue reading)

Dan Bolser | 10 Mar 14:54 2011
Picon

Re: Recursive ask using format=template, stuck at depth of 3?

On 10 March 2011 12:27, Alex M. Hendler <amh.public@...> wrote:
> Hi Dan,
>
> I am not sure what "your own risk!" means, but whenever I see an
> exclamation point in the body of a comment that is not telling you how
> super-cool a feature is, I get a bit scared.

I don't see that online here:
http://semantic-mediawiki.org/doc/SMW__QueryPrinter_8php-source.html

Perhaps it's a version issue, but in any case, I take your point.

> That said, I can foresee a problem if you set recursion depth too high
> and someone made an error such that a page that gets returned by the
> query is "part of" the querying page, then you just end up with loopy
> (literally) query results.

Yeah, of course a page shouldn't be 'part of' itself, but there is
nothing to stop a user doing that.

> As for performance, in my experience (still yet to be confirmed by
> others) maxRecursionDepth > 2 may cause odd property inheritance
> behavior if you embed or transclude pages. See
> https://bugzilla.wikimedia.org/show_bug.cgi?id=27445

Weird bug! Seems to be a 'feature' of the embed format only with nested queries?

> I hope this helps point you in the right direction in terms of doing
> what you need to do (it looks like maybe a template with known levels of
> properties, e.g., [[-Part of::x]] passed through sufficient levels of
(Continue reading)


Gmane