Excluding groups of pages from Semantic query

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Excluding groups of pages from Semantic query

Peter Yang
Hello,


I'm kindly asking for help as a novice with trouble I've had figuring out how to exclude certain pages from some queries that I use on a wiki at HemOnc.org. Apologies in advance if syntax for my guesses are misformatted.  I've tried looking at pages such as https//www.semantic-mediawiki.org/wiki/Help:Selecting_pages without being able to figure things out.


I currently have pages with several "regimens," which I label individually as such {{#subobject:d9be78|Regimen=1}} with a random string for the subobject, because all I actually care about is a sum.  On each page, I add the total number of labels up and display it on that page using:

{{#ask: [[-Has subobject::{{FULLPAGENAME}}]] |?Regimen |limit=10000|format=sum}}


On the main page of the website, I also run a query of the total number of regimens throughout the whole site using:

{{#ask: [[Regimen::+]] |?Regimen |limit=10000|format=sum}}


I am starting to transclude copies of these regimens to other pages that display this information in different ways, but this appears to create duplicates when counting sums on the main page in the way that I do so above.


What is the recommended best practice way for me to exclude certain pages with duplicate information from being included in this count:


1. For example, if all of the pages i wish to exclude are labeled with Category:Regimen-specific pages, can I form a query to exclude all pages which are a member of a certain category?   How would I format the correct query using the example above?  I don't think this is right:

{#ask: [[Regimen::+||!Category:Regimen-specific pages]] |?Regimen |limit=10000|format=sum}}


2. May I put a property value like {{#subobject:ExcludeSemantic|answer=yes}} which will allow me to exclude any pages which that is present on, and use that to avoid inclusion in a query?  If so, how would I format that query?

3. Is there some "magic word" or tags like MediaWiki's <nowiki></nowiki> which I could use on a page that's going to be transcluded to limit whether its contents are used for Semantic queries?


Thank you,

Peter
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|

Re: Excluding groups of pages from Semantic query

lbillett
Hi Peter,
Peter Yang wrote
I am starting to transclude copies of these regimens to other pages that display this information in different ways, but this appears to create duplicates when counting sums on the main page in the way that I do so above.
Transcluding the information from the articles in which the properties exist might be what you want to work around. Not understanding exactly what you're trying to do, I'd make sure you're only displaying this information, using queries etc., not transcluding them such that the properties get set up for those articles too.

1. For example, if all of the pages i wish to exclude are labeled with Category:Regimen-specific pages, can I form a query to exclude all pages which are a member of a certain category?   How would I format the correct query using the example above?  I don't think this is right:
Subobjects themselves don't get category membership, so I don't think that would work.

2. May I put a property value like {{#subobject:ExcludeSemantic|answer=yes}} which will allow me to exclude any pages which that is present on, and use that to avoid inclusion in a query?  If so, how would I format that query?
Again, since you're setting up a bunch of subobjects, EACH subobject would need to get some kind of property set to allow this. Which would be fine, though if they're all being transcluded directly from their native pages, not sure how you'd set it differently for each one.

Hope that helps some. Alternatively, depending on the output you're trying to get,  you could feed the query result (without the sums) to an intermediate template that could string together the expression without the dupes. You'd basically use Extension:Variables to compare the values/ids you're getting and only create output if the record is NOT the same as the last one (assumes sorting by subobject name portion, I think). Reference here [1].

[1] http://wikimedia.7.x6.nabble.com/Group-Results-by-Date-or-Return-Unique-Dates-in-Result-Set-td5046862.html
Reply | Threaded
Open this post in threaded view
|

Re: Excluding groups of pages from Semantic query

kghbln


Am 04.01.2017 um 03:28 schrieb lbillett:

> Hi Peter,
>
> Peter Yang wrote
>> I am starting to transclude copies of these regimens to other pages that
>> display this information in different ways, but this appears to create
>> duplicates when counting sums on the main page in the way that I do so
>> above.
>
> Transcluding the information from the articles in which the properties exist
> might be what you want to work around. Not understanding exactly what you're
> trying to do, I'd make sure you're only displaying this information, using
> queries etc., not transcluding them such that the properties get set up for
> those articles too.
>
>
>> 1. For example, if all of the pages i wish to exclude are labeled with
>> Category:Regimen-specific pages, can I form a query to exclude all pages
>> which are a member of a certain category?   How would I format the correct
>> query using the example above?  I don't think this is right:
>
> Subobjects themselves don't get category membership, so I don't think that
> would work.
>
Since SMW 2.3 you actually can. See [0]. These are only used internally,
i.e. the subobjects will not be shown in the catagories, but this allows
to query.

[0]
https://www.semantic-mediawiki.org/wiki/Help:Adding_subobjects#Using_categories


>
>> 2. May I put a property value like
>> {{#subobject:ExcludeSemantic|answer=yes}} which will allow me to exclude
>> any pages which that is present on, and use that to avoid inclusion in a
>> query?  If so, how would I format that query?
>
> Again, since you're setting up a bunch of subobjects, EACH subobject would
> need to get some kind of property set to allow this. Which would be fine,
> though if they're all being transcluded directly from their native pages,
> not sure how you'd set it differently for each one.
>
> Hope that helps some. Alternatively, depending on the output you're trying
> to get,  you could feed the query result (without the sums) to an
> intermediate template that could string together the expression without the
> dupes. You'd basically use Extension:Variables to compare the values/ids
> you're getting and only create output if the record is NOT the same as the
> last one (assumes sorting by subobject name portion, I think). Reference
> here [1].
>
> [1]
> http://wikimedia.7.x6.nabble.com/Group-Results-by-Date-or-Return-Unique-Dates-in-Result-Set-td5046862.html
>
>
>
>
> --
> View this message in context: http://wikimedia.7.x6.nabble.com/Excluding-groups-of-pages-from-Semantic-query-tp5070514p5070532.html
> Sent from the Semantic Mediawiki - User mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Semediawiki-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/semediawiki-user
>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user