Module talk:Wikidata: Difference between revisions
ClueBot III (talk | contribs) m Fixing links to archived content. (BOT) |
|||
(9 intermediate revisions by 2 users not shown) | |||
Line 136: | Line 136: | ||
: (copied from Village pump (technical) to make sure it stays visible for this module) |
: (copied from Village pump (technical) to make sure it stays visible for this module) |
||
:The more I've looked at this, the more I become convinced that you can't write a generic call to fetch just the value of a given qualifier associated with a given property because of the possibility of multiple values. For example, if you look at Richard Burton ([[d:Q151973]]), he has 3 spouses (P26) listed, two of whom have qualifiers for start time (P580) and end time (P582). What should a call asking for Richard Burton's spouse's start time return? Should it return nil for Elizabeth Taylor? or 3 July 1983 for Sally Burton? or 1949 for Sybil Christopher? Of course we could have it return 1949 ''and'' 3 July 1983, but what value would they be without knowing which spouse they referred to? It would be possible to write a call that fetched e.g. the value of first given qualifier from the first given property, but that becomes vulnerable to someone adding another value for the property. How would you want to deal with the situation if Santa Fe ([[d:Q316370]]) had 30 [[sitio]]s -- Wikidata shows it has 10 [[Barangay]]s by using the property "has part(P527)=barangay" with the qualifier "quantity(P1114)=10" -- and someone added "has part=sitio" with a qualifier of "quantity=30"? Should getRawQualifierValue|P527|P1114 return 10 or 30? Sorry to be negative about the problem, but I can't see a general solution. --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 14:50, 2 March 2015 (UTC) |
:The more I've looked at this, the more I become convinced that you can't write a generic call to fetch just the value of a given qualifier associated with a given property because of the possibility of multiple values. For example, if you look at Richard Burton ([[d:Q151973]]), he has 3 spouses (P26) listed, two of whom have qualifiers for start time (P580) and end time (P582). What should a call asking for Richard Burton's spouse's start time return? Should it return nil for Elizabeth Taylor? or 3 July 1983 for Sally Burton? or 1949 for Sybil Christopher? Of course we could have it return 1949 ''and'' 3 July 1983, but what value would they be without knowing which spouse they referred to? It would be possible to write a call that fetched e.g. the value of first given qualifier from the first given property, but that becomes vulnerable to someone adding another value for the property. How would you want to deal with the situation if Santa Fe ([[d:Q316370]]) had 30 [[sitio]]s -- Wikidata shows it has 10 [[Barangay]]s by using the property "has part(P527)=barangay" with the qualifier "quantity(P1114)=10" -- and someone added "has part=sitio" with a qualifier of "quantity=30"? Should getRawQualifierValue|P527|P1114 return 10 or 30? Sorry to be negative about the problem, but I can't see a general solution. --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 14:50, 2 March 2015 (UTC) |
||
== Is it possible to get value(s) in structured tree by this Module? == |
|||
What I want to ask is... for example, frontal lobe ([[:d:Q749520]]) has structured data tree as follows. |
|||
* [[frontal lobe]] ([[:d:Q749520]]) -> described by source ([[:d:P:P1343]]) -> Gray's Anatomy (20th edition) ([[:d:Q19558994]]) -> page ([[:d:P:P304]]) -> 821 |
|||
In this case, can we get value "821" by Module:Wikidata? |
|||
Motivation of the question is... now there is a discussion about "Which is best way to store data. Creating new property or using structure?" for [[Gray's Anatomy]] text page data, at property proposal ([[:wikidata:Wikidata:Property_proposal/Natural_science#Gray.27s_Anatomy_1918_page]]). So I want to know whether it is possible to get value the data in structured tree. Thank you! --[[User:Was a bee|Was a bee]] ([[User talk:Was a bee|talk]]) 16:34, 17 March 2015 (UTC) |
|||
: I added some diagnostic method <tt>V</tt> to get anything. Try this <code><nowiki>{{#invoke:Wikidata|V|claims|P1343|1|qualifiers|P304|1|datavalue|value}}</nowiki></code>. [[User:Paweł Ziemian|Paweł Ziemian]] ([[User talk:Paweł Ziemian|talk]]) 18:51, 17 March 2015 (UTC) |
|||
:: Wow! Paweł, thank you very much for new code. This would help the project very much! --[[User:Was a bee|Was a bee]] ([[User talk:Was a bee|talk]]) 20:52, 17 March 2015 (UTC) |
|||
:::{{ping|Paweł Ziemian}} I experimented that code at article "[[Frontal lobe]]", and I can get page data "821"! That works nicely. Thank you very much. Then, but, can I get data at reference URL ([[:d:P:P854]]) section? I tried some variations of your code above, but I can't retrieve the URL data (for example, "''<nowiki>http://www.bartleby.com/107/189.html#58</nowiki>''"). Is there any key? or Storing data in reference section is not appropriate? Thank you.--[[User:Was a bee|Was a bee]] ([[User talk:Was a bee|talk]]) 17:23, 20 March 2015 (UTC) |
|||
:::: Added another function <code><nowiki>{{#invoke:Wikidata|Dump|claims}}</nowiki></code> to spy the structured data. It uses the same arguments as <tt>V</tt>. Try this with preview only to see results. That helps me a lot in developing Lua scripts that access the data. If used without arguments (here <tt>claims</tt>) it dumps everything including labels, descriptions and interwiki links. [[User:Paweł Ziemian|Paweł Ziemian]] ([[User talk:Paweł Ziemian|talk]]) 17:46, 20 March 2015 (UTC) |
|||
::::: Oh.. so awesome. I figured out how to retrieve data through <code><nowiki>V</nowiki></code> function. I can retrieve a (first) URL and title in reference section by this code. |
|||
:::::* <code><nowiki>{{#invoke:Wikidata|V|claims|P1343|1|references|1|snaks|P854|1|datavalue|value}}</nowiki></code> (first) URL in reference section |
|||
:::::* <code><nowiki>{{#invoke:Wikidata|V|claims|P1343|1|references|1|snaks|P1476|1|datavalue|value|text}}</nowiki></code> (first) title in reference section |
|||
:::::Thank you {{Ping|1=Paweł Ziemian|label1=Paweł}} very very much! P.S. Though I don't know why you named the function as <code><nowiki>V</nowiki></code>, it would be better if the name is more longer and easier to search, wouldn't it? I think your function would be used in wide and various situations. Thanks. --[[User:Was a bee|Was a bee]] ([[User talk:Was a bee|talk]]) 20:08, 20 March 2015 (UTC) |
|||
:::::: I don't mind if you change the name. It is short time the function was introduced so there is no risk in it. I choose one letter after ''ViewSomething'' to avoid a lot of typing. [[User:Paweł Ziemian|Paweł Ziemian]] ([[User talk:Paweł Ziemian|talk]]) 20:41, 20 March 2015 (UTC) |
|||
::::::: Fucntion name [https://en.wikipedia.org/w/index.php?title=Module:Wikidata&diff=652811973&oldid=652760235 was changed] from <code><nowiki>V</nowiki></code> to its full style <code><nowiki>ViewSomething</nowiki></code>. I like the name because it shows what this function can do concisely. Thanks! --[[User:Was a bee|Was a bee]] ([[User talk:Was a bee|talk]]) 00:57, 21 March 2015 (UTC) |
Revision as of 00:57, 21 March 2015
Why
I don't quite get the point of this module. I though that a Wikidata property can simply be transcluded by using {{#property:pXXX}}
, e.g. {{#property:p26}}
returns "Hillary Rodham Clinton" (sans quotes) on Bill Clinton's page, and [[{{#property:p26}}]]
returns as expected Hillary Rodham Clinton. So what does this module do that the straight use of properties doesn't?
PS & off-topic: When will property transclusion be available for items other than the calling page, i.e. {{#property:p26|of=Bill Clinton}}
or {{#property:p26|id=Q1124}}
-- Michael Bednarek (talk) 13:46, 29 August 2013 (UTC)
- I have the same question as you. They're usefull to build a list of redlinks for certain projects. Bennylin (talk)
- If a property has multiple values then sticking [[...]] around the data returned by #property from Wikidata doesn't create multiple links. For example Franz Kafka's (d:Q905) countries of citizenship (d:P27) are Austria-Hungary, Czechoslovakia, not Austria-Hungary, Czechoslovakia. Lots of properties in Wikidata have multiple values and if we want to populate infoboxes from a central resource, then we need to handle linking of multiple results automatically. --RexxS (talk) 18:06, 22 September 2013 (UTC)
- Additionally, #property returns an undisambiguated value, so for William Ellery (d:Q567964) you'd get his place of birth as 'Newport'. Blindly making that into a link takes you to the page Newport which is not where Ellery was born. This module correctly returns Newport, Rhode Island (d:Q54264). As a bonus, it should work in other language wikis where a corresponding article exists because it looks for the title of the article in that language to create the link, although I haven't tested in other languages yet. --RexxS (talk) 18:18, 22 September 2013 (UTC)
Display en label if no article exists
For the sample
- {{#invoke:Wikidata|getValue|p26|FETCH_WIKIDATA}}
when used in the article "Bill Clinton", is there a way to display a string with the English label of d:Q6294
if d:Q6294 had no link to Wikipedia? -- 签名 sig at 21:20, 23 September 2013 (UTC)
- Actually, it's "getRawValue". -- 签名 sig at 21:26, 23 September 2013 (UTC)
- Update: If there's no local article for a returned value, the "getValue" call should now display the localised label of the Wikidata entry - this is linked to the Wikidata entry so that there is somewhere for the reader to see more info if they want. There's a small marker that is an abbreviation for "Article is not yet available in this wiki" that should look like this: [*]
- Is that any better? --RexxS (talk) 12:03, 19 July 2014 (UTC)
getSiteLink
Could someone here more generally implement the recently-created Module:Wikivoyage such that any language and any project will return the sitelink's name of the ID? --Izno (talk) 21:31, 10 February 2014 (UTC)
Date error for years of 1st century
Trying to fetch a date value of the first century defined only with year it returns a date format error. Checked on Abgar V with {{#invoke:Wikidata|getDateValue|p570|FETCH_WIKIDATA}}
(p570=50) while it works on Martial (p570=104) or Nero (p570=7 June 68). Not sure if this can be fixed here or it should be reported on Wikidata. --Vriullop (talk) 15:17, 17 July 2014 (UTC)
- The problem occurs because wikidata - for some reason - internally stores the dates 50 CE and 104 CE in different length strings:
+000000050-01-01T00:00:00Z +00000000104-01-01T00:00:00Z
I can fix that here but there will still be the problem that Wikidata stores 50 CE as 1 January 50 (likewise for 104 CE of course). Without a qualifier that shows the precision of the stored value, I don't know how to differentiate the returned value from an actual date of 1 January YYYY. Perhaps there's some discussion already over at Wikidata? --RexxS (talk) 16:07, 17 July 2014 (UTC)
- I've implemented a modification to deal with years <100. I suppose we ought to deal with BCE dates. How would this best be done: append 'BCE' or 'BC' or pass another flag to fit the usage in the article (as we do with dmy/mdy)? --RexxS (talk) 16:30, 17 July 2014 (UTC)
- Thanks. Commented at d:Wikidata:Project chat#Date format for years<100. --Vriullop (talk) 19:44, 17 July 2014 (UTC)
Was the BCE question ever resolved? I'm doing something like this:
local birthtable = entity:formatPropertyValues( 'P569' ) local birthsplit = mw.text.split(birthtable["value"], " ") local l, count = mw.ustring.gsub(birthtable["value"], "%S+", "") -- count = number of words if string.find(birthsplit[count], "^%d") then birth = birthsplit[count] elseif string.find(birthsplit[count], "BCE") then birth = birthsplit[count - 1] end
It looks at the value of the Birth ID (P569), which might be "4 January 54 BCE" or "6 May 2001" .. takes the last word and checks if it's a number or word, if a number then returns the last word ("2001"), if the later then return the second to last word ("54"). I don't know how robust this is but seems to be working. -- GreenC 15:32, 15 October 2014 (UTC)
- That's a sensible implementation and looks robust. It does rely on entity:formatPropertyValues() to provide 'BCE' from the raw string that is stored, so it won't use 'BC' as far as I can see. You may find that you need to offer 'BC' as an option for use in articles where that is the style used. Cheers --RexxS (talk) 12:37, 16 October 2014 (UTC)
- Might run into problems with "12th. Century" or "ca. 1890s" and other outlier date formats. That's separate from the BC question but same general problem. -- GreenC 17:24, 22 October 2014 (UTC)
Article is not yet available in this wiki
I've altered the text returned when the article does not exist in the local wiki so that it displays the text of the Wikidata label for the entry, rather than Qnnnn. I've also changed the abbreviation marker that has the message "Article is not yet available in this wiki" as its title from small '?' to a normal '*' as I expect that to be less obtrusive for the reader if this module is called from an infobox, for example. --RexxS (talk) 11:56, 19 July 2014 (UTC)
Is it possible to call single value from the property which has multiple values?
Is it possible to call single value or each values one by one, from the property which has multiple values? What i wnat to ask is...
For example, code {{#invoke:Wikidata|getValue|p26|FETCH_WIKIDATA}} in Richard Burton (wikidata:Q151973) returns
-Sally Burton, Sybil Christopher, Elizabeth Taylor
This is because of 'spouse' property at wikidata:Q151973 has 3 values. In such situation, can we get single value from WikiData? (for example only first one), like...
-Sally Burton
Motivation of this question is as follows. Now I am maintaining anatomical property which could have multiple values (wikidata:Property_talk:P1323#Multiple values). But link syntax in infobox template ({{infobox anatomy}} using {{TA98}}) doesn't go well if P1323 has multipul values. So I'm wondering whether there is a method to avoiding the problem. Thank you for reading. --Was a bee (talk) 01:20, 21 September 2014 (UTC)
- The module was originally intended to return multiple values, each individually linked to the relevant article. There is a getRawValue call that just returns values unlinked, if that is any help to you. The problem that I foresee with trying to return just one value is in determining which one you want when there are multiple values? To take your example, how would we know whether you want "Sally Burton" or "Sybil Christopher" or "Elizabeth Taylor"? I could easily add another call to simply return the first value stored, but would that always be the one you want? --RexxS (talk) 03:04, 21 September 2014 (UTC)
@Was a bee: I've created a call in this module that returns the formatted links and text for TA98 directly, bypassing the {{TA98}} template. I've modified Template:Infobox anatomy to use the call. It looks ok in Ear, for example, which has two TA98 values. Human nose seems ok with just one TA98 value. Do you have any different test cases? (I do need to get rid of the html break, but I can do that later). --RexxS (talk) 23:26, 21 September 2014 (UTC)
- Wow! thank you @RexxS:! That is exactly what I hoped for. I have tested 3 values case at Ear article, and that worked. It seems all fine. I'll care how this update works in various situations. Again, thank you RexxS. --Was a bee (talk) 02:08, 22 September 2014 (UTC)
Qualifiers
How can you for example access qualifier P1129 @ Q172221 @ P54 from [1]. I see this module has a getQualifierValue method, but there is no example on how to use it. --Sporti (talk) 06:08, 16 October 2014 (UTC)
- The method was added with this edit by @Jackmcbarn:. He should be able to confirm it, but I think the methods are intended to be called like this:
{{#invoke:Wikidata |getQualifierValue |propertyID |qualifierID |FETCH_WIKIDATA}}
{{#invoke:Wikidata |getRawQualifierValue |propertyID |qualifierID |FETCH_WIKIDATA}}
{{#invoke:Wikidata |getQualifierDateValue |propertyID |qualifierID |FETCH_WIKIDATA |dmy }}
- In the case of Boštjan Cesar, trying
{{#invoke:Wikidata |getRawQualifierValue | P54 |Q172221 |FETCH_WIKIDATA}}
fails because the method assumes that each of the property values has a qualifier, which isn't true in Boštjan Cesar's case as we can see at d:Q346712. The current code should work where there is a single value for the property and it then copes with multiple qualifiers, but I think it needs more work to deal with multiple property values which may or may not individually have qualifiers. - The question that I think needs an answer is how do we wish to display the results of requesting the data, when it's as complicated as 'member of sports team' (P54) for Boštjan Cesar? At present, if we call the method that returns just the properties:
{{#invoke:Wikidata |getValue | P54 |FETCH_WIKIDATA}}
- in Boštjan Cesar, we get the expected result:
- A.C. Chievo Verona, NK Croatia Sesvete, Olympique de Marseille, West Bromwich Albion F.C., NK Olimpija Ljubljana (defunct), Slovenia national football team, GNK Dinamo Zagreb
- but how do we want to display the qualifiers? Are you thinking about something like this:
- A.C. Chievo Verona, NK Croatia Sesvete, Olympique de Marseille, West Bromwich Albion F.C., NK Olimpija Ljubljana (defunct), Slovenia national football team (start date:2003; national team caps:79±1; number of points/goals scored:6±1), GNK Dinamo Zagreb
- It makes sense to me to program the method to return a specified display format, once we've agreed what that display should be. --RexxS (talk) 13:23, 16 October 2014 (UTC)
- I believe it will be used by {{Infobox football biography}} eventually, also by lists like List of Slovenia international footballers, but I guess we're not quite there yet... --Sporti (talk) 13:53, 16 October 2014 (UTC)
- I'll have a look at how that infobox is used and see if I can put together something suitable as soon as I get time (unless someone beats me to it). Cheers --RexxS (talk) 14:34, 16 October 2014 (UTC)
- I believe it will be used by {{Infobox football biography}} eventually, also by lists like List of Slovenia international footballers, but I guess we're not quite there yet... --Sporti (talk) 13:53, 16 October 2014 (UTC)
- Is there any way to retrieve data for p1129 with #property parser function? I guess it must be a little more complicated then {{#property:p54|id=q177221 .. ???}}. --Pinky sl (talk) 18:00, 16 October 2014 (UTC)
Linking to Wikidata
@RexxS: I would like to put a link at the bottom of an infobox that says "Edit data on Wikidata" and that should link to the connected Wikidata-item. Is that possible yet? ---Tobias1984 (talk) 15:35, 21 October 2014 (UTC)
- The entry in the toolbox that says 'Wikidata item' obviously has a means of retrieving the Q value associated with the current page. Sadly, I'm not aware of a call to the API that does that job for us yet - although the opposite (finding an article label from its Q value) has been available for quite some time. Perhaps somebody can suggest a work-around? --RexxS (talk) 15:33, 23 October 2014 (UTC)
- The Q value of the current page can be retrieved by calling
mw.wikibase.getEntityObject().id
. --Mps (talk) 16:41, 23 October 2014 (UTC) - For better convenience I added a pageId function to this module. --Mps (talk) 16:50, 23 October 2014 (UTC)
- @Mps: Thanks a lot. I tested it and it works perfectly. I also added an example to the documentation. -Tobias1984 (talk) 17:52, 23 October 2014 (UTC)
- The Q value of the current page can be retrieved by calling
Sources from Wikidata
Is it already possible to get the source from Wikidata with this module? The German module for Wikidata seems to have a function for it "function getReferences(claim)". @Mps and JakobVoss: Is that possible to add that here? --Tobias1984 (talk) 09:38, 22 October 2014 (UTC)
- As far as I see it is not possible with the current state of the English module. The main issue with with the English module is that it does not support all data types provided by Wikidata, only strings, Wikidata links and dates (partially), but not the "novalues" datatype, the "somevalue" datatype, times, numbers, coordinates, monolingual text, or parts thereof. Also the user needs to select which module method to use based on the date type. The module also ignores the rankings and sorting orders. The German module is doing all of this automatically. For the sources this is important, as these may use all data types. So the short version is: additionally to getReferences one would also need to add the complete datatype handling of the German version. On a side note, this would also solve the #Qualifiers question from above.
- The documentation for the German version can be found under de:Wikipedia:Lua/Modul/Wikidata/de#claim: its in German but the examples ("Beispiele") there should be understandable nonetheless. --Mps (talk) 12:37, 22 October 2014 (UTC)
- @Mps: Thank you for the detailed answer. I will try if I can include those parts in the en-wiki module. Deutsch wird nicht das größte Problem sein :) -Tobias1984 (talk) 09:58, 23 October 2014 (UTC)
Connecting arbitrary page to Wikidata-item for testing
I made a sandbox page at Template:Infobox_drug/sandbox3. I am testing the infobox here: User:Tobias1984/Infobox drug test Is there any way to pretend-connect the page with the WD-item for Warfarin, so I don't see the template error? --Tobias1984 (talk) 09:42, 22 October 2014 (UTC)
- You can't pretend-connect pages. You should connect Wikidata's sandbox item to a page in your userspace if you need to test temporarily. Jackmcbarn (talk) 11:59, 22 October 2014 (UTC)
- You can use Special:ExpandTemplates for a very basic "pretend-connect pages". --Mps (talk) 13:42, 22 October 2014 (UTC)
getDateValue issue
![]() | This request for help from administrators has been answered. If you need more help or have additional questions, please reapply the {{admin help}} template, or contact the responding user(s) directly on their own user talk page. |
There's a little problem inside getDateValue fuction in Module:Wikidata. If the qualifier contains only a year, function prints 1 January 1986 instead of 1986.
{{#invoke:Wikidata|getDateValue|P577|{{{published|FETCH_WIKIDATA}}}}}
--Rezonansowy (talk | contribs) 11:41, 25 October 2014 (UTC)
- Maybe some admin could help. Someone from WP:Lua. --RezonansowyakaRezy (talk | contribs) 12:00, 18 February 2015 (UTC)
- @Rezonansowy: Admins are not necessarilyly technically qualified - you would do better to ask at WP:VPT where the gurus hang out or, if that fails, at the talk page WT:LUA. JohnCD (talk) 12:04, 18 February 2015 (UTC)
- The problem is that Wikidata actually stores a year such as 1986 as the date 1 January 1986. Sadly, there's no way knowing whether the stored value was actually meant to be that date or the year.
Would you like me to add a call that stripped the date down to the year?You'd have to decide then to use that call rather than requesting a date value, of course. --RexxS (talk) 18:09, 18 February 2015 (UTC) - Update: I had a look and somebody had already done the job more elegantly. If you supply a third parameter to
getDateValue
then it sets the date format. The option to use 'y' for just the year has been added. Try:
- The problem is that Wikidata actually stores a year such as 1986 as the date 1 January 1986. Sadly, there's no way knowing whether the stored value was actually meant to be that date or the year.
- @Rezonansowy: Admins are not necessarilyly technically qualified - you would do better to ask at WP:VPT where the gurus hang out or, if that fails, at the talk page WT:LUA. JohnCD (talk) 12:04, 18 February 2015 (UTC)
{{#invoke:Wikidata|getDateValue|P577|{{{published|FETCH_WIKIDATA}}}|y}}
- Does that solve the problem for you or is there something more? I'll update the examples in the documentation in any case. --RexxS (talk) 18:24, 18 February 2015 (UTC)
Translate error messages
The error messages are in German. Would be nice if someone could translate those... --Lucie Kaffee (WMDE) (talk) 13:20, 27 February 2015 (UTC)
Data type in getRawQualifierValue
A possible bug is discussed at Wikipedia:Village pump (technical)/Archive 135#Wikidata problem. PrimeHunter (talk) 21:06, 1 March 2015 (UTC)
- (copied from Village pump (technical) to make sure it stays visible for this module)
- The more I've looked at this, the more I become convinced that you can't write a generic call to fetch just the value of a given qualifier associated with a given property because of the possibility of multiple values. For example, if you look at Richard Burton (d:Q151973), he has 3 spouses (P26) listed, two of whom have qualifiers for start time (P580) and end time (P582). What should a call asking for Richard Burton's spouse's start time return? Should it return nil for Elizabeth Taylor? or 3 July 1983 for Sally Burton? or 1949 for Sybil Christopher? Of course we could have it return 1949 and 3 July 1983, but what value would they be without knowing which spouse they referred to? It would be possible to write a call that fetched e.g. the value of first given qualifier from the first given property, but that becomes vulnerable to someone adding another value for the property. How would you want to deal with the situation if Santa Fe (d:Q316370) had 30 sitios -- Wikidata shows it has 10 Barangays by using the property "has part(P527)=barangay" with the qualifier "quantity(P1114)=10" -- and someone added "has part=sitio" with a qualifier of "quantity=30"? Should getRawQualifierValue|P527|P1114 return 10 or 30? Sorry to be negative about the problem, but I can't see a general solution. --RexxS (talk) 14:50, 2 March 2015 (UTC)
Is it possible to get value(s) in structured tree by this Module?
What I want to ask is... for example, frontal lobe (d:Q749520) has structured data tree as follows.
- frontal lobe (d:Q749520) -> described by source (d:P:P1343) -> Gray's Anatomy (20th edition) (d:Q19558994) -> page (d:P:P304) -> 821
In this case, can we get value "821" by Module:Wikidata?
Motivation of the question is... now there is a discussion about "Which is best way to store data. Creating new property or using structure?" for Gray's Anatomy text page data, at property proposal (wikidata:Wikidata:Property_proposal/Natural_science#Gray.27s_Anatomy_1918_page). So I want to know whether it is possible to get value the data in structured tree. Thank you! --Was a bee (talk) 16:34, 17 March 2015 (UTC)
- I added some diagnostic method V to get anything. Try this
{{#invoke:Wikidata|V|claims|P1343|1|qualifiers|P304|1|datavalue|value}}
. Paweł Ziemian (talk) 18:51, 17 March 2015 (UTC)- Wow! Paweł, thank you very much for new code. This would help the project very much! --Was a bee (talk) 20:52, 17 March 2015 (UTC)
- @Paweł Ziemian: I experimented that code at article "Frontal lobe", and I can get page data "821"! That works nicely. Thank you very much. Then, but, can I get data at reference URL (d:P:P854) section? I tried some variations of your code above, but I can't retrieve the URL data (for example, "http://www.bartleby.com/107/189.html#58"). Is there any key? or Storing data in reference section is not appropriate? Thank you.--Was a bee (talk) 17:23, 20 March 2015 (UTC)
- Added another function
{{#invoke:Wikidata|Dump|claims}}
to spy the structured data. It uses the same arguments as V. Try this with preview only to see results. That helps me a lot in developing Lua scripts that access the data. If used without arguments (here claims) it dumps everything including labels, descriptions and interwiki links. Paweł Ziemian (talk) 17:46, 20 March 2015 (UTC)- Oh.. so awesome. I figured out how to retrieve data through
V
function. I can retrieve a (first) URL and title in reference section by this code.{{#invoke:Wikidata|V|claims|P1343|1|references|1|snaks|P854|1|datavalue|value}}
(first) URL in reference section{{#invoke:Wikidata|V|claims|P1343|1|references|1|snaks|P1476|1|datavalue|value|text}}
(first) title in reference section
- Thank you @Paweł: very very much! P.S. Though I don't know why you named the function as
V
, it would be better if the name is more longer and easier to search, wouldn't it? I think your function would be used in wide and various situations. Thanks. --Was a bee (talk) 20:08, 20 March 2015 (UTC)- I don't mind if you change the name. It is short time the function was introduced so there is no risk in it. I choose one letter after ViewSomething to avoid a lot of typing. Paweł Ziemian (talk) 20:41, 20 March 2015 (UTC)
- Fucntion name was changed from
V
to its full styleViewSomething
. I like the name because it shows what this function can do concisely. Thanks! --Was a bee (talk) 00:57, 21 March 2015 (UTC)
- Fucntion name was changed from
- I don't mind if you change the name. It is short time the function was introduced so there is no risk in it. I choose one letter after ViewSomething to avoid a lot of typing. Paweł Ziemian (talk) 20:41, 20 March 2015 (UTC)
- Oh.. so awesome. I figured out how to retrieve data through
- Added another function
- @Paweł Ziemian: I experimented that code at article "Frontal lobe", and I can get page data "821"! That works nicely. Thank you very much. Then, but, can I get data at reference URL (d:P:P854) section? I tried some variations of your code above, but I can't retrieve the URL data (for example, "http://www.bartleby.com/107/189.html#58"). Is there any key? or Storing data in reference section is not appropriate? Thank you.--Was a bee (talk) 17:23, 20 March 2015 (UTC)
- Wow! Paweł, thank you very much for new code. This would help the project very much! --Was a bee (talk) 20:52, 17 March 2015 (UTC)