This site is a playground for testing Semantic MediaWiki. All content entered or uploaded here may be deleted at any time, and nothing here should be assumed to be true.
Some content was copied from semanticweb.org – please visit this site for more reliable information and author attribution.
Help talk:Inline queries
From SMW-Sandbox
I must be dreaming... I can't believe Semantic MediaWiki stands this far allready;-) Nice job! --Joris Gillis 16:43, 14 May 2006 (CEST)
[edit] Discussion of template examples
I recommend showing the code of the template to make the template examples clearer, i.e.,
Template:Query_output_demo contains:
UNIQ1b18a9a22ccede4d-pre-00000000-QINUI'd add that myself but the page is protected.
In the second template example, if it is intended as an example of how to do it wrong, that should be clearly stated; if not, it's incorrect and should be fixed. I presume this example has something to do with the explanation of "if the selected page itself would normally be produced...", but that explanation is not very clear, nor is the example's connection, if any, to that explanation made clear. It appears to me that mainlabel is broken or changed; see Rvs_test_1.
[edit] Template support question
I was wondering why, when you specify a template to use, and you specify the header titles for a particular attribute/relation, it doesn't pass these variables into the template with those names. Is it a technical issue, a theoretical issue (Does that screw something up that I don't see?) or a priority issue? If it isn't the second I wouldn't mind looking into it to add this support. If it is, why? --Jberger 07:09, 24 June 2007 (CEST)
[edit] Problems with * in ask queries
I am running semwiki on a win xp machine with:
- Apache 2.0.5.9
- SQL 4.1.21
- PHP 5.1.2
- mediawiki 1.8.2
- semantic mediawiki 0.5
- parser functions enabled
Everytihng works finde but as soon as i use a * in ask queries and safe the page the article is not loaded and shows a blank page instead. This is of course extremely annoying as all advanced useful queries need that sign.
See User:Freddy for the application i am trying to use that for.
Does anyone have an idea how to solve that?
The automatically generated lists in this wike are also always "up-to-date" when the article that contains the list is reloaded. In my wiki i have to edit and save the article with the list again to make newly annotated pages appear in the list. Is this a semwiki verison issue or another "defect" of my installation?
-- Freddy 13:54, 29 November 2006 (CET)
- On another installation i finally got a usable errormessage concerning mb_strpos cannot be found. So the problem could easily be solved by enabling the php extension mbstring by uncommenting php_mbstring.dll in php.ini. Request: Please include that information in the Semwiki install file or check on Special:SMWAdmin if this extension is enabled. Thanks -- Freddy 16:17, 29 November 2006 (CET)
- I was having the same problem Freddy was having, and to my amazement uncommenting the line he pointed out of php.ini did solve the problem! It's almost miracolous! Definitely something that should be either bypassed by the SMW's source code or documented in very large characters somewhere here on OntoWorld.org. Manu3d 17:11, 10 July 2007 (CEST)
[edit] Nested queries
Example: i want to get the Year of birth of the current president of the USA. How can i get that? I tried the following in dozens of variations, but it didn't work out:
UNIQ1b18a9a22ccede4d-pre-00000001-QINU UNIQ1b18a9a22ccede4d-pre-00000002-QINUgives UNIQ1b18a9a22ccede4d-ask-00000003-QINU --Patrick 14:09, 7 November 2006 (CET)
- Thanks for the fast response. But how to get only the value "1946" for inline use? What if i don't know the relation "president of" ;-) ? --Freddy 14:30, 7 November 2006 (CET)
- UNIQ1b18a9a22ccede4d-pre-00000004-QINU returns UNIQ1b18a9a22ccede4d-ask-00000005-QINU if you don't want to use show the name and don't know the relation "president of". - Fuelbottle 14:37, 7 November 2006 (CET)
- Thanks again, but i don't want the birth year of George Walker Bush, but rather the year of birth of the current president of the USA. Actually I want to understand the way how nested queries work ... or how not. See next example for what i'am planning. -- Freddy
- This is an older problem it seems, but I think the new template functionality will give you what you want if you make a template that does a query to find the age of the name you pass in to it. This might not work with your example below, depending on if #expr will parse the template correctly.--Jberger 07:16, 24 June 2007 (CEST)
- Thanks again, but i don't want the birth year of George Walker Bush, but rather the year of birth of the current president of the USA. Actually I want to understand the way how nested queries work ... or how not. See next example for what i'am planning. -- Freddy
- I don't think you can get only the value "1946": the result of the page selection is always shown unless the pages are enumerated in the query. You need the relation "president of", you cannot take two steps forward (from subject to object), you always take 0, 1 or 2 steps backward and 0 or 1 steps forward.--Patrick 17:16, 7 November 2006 (CET)
- UNIQ1b18a9a22ccede4d-pre-00000004-QINU returns UNIQ1b18a9a22ccede4d-ask-00000005-QINU if you don't want to use show the name and don't know the relation "president of". - Fuelbottle 14:37, 7 November 2006 (CET)
Another example: What if i want to ask for a value of the current article and do some calculation with it? Imagine semantic Templating of the Chemical Elementbox at Wikipedia [1]. One could autofill the "next/previous" element with inline queries like that:
UNIQ1b18a9a22ccede4d-pre-00000006-QINUIs that possible somehow already?
--Freddy 13:48, 7 November 2006 (CET)
- Unfortunately not.--Patrick 17:18, 7 November 2006 (CET)
[edit] Not operator
HansOesterholt 22:32, 15 May 2006 (CEST) -- Of course there's always something to complain about. I wonder: Where is the 'not' operator?
- I don't think there is any. --OlivierDameron 09:54, 16 May 2006 (CEST)
- Right, there is none for now. Maybe in a later version. --Denny 11:48, 16 May 2006 (CEST)
[edit] OR operator
HansOesterholt -- What about an OR operator? It is very usefull to be able to formulate a query which returns either this or that.
- I do not really like the idea of a general OR. Actually, I think, the || is already too much, but it was needed for some other stuff, so I thought, yikes, let's make it possible. I still think that inline queries should be as simple as possible -- and OR actually confuses users often (i.e. they get other results than they expected). Don't forget that by using SPARQL on the output you could always make queries as complicated as you like -- Inline Queries are just for some lightweight stuff, that should not cost too much performance (they violate this rule right now with a few features, but we hope to straighten that out during this summer). It could always be that I am wrong, though, and people just need ORs desperately :) --Denny 18:54, 16 May 2006 (CEST)
HansOesterholt 10:17, 19 May 2006 (CEST) - I see. Well, I really like the OR operator that's there right now. For instance, I'm querying our wiki on artikles or reports to be able to find all reports
and artikles on e.g. the subject integration from a certain author. These inline queries are really handy! I've created pages where all of our SIGs are displayed, without the need
to administer them on an assembly page.
HansOesterholt 10:17, 19 May 2006 (CEST) - But what about SPARQL? Is this already an option to use?
But do you mean SPARQL run locally on each user's machine, or a online page such as This ? I think it is interesting to see the results of queries right in the wiki itself without copying, running some other application , pasting back the result manually etc. If there is a way to provide the input from an article, then redirect the output back to the wiki automatically as a secondary web service then that should be fine. But if not then I think it fosters collaboration to let users see and comment on each other's queries real time if it is a built in feature. It's one of the things that makes a Semantic Wiki more interesting than a "regular" one. The advanced Query feature, whether it is built in or remote, should allow for reasonably complex expressions, at least the basic logic operators which I also think should include NOT, OR etc. I know performance is an issue so if there is a way to use the remote page then that is probably best. Perhaps someone could put an example.
How do I combine results in general, for instance all people that are very large or very small:
UNIQ1b18a9a22ccede4d-pre-00000007-QINU[edit] Displaying the category
HansOesterholt 10:22, 19 May 2006 (CEST) - Is it possible to use something like UNIQ1b18a9a22ccede4d-nowiki-00000008-QINU to display the category?
[edit] Disjunction of relations
As there is no consensus on a common vocabulary to use, it would be useful to be able to make queries using relationA or relationB. For example, in order to retrieve the instances of Person being described as Is_A::Person or as rdf:type::Person, it would be nice to write something like: UNIQ1b18a9a22ccede4d-nowiki-00000009-QINU.
Does such a feature already exist, with a syntax I am unaware of? --OlivierDameron 12:22, 16 May 2006 (CEST)
- I'd prefer to have users come to a consensus. Nevertheless, I think this could become part of Version 0.5 -- probably because I think it will be a prerequisite for allowing subproperties. So you may get them anyway :) Cheers, --Denny 15:48, 16 May 2006 (CEST)
[edit] Format date?
Is there a way to choose the date formatting? I am running a query like:
UNIQ1b18a9a22ccede4d-pre-0000000A-QINUI get back 2,006 ISO8601 as the "to review" column - in the articles it's entered as e.g. May 30 2006... seems to format better using simple search
[edit] Aggregation
It would be nice if results not only can be listed, but could also be counted or summed.
Is this or will this be possible? Tromm 09:59, 7 June 2006 (CEST)
[edit] Inheritance
Inheritance works for categories. If you query a supercategory you also get all the instances of its subcategories.
Does this also work for relational categories? For instance, I have several relations consists of, contains, is made of which are all generalisations of something (whole-part).
So if I make a supercategory relation 'is generalisation of', can I query for all parts that are objects in 'is generalisation of'-type relations and its subcategorietype relations?
Tromm 10:48, 7 June 2006 (CEST)
[edit] Subject query
It seems 'ask' is only capable of doing relation-object queries. Will it allow subject-relation queries as well in the future? --Joris Gillis 19:29, 18 July 2006 (CEST)
Nevermind, UNIQ1b18a9a22ccede4d-nowiki-0000000B-QINU seems to work just fine--Joris Gillis 22:39, 9 August 2006 (CEST)
- This doesn't seem to work in subqueries as expected. For instance,
UNIQ1b18a9a22ccede4d-nowiki-0000000C-QINU
- gives me the father of the child, but
UNIQ1b18a9a22ccede4d-nowiki-0000000D-QINU
- does not give me the children of that father, i.e. siblings...It actually gives me the grandchildren--Dirtysouthafrican 19:39, 7 April 2007 (CEST)
[edit] Subquery that returns object
Is there a possibility to get the object in a subquery and reuse the in the query?
Example:
In this example i want a list of all articles that have the same keywords like the actual article...
UNIQ1b18a9a22ccede4d-nowiki-0000000E-QINU
Problem here is, that the subquery returns the article UNIQ1b18a9a22ccede4d-nowiki-0000000F-QINU, not the object of the triple UNIQ1b18a9a22ccede4d-nowiki-00000010-QINU
If you compare this two queries, you can see the difference:
UNIQ1b18a9a22ccede4d-nowiki-00000011-QINU Results: has keyword Metadata
UNIQ1b18a9a22ccede4d-nowiki-00000012-QINU Results: Example Project (in this case Inline queries
This problem appears since version 4.3.2. Before it worked, because the subquery returned just the string of the object.
But there was a rewrite of the inline queries. Has the syntax changed, was it a misstake, or isn't this query possible anymore?
--Brs 20:29, 17 August 2006 (CEST)
Yep, the reimplimentation made the queries far more efficient than before. It is a pity they lost a bit of expressive power to this regard (especially since my own wiki heavily relied on that, bummer). We are exploring how we can get that back, but we are not sure yet... If you have an idea, feel free to share on the dev list. --Denny 23:19, 17 August 2006 (CEST)
[edit] Parser Function equivalent to <ask>?
Hi! Is there a parser function equivalent to <ask>? Perhaps something akin to UNIQ1b18a9a22ccede4d-nowiki-00000013-QINU? Thanks in advance.
--Jimbojw 19:24, 14 May 2007 (CEST)
[edit] What's the difference
between UNIQ1b18a9a22ccede4d-nowiki-00000014-QINU and UNIQ1b18a9a22ccede4d-nowiki-00000015-QINU ?
- The first one will work; the second won't. Yaron Koren 21:14, 20 June 2007 (CEST)
[edit] How do I find the list of the things related to?
If I have 10 UNIQ1b18a9a22ccede4d-nowiki-00000016-QINU, and each has a UNIQ1b18a9a22ccede4d-nowiki-00000017-QINU or UNIQ1b18a9a22ccede4d-nowiki-00000018-QINU, how do I get the string "You can find good coffee shops in Main Street and Market Street"?
- If you're willing to drop the "and", how about UNIQ1b18a9a22ccede4d-nowiki-00000019-QINU?
[edit] Regarding Parser Functions
I'm using the latest version which is 1.10 but i have problems with parser functions (ex. #if, #switch, etc.) templates doesn't funtion well if theres an if statements in it. I badly need help i've been searching the internet for possible answers but found none. Thanks in advance. --Bongsky 03:58, 3 July 2007 (CEST)
[edit] Request for Example: Templates
Could you give an example for UNIQ1b18a9a22ccede4d-nowiki-0000001A-QINU? I didn't manage to get a table. How can I generate the table header? -- Björn 4. July 2007 19:04
- I'm having the same problem, It appears that table characters inside the templates are not expanded properly when the template is used in an UNIQ1b18a9a22ccede4d-nowiki-0000001B-QINU query. I'm doing some further testing. I should be able to add some more information shortly. - Manu3d 12:44, 11 July 2007 (CEST)
- The template is used only for the repeating part of the table. Therefore the table caption and headers must be outside of the template, thus:
UNIQ1b18a9a22ccede4d-nowiki-0000001C-QINU
- Which produces the following table:
| City | Province | Country |
|---|
UNIQ1b18a9a22ccede4d-ask-0000001D-QINU
- By using CSS styling and html coding, there is considerable flexibility in the output.--Joschroy 06:49, 15 July 2007 (CEST)
Thanks. But it's still a hack, because you get two tables with this. --Björn Klippstein 11:47, 20 August 2007 (CEST)
[edit] Semantic problems after XML import
I have an urgent problem. I created an XML dump file to import via the specials page import. Everything works so far except the fact, that attributes obviously not working properly. (no errors while importing, no visible strange characters in the article)
An article has an attribute like this:
UNIQ1b18a9a22ccede4d-nowiki-0000001E-QINU
The inline query (which is not working after the import, just blank space) looks like this: UNIQ1b18a9a22ccede4d-nowiki-0000001F-QINU
The thing is, when I edit the article, do any minor change like adding a space somewhere and save it, it works. So I would imagine there's a wrong character but all looks fine to me.
Is there a possibility to script wikipedia to open and save all articles or a tool to check the wiki XML import file? (I mean there's no error message while importing).
Cheers, Steve
[*]I think when I import an XML dump the smw_attributes table doesn't get updated. Any chance that I can update it for all articles?
- Steve, I believe in the latest build of SMW, there are scripts in the maintenance directory to update all articles. I believe the one you want is SMW_refreshData.php. --JoelN 13:40, 15 July 2007 (CEST)
[edit] How do you get a count of attributes inside a category?
I asked:
UNIQ1b18a9a22ccede4d-nowiki-00000020-QINU
It keeps returning the number of Categories, not the number of people in the category. If I remove the count format, I get all the people in the category as expected. However, they are grouped by category and count seems to be stuck counting the category.
Any hints? --JoelN 18:14, 18 July 2007 (CEST)
- Can you describe what's going on here in more detail? Are there a set of pages within this category, and each one has a "people" attribute that's an integer, and are you trying to do a sum of all of these integers? Or is the "people" attribute a string, representing someone's name? Yaron Koren 01:36, 23 July 2007 (CEST)
[edit] Table headers as columns vs. rows
Is this possible? I want to duplicate http://tnlc.com/eep/compare/table.html but am having a hard time finding a MediaWiki extension that can do just that (let alone all the colspan/rowspans)! -Eep² 06:05, 30 July 2007 (CEST)
[edit] Update / Refresh?
I have a pretty complex set of semantic variables on a Wiki that is, among other things, tracking legislation of the Student Senate at my college.
Each piece of legislation gives each of its CoSponsors a semantic tag called "LegislationCoSponsor."
Meanwhile, on the pages of the 25 Senators, I have a template which has UNIQ1b18a9a22ccede4d-nowiki-00000021-QINU.
When I apply this template and save the page, it works fine.
However, when a new piece of legislation gains this tag, the table for the inline query on the person's page is not updated. If I simply click "edit" and then save the page again, it updates fine.
I have the same problem on the page that lists the legislation, which simply queries all of the pages in the category.
Is this normal? Is there a way I can cause this page to update automatically? I'm not sure if I understand the point of inline queries otherwise. Is there an easier way to do this whole thing?
Here's a link to the legislation link:
http://wikipaltz.com/index.php?title=44th_Student_Senate_Legislation
- metrix[nosp]1978@gmail[nosp].com (remove nosp) I am having the same problem and found the bug report in bugzilla. The current workaround is to create a cron job to touch the LocalSettings.php everyonce in a while to force all page caches to be reset. -Brandon
