Wikifunctions
wikifunctionswiki
https://www.wikifunctions.org/wiki/Wikifunctions:Main_Page
MediaWiki 1.44.0-wmf.8
first-letter
Media
Special
Talk
User
User talk
Wikifunctions
Wikifunctions talk
File
File talk
MediaWiki
MediaWiki talk
Template
Template talk
Help
Help talk
Category
Category talk
TimedText
TimedText talk
Module
Module talk
Translations
Translations talk
Z801
0
169
147106
139633
2024-12-19T05:09:41Z
Jérémy-Günther-Heinz Jähnick
6055
Traduction en français (fr)
147106
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z801"
},
"Z2K2": {
"Z1K1": "Z8",
"Z8K1": [
"Z17",
{
"Z1K1": "Z17",
"Z17K1": "Z1",
"Z17K2": "Z801K1",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "input"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1157",
"Z11K2": "invoer"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1025",
"Z11K2": "wejście"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1014",
"Z11K2": "Ihe"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1011",
"Z11K2": "ইনপুট"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "saisie"
}
]
}
}
],
"Z8K2": "Z1",
"Z8K3": [
"Z20",
"Z8010",
"Z8011",
"Z8012",
"Z8013",
"Z13517",
"Z15868",
"Z13870",
"Z17799"
],
"Z8K4": [
"Z14",
"Z901"
],
"Z8K5": "Z801"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Echo"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1430",
"Z11K2": "Echo"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1157",
"Z11K2": "echo"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1025",
"Z11K2": "nie zmieniaj"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1014",
"Z11K2": "Echo"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1003",
"Z11K2": "Escribir"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1592",
"Z11K2": "mata ut"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1011",
"Z11K2": "প্রতিফলন"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "écho"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31",
{
"Z1K1": "Z31",
"Z31K1": "Z1002",
"Z31K2": [
"Z6",
"Identity",
"Print",
"ROT0",
"ROT26",
"return Object",
"evaluate object"
]
},
{
"Z1K1": "Z31",
"Z31K1": "Z1025",
"Z31K2": [
"Z6",
"identyczność",
"echo",
"zwróć obiekt bez zmian",
"tożsamość"
]
},
{
"Z1K1": "Z31",
"Z31K1": "Z1003",
"Z31K2": [
"Z6",
"Mensaje",
"Eco",
"Imprimir"
]
},
{
"Z1K1": "Z31",
"Z31K1": "Z1592",
"Z31K2": [
"Z6",
"skriv ut",
"echo",
"print"
]
},
{
"Z1K1": "Z31",
"Z31K1": "Z1011",
"Z31K2": [
"Z6",
"ছায়া ",
"প্রতিধ্বনি",
"অনুকৃতি",
"অনুকরণ",
"পুনরাবৃত্তি"
]
}
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "returns the argument unchanged"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1025",
"Z11K2": "zwraca obiekt podany jako parametr bez zmian"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1014",
"Z11K2": "weghachiri arụmụka ahụ agbanweghị"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1003",
"Z11K2": "regresa un argumento sin cambios"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1592",
"Z11K2": "skicka vidare argumentet utan färändring"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1011",
"Z11K2": "আর্গুমেন্টকে ঠিক যেমন কি তেমনই ফিরিয়ে দেবে"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "renvoie l'argument inchangé"
}
]
}
}
euunhshwqjm9m5hfmh25bci2dll9f70
Template:Main page
10
1170
147122
146025
2024-12-19T07:36:06Z
DVrandecic (WMF)
7
fixed link
147122
wikitext
text/x-wiki
<templatestyles src="Template:Main_page/styles.css" />
<div id="lang_dir" class="mw-content-{{dir|{{#invoke:Caller title|lang|base=Template:Main_page}}}}" dir="{{dir|{{#invoke:Caller title|lang|base=Template:Main_page}}}}">
<div id="mainpage_header" class="mainpage_header">
[[file:Wikifunctions-logo.svg|75px]]
<h1><translate><!--T:1--> Welcome to Wikifunctions</translate></h1>
<p><translate><!--T:2--> Wikifunctions is a [[<tvar name="1">foundation:Special:MyLanguage/Policy:Terms_of_Use</tvar>|free]] library of [[<tvar name="2">Special:MyLanguage/Wikifunctions:About</tvar>|functions]] that anyone can edit.</translate></p>
</div>
<div style="clear: both;"></div>
<div id="audiences" class="mainpage_row">
<div class="mainpage_box">
<h3><span class="header_icon" aria-hidden="true" role="presentation">[[File:Wikifunctions-logo-monochrome-black.svg|20px|middle|link=|class=skin-invert-image]]</span><span><translate><!--T:3--> Welcome!</translate></span></h3>
<div id="mainpage-welcome" title="Welcome" class="items">
<translate><!--T:4--> '''Wikifunctions''' is a Wikimedia project for everyone to collaboratively create and maintain a library of code functions to support the Wikimedia projects and beyond, in the world's natural and programming languages.</translate>
<translate><!--T:5--> A "function" is a sequence of programming instructions that makes a calculation based on data you provide. Functions can answer questions, such as how many days have passed between two dates, or the distance between two cities.</translate>
</div>
</div>
<div class="mainpage_box">
<h3><span class="header_icon" aria-hidden="true" role="presentation">[[File:OOjs UI icon chem.svg|20px|middle|link=|class=skin-invert-image]]</span><span><translate><!--T:6--> Get started</translate></span></h3>
<div id="mainpage-start" title="Get started" class="items">
[[File:Wikifunctions in 7 minutes.webm|thumbtime=0:01|thumb|center|400px|<translate><!--T:80--> Wikifunctions in 7 minutes</translate>]]
* [[Special:RunFunction|<translate><!--T:92--> Run a Function</translate>]]
* [[Wikifunctions:Project chat|<translate><!--T:7--> Project chat</translate>]]
* [[Wikifunctions:Community portal|<translate><!--T:91--> Community portal</translate>]]
* [[Wikifunctions:Suggest a function|<translate><!--T:8--> Suggest a function</translate>]]
* [[Wikifunctions:Catalogue|<translate><!--T:9--> Catalogue of available functions</translate>]]
</div>
</div>
</div>
<div id="many-examples" class="mainpage_row">
<div class="mainpage_box">
<h3><span class="header_icon" aria-hidden="true" role="presentation">[[File:OOjs UI icon listBullet-{{dir|{{#invoke:Caller title|lang|base=Template:Main_page}}}}.svg|20px|middle|link=|class=skin-invert-image]]</span><span><translate><!--T:11--> Functions to try out</translate></span></h3>
<div id="mainpage-function-list" title="Function list" class="items">
* {{Z+|Z10096}}
* {{Z+|Z13163}}
* {{Z+|Z12427}}
* {{Z+|Z13587}}
* {{Z+|Z12626}}
* {{Z+|Z12812}}
* {{Z+|Z10012}}
* {{Z+|Z10070}}
[[Wikifunctions:Catalogue|<translate><!--T:12--> ''more functions…''</translate>]]
</div>
</div>
</div>
<div id="misc-news" class="mainpage_row">
<div class="mainpage_box">
<h3><span class="header_icon" aria-hidden="true" role="presentation">[[File:OOjs UI icon ongoingConversation-{{dir|{{#invoke:Caller title|lang|base=Template:Main_page}}|2=ltr|3=rtl}}.svg|20px|middle|link=|class=skin-invert-image]]</span><span><translate><!--T:13--> Learn and contribute</translate></span></h3>
<div id=mainpage-help-contribute" title="Support and Contributing" class="items">
; <translate><!--T:14--> Learn about Wikifunctions</translate>
* [[Special:MyLanguage/Wikifunctions:About|<translate><!--T:15--> About Wikifunctions</translate>]]
* [[Special:MyLanguage/Wikifunctions:Introduction|<translate><!--T:16--> Wikifunctions introduction</translate>]]
* [[Special:MyLanguage/Wikifunctions:FAQ|<translate><!--T:17--> FAQ</translate>]]
* [[Special:MyLanguage/Wikifunctions:Glossary|<translate><!--T:18--> Glossary</translate>]]
; <translate><!--T:19--> Contribute to other areas</translate>
* [[Special:MyLanguage/Help:Multilingual|<translate><!--T:20--> Get involved as a translator</translate>]]
; <translate><!--T:21--> Get help</translate>
* <translate><!--T:22--> Questions?</translate> <translate><!--T:23--> Ask at the [[<tvar name="1">Wikifunctions:Project chat</tvar>|Project chat]] or [[<tvar name="2">Special:MyLanguage/Wikifunctions:Report a technical problem#Discuss with others</tvar>|our Telegram/IRC channel]]!</translate>
* [[Special:MyLanguage/Wikifunctions:Report a technical problem|<translate><!--T:24--> Report a technical problem</translate>]]
** <translate><!--T:25--> [[<tvar name="1">Wikifunctions:Status</tvar>|Status]] page lists major known issues and problems</translate>
</div>
</div>
<div class="mainpage_box">
<h3><span class="header_icon" aria-hidden="true" role="presentation">[[File:Echo (Notifications) megaphone{{dir|{{#invoke:Caller title|lang|base=Template:Main_page}}|2=-rtl|3=}}.svg|20px|middle|link=|class=skin-invert-image]]</span><span><translate><!--T:26--> News</translate></span></h3>
<div id="mainpage-news" title="News" class="items">
<div style="margin: auto; vertical-align:top">
<div class="mainpage_boxcontents_small">
; <translate><!--T:27--> Upcoming meetings</translate>
* <translate><!--T:28--> The next Volunteers' Corner will be on <tvar name="date-and-time"><bdi lang="en" dir="ltr">[https://zonestamp.toolforge.org/1733758200 2024-12-09, 15:30 UTC]</bdi></tvar> on <tvar name="platform"><bdi lang="en" dir="ltr">Google Meet</bdi></tvar> at <tvar name="link"><bdi lang="en" dir="ltr">[https://meet.google.com/xuy-njxh-rkw meet.google.com/xuy-njxh-rkw]</bdi></tvar>.</translate>
; <translate><!--T:29--> Recent updates about Wikifunctions</translate>
<!--Keep this to the most recent 6 entries-->
* 2024-12-12: [[Special:MyLanguage/Wikifunctions:Status updates/2024-12-12|<translate><!--T:140--> Sketching a path to Abstract Wikipedia; Team offsite in Lisbon; New Type: Gregorian calendar date</translate>]]
* 2024-11-27: [[Special:MyLanguage/Wikifunctions:Status updates/2024-11-27|<translate> <!--T:139--> WordGraph release; New Special page: list functions by tests; new type for day of the year</translate>]]
* 2024-11-21: [[Special:MyLanguage/Wikifunctions:Status updates/2024-11-21|<translate><!--T:138--> New special page for missing labels, new type for Gregorian years, and much more</translate>]]
* 2024-11-13: [[Special:MyLanguage/Wikifunctions:Status updates/2024-11-13|<translate><!--T:136--> New Type: Rational number</translate>]]
* 2024-11-07: [[Special:MyLanguage/Wikifunctions:Status updates/2024-11-07|<translate><!--T:137--> The Dream of a Universal Language</translate>]]
* 2024-11-01: [[Special:MyLanguage/Wikifunctions:Status updates/2024-11-01|<translate><!--T:134--> Rewriting the backend</translate>]]
</div>
[[Special:MyLanguage/Wikifunctions:Status_updates|<span class="mw-ui-button mw-ui-constructive mw-ui-small"><translate><!--T:37--> More news</translate></span>]]
</div>
</div>
</div>
</div>
<div id="sister" class="mainpage_row">
<div class="mainpage_box">
<div id="mainpage-sister" title="Sister projects" class="items" style="border-top:unset;">
<div class="mainpage-sister-title">
<div style="background: white; width:45px; margin:0 auto; margin-top: -40px;">[[File:Wikimedia-logo.svg|45px|center|link=]]</div>
<div class="plainlinks" style="color:var(--color-subtle, #54595d); font-size:120%; text-align:center; padding-top:10px;"><translate><!--T:38--> Wikifunctions is part of the non-profit, multilingual, free-content Wikimedia family.</translate></div>
</div>
<div class="mainpage-sister-projects">
*[[File:Wikipedia-logo-v2.svg|40x40px|link=w:{{int:lang}}:|alt=]]<div><span>[[w:{{int:lang}}:|{{int:Wikibase-otherprojects-wikipedia}}]]</span><br><translate><!--T:40--> Encyclopedia</translate></div>
*[[File:Wikidata-logo.svg|40x40px|link=d:|alt=]]<div><span>[[d:|{{int:Wikibase-otherprojects-wikidata}}]]</span><br><translate><!--T:42--> Knowledge base</translate></div>
*[[File:Commons-logo.svg|40x40px|link=c:|alt=]]<div><span>[[c:|{{int:Wikibase-otherprojects-commons}}]]</span><br><translate><!--T:46--> Media repository</translate></div>
*[[File:Wiktionary-logo.svg|40x40px|link=wikt:{{int:lang}}:|alt=]]<div><span>[[wikt:{{int:lang}}:|{{int:Wikibase-otherprojects-wiktionary}}]]</span><br><translate><!--T:48--> Dictionary and thesaurus</translate></div>
*[[File:Wikibooks-logo.svg|40x40px|link=b:{{int:lang}}:|alt=]]<div><span>[[b:{{int:lang}}:|{{int:Wikibase-otherprojects-wikibooks}}]]</span><br><translate><!--T:50--> Textbooks and manuals</translate></div>
*[[File:Wikinews-logo.svg|40x40px|link=n:{{int:lang}}:|alt=]]<div><span>[[n:{{int:lang}}:|{{int:Wikibase-otherprojects-wikinews}}]]</span><br><translate><!--T:52--> Free-content news</translate></div>
*[[File:Wikiquote-logo.svg|40x40px|link=q:{{int:lang}}:|alt=]]<div><span>[[q:{{int:lang}}:|{{int:Wikibase-otherprojects-wikiquote}}]]</span><br><translate><!--T:54--> Collection of quotations</translate></div>
*[[File:Wikisource-logo.svg|40x40px|link=s:{{int:lang}}:|alt=]]<div><span>[[s:{{int:lang}}:|{{int:Wikibase-otherprojects-wikisource}}]]</span><br><translate><!--T:56--> Free-content library</translate></div>
*[[File:Wikiversity logo 2017.svg|40x40px|link=v:{{int:lang}}:|alt=]]<div><span>[[v:{{int:lang}}:|{{int:Wikibase-otherprojects-wikiversity}}]]</span><br><translate><!--T:58--> Learning resources</translate></div>
*[[File:Wikivoyage-Logo-v3-icon.svg|40x40px|link=voy:{{int:lang}}:|alt=]]<div><span>[[voy:{{int:lang}}:|{{int:Wikibase-otherprojects-wikivoyage}}]]</span><br><translate><!--T:60--> Travel guides</translate></div>
*[[File:Wikispecies-logo.svg|40x40px|link=species:|alt=]]<div><span>[[species:|{{int:Wikibase-otherprojects-species}}]]</span><br><translate><!--T:64--> Directory of species</translate></div>
*[[File:Incubator-logo.svg|40x40px|link=incubator:|alt=]]<div><span>[[incubator:|<translate><!--T:65--> Incubator</translate>]]</span><br><translate><!--T:66--> New language versions</translate></div>
*[[File:Wikimedia Community Logo.svg|40x40px|link=m:|alt=]]<div><span>[[m:|{{int:Project-localized-name-metawiki}}]]</span><br><translate><!--T:70--> Project coordination</translate></div>
*[[File:MediaWiki-2020-icon.svg|40x40px|link=mw:|alt=]]<div><span>[[mw:|{{int:Project-localized-name-mediawikiwiki}}]]</span><br><translate><!--T:72--> MediaWiki development</translate></div>
</div>
</div>
</div>
</div>
</div>
__NOEDITSECTION__
__NOTOC__<languages /><noinclude>
</noinclude>
6daudzctmb6s1miulx54n0pbxlmzjw1
Wikifunctions:Requests for deletions
4
1696
147062
146501
2024-12-18T21:44:39Z
Feeglgeef
8776
/* Z20858 */ new section
147062
wikitext
text/x-wiki
<noinclude>__NEWSECTIONLINK__ __FORCETOC__</noinclude>
Functions or implementations or tests which do not work properly, do not meet notability criteria or are duplicates of another object can be deleted. Please nominate items for deletions under the "Requests for deletion" section below.
If it is obvious vandalism, just report it in [[Wikifunctions:Report vandalism]], or ping an [[Special:ListAdmins|administrator]]. Contact can also be made with an administrator on [https://t.me/Wikifunctions Telegram] or IRC [irc://irc.libera.chat/wikipedia-abstract #wikipedia-abstract].
If it is a predefined object (it's ZID is less than 10000), please see [[Wikifunctions:Report a technical problem]].
{{Autoarchive resolved section
|age = 1
|archive = ((FULLPAGENAME))/Archive/((year))/((month:##))
|level = 2
}}
{{Archives|{{Special:PrefixIndex/Wikifunctions:Requests for deletions/Archive/|stripprefix=1}}}}
== [[Z13284]] ==
Duplicate of [[Z13177]] --[[User:Ameisenigel|Ameisenigel]] ([[User talk:Ameisenigel|talk]]) 15:47, 3 October 2024 (UTC)
:{{ping|JosefAnthony|GrounderUK}} FYI --[[User:Ameisenigel|Ameisenigel]] ([[User talk:Ameisenigel|talk]]) 16:53, 27 October 2024 (UTC)
::Yes, it looks like that never progressed. It would be a shame to lose its Hausa label, assuming that’s valid for Z13177. I wouldn’t ordinarily enter a label in an unfamiliar language but this might be a justifiable exception (if @[[User:JosefAnthony|JosefAnthony]] doesn’t respond). [[User:GrounderUK|GrounderUK]] ([[User talk:GrounderUK|talk]]) 12:33, 29 October 2024 (UTC)
== [[Z20757]] and [[Z20765]] ==
Both useless, one a duplicate. [[User:Feeglgeef|Feeglgeef]] ([[User talk:Feeglgeef|talk]]) 20:31, 15 December 2024 (UTC)
== [[Z20858]] ==
I was told that this function was disruptive by a member of the Abstract Wikipedia team, please delete. Thanks! [[User:Feeglgeef|Feeglgeef]] ([[User talk:Feeglgeef|talk]]) 21:44, 18 December 2024 (UTC)
4eg20fm4n5qg4aslz6odytwyyio3qna
Z10015
0
3299
147107
104304
2024-12-19T05:10:11Z
Jérémy-Günther-Heinz Jähnick
6055
Traduction en français (fr)
147107
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z10015"
},
"Z2K2": {
"Z1K1": "Z14",
"Z14K1": "Z801",
"Z14K3": {
"Z1K1": "Z16",
"Z16K1": "Z600",
"Z16K2": "function Z801( Z801K1 ) {\n\treturn Z801K1;\n}"
}
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "JavaScript implementation of Echo"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1430",
"Z11K2": "JavaScript-Implementierung von Echo"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "écho, en JavaScript"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
p8282yz4urov8ffgdua1bl1led0yyc8
Z10044
0
3457
147108
82270
2024-12-19T05:10:28Z
Jérémy-Günther-Heinz Jähnick
6055
Traduction en français (fr)
147108
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z10044"
},
"Z2K2": {
"Z1K1": "Z14",
"Z14K1": "Z801",
"Z14K2": {
"Z1K1": "Z18",
"Z18K1": "Z801K1"
}
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "echo composition"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1430",
"Z11K2": "Implementierung der Echo-Komposition"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "écho, en Composition"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
1dyyaap5uf3ie18lkqugzfq1n6ehz5e
Wikifunctions:Requests for user groups
4
3790
147034
146992
2024-12-18T16:18:12Z
Feeglgeef
8776
close
147034
wikitext
text/x-wiki
{{shortcut|[[WF:RFG]]|[[WF:PERM]]|[[WF:RFUG]]}}
This is the place to request specific user groups:
{{ombox
| image = [[File:Echo user-rights icon.svg|60x60px|alt=|link=]]
| text = '''How to make a request'''
#Edit the section for the user group you wish to request
#Copy the following and ''append'' it to the text-area:
##Requests without required discussion: <code><nowiki>{{subst:rfg|1={{subst:REVISIONUSER}}|2=reason ~~~~}}</nowiki></code>
##Requests with required discussion: <code><nowiki>{{subst:rfg|3=1|1={{subst:REVISIONUSER}}|2=reason ~~~~}}</nowiki></code>
#Replace <code>reason</code> with a rationale based on the guidelines specified for the user group
}}
:''Archived requests can be found at [[Wikifunctions:Requests for user groups/Archive]]''
{{Autoarchive resolved section
|age =1
|archive =((FULLPAGENAME))/Archive/((year))/((month:##))
|level =3
}}
==Confirmed==
{{see also|Wikifunctions:Confirmed users}}
== Functioneer ==
{{see also|Wikifunctions:Functioneers}}
==Maintainer==
{{see also|Wikifunctions:Maintainers}}
This role is not yet available.
==Autopatroller==
{{See also|Wikifunctions:Autopatrollers}}
==Administrator==
{{see also|Wikifunctions:Administrators}}
{{atop}}
=== Mdaniels5757 ===
{{UL2.0|1=Mdaniels5757|contributions=1|deletedcontributions=1|editcount=1|blocklog=1|rightslog=1|crosswiki=1}}
:''Discussion open until: 16:18, 18 December 2024 (UTC)''
:Hi! I'd like to request renewal of my adminship and interface adminship. I am still not the most active here, but I hope to continue to be trusted with the tools so I can continue helping by making interface changes and deletions where needed. (Links to previous requests for convienence: [[Wikifunctions:Requests for user groups/Archive/2023/08#Interface administrator and Sysop|1 (by decree)]], [[Wikifunctions:Requests for user groups/Archive/2023/12#Mdaniels5757|2]]). Best, —‍[[User:Mdaniels5757|Mdaniels5757]] ([[User talk:Mdaniels5757|talk]] • [[Special:Contributions/Mdaniels5757|contribs]]) 16:18, 11 December 2024 (UTC)
::{{s}}, LGTM [[User:Feeglgeef|Feeglgeef]] ([[User talk:Feeglgeef|talk]]) 19:36, 11 December 2024 (UTC)
:::@[[User:Feeglgeef|Feeglgeef]] I actually have, see https://www.wikifunctions.org/w/index.php?title=Special%3AContributions&target=Mdaniels5757&namespace=8&tagfilter=&start=&end=&limit=50. Edits to .css and .js pages in the MediaWiki namespace, and edits to [[MediaWiki:Gadgets-definition]] all require interface adminship. —‍[[User:Mdaniels5757|Mdaniels5757]] ([[User talk:Mdaniels5757|talk]] • [[Special:Contributions/Mdaniels5757|contribs]]) 03:42, 15 December 2024 (UTC)
::::Ah, ok, will change again. [[User:Feeglgeef|Feeglgeef]] ([[User talk:Feeglgeef|talk]]) 03:56, 15 December 2024 (UTC)
::::MediaWiki:Gadgets-definition does not, but CSS and JS require interface admin. --[[User:Ameisenigel|Ameisenigel]] ([[User talk:Ameisenigel|talk]]) 21:19, 15 December 2024 (UTC)
:::::@[[User:Ameisenigel|Ameisenigel]] The [[MediaWiki:Gadgets-definition]] page is actually a bit unique among wikitext pages in the MediaWiki namespace. Per [https://www.wikifunctions.org/w/index.php?title=MediaWiki:Gadgets-definition&action=info], editing the page is limited to users with "editsitecss, editsitejs" permission. I'm not sure if it requires just one of the two, or both, but per [[Special:ListGroupRights]], only interface admins have either of those rights locally.
:::::(Ordinary gadget pages, like [[MediaWiki:Gadget-popups]], are treated as normal wikitext pages in the MediaWiki namespace, which, as you note, can be edited by sysops and interface-admins). —‍[[User:Mdaniels5757|Mdaniels5757]] ([[User talk:Mdaniels5757|talk]] • [[Special:Contributions/Mdaniels5757|contribs]]) 03:26, 16 December 2024 (UTC)
::::::Interesting, thank you for the explanation. --[[User:Ameisenigel|Ameisenigel]] ([[User talk:Ameisenigel|talk]]) 07:08, 16 December 2024 (UTC)
::{{S}} --[[User:Ameisenigel|Ameisenigel]] ([[User talk:Ameisenigel|talk]]) 18:56, 11 December 2024 (UTC)
{{abot}}
{{Section resolved|[[User:Feeglgeef|Feeglgeef]] ([[User talk:Feeglgeef|talk]]) 16:18, 18 December 2024 (UTC)}}
==Interface administrator==
{{see also|Wikifunctions:Interface administrators}}
==Translation administrator==
{{see also|Wikifunctions:Translation administrators}}
=== Alexander-Mart-Earth ===
{{UL2.0|1=Alexander-Mart-Earth|contributions=1|deletedcontributions=1|editcount=1|blocklog=1|rightslog=1|crosswiki=1}}<br>
Discussion open until: 22:54, 18 December 2024 (UTC)
Some translation edits (at functions namespace):
[[Special:Contributions/Alexander-Mart-Earth]]
My main local wiki profile:
[[w:ru:User:Alexander-Mart-Earth]] [[User:Alexander-Mart-Earth|Alexander-Mart-Earth]] ([[User talk:Alexander-Mart-Earth|talk]]) 22:54, 11 December 2024 (UTC)
:{{o}} you haven't stated ''why'' you'd like the group. Will likely change if you provide a reason. Thanks! [[User:Feeglgeef|Feeglgeef]] ([[User talk:Feeglgeef|talk]]) 21:10, 12 December 2024 (UTC)
:{{O}} You do not need this right to translate things --[[User:Ameisenigel|Ameisenigel]] ([[User talk:Ameisenigel|talk]]) 21:20, 15 December 2024 (UTC)
==Bureaucrat==
{{see also|Wikifunctions:Bureaucrats}}
== Miscellaneous requests ==
=== DannyS712 bot ===
I want to get approval for a bot with translation admin rights that will automatically mark pages for translations if and only if the latest version is identical to the version that is already in the translation system, i.e. only pages with no "net" changes in the pending edits. I am filing almost identical requests for bot approval on a bunch of wikis, and figured I should put some of the details in a central location. Please see [[:meta:User:DannyS712/TranslationBot]] for further info. --[[User:DannyS712|DannyS712]] ([[User talk:DannyS712|talk]]) 12:44, 21 July 2024 (UTC)
:Could you performe some tests (with your regular account)? --[[User:Ameisenigel|Ameisenigel]] ([[User talk:Ameisenigel|talk]]) 14:30, 28 July 2024 (UTC)
::@[[User:Ameisenigel|Ameisenigel]] I'd prefer to avoid added bot passwords to my personal account - would you be willing to accept the trial on Wikidata, where the bot account has been granted translation admin rights (once I actually do the trial) as a working demonstration, given that the code is going to essentially be identical? --[[User:DannyS712|DannyS712]] ([[User talk:DannyS712|talk]]) 17:17, 29 July 2024 (UTC)
:::Sure, that would work as well. --[[User:Ameisenigel|Ameisenigel]] ([[User talk:Ameisenigel|talk]]) 17:38, 29 July 2024 (UTC)
=== Feeglbot ===
For maintenance tasks from time to time or execution of a list of very-small-human-intervention edits. This is quite broad, so I will notify on the project chat with specifics at least 48 hours before doing anything with it. It will require functioneer. [[User:Feeglgeef|Feeglgeef]] ([[User talk:Feeglgeef|talk]]) 04:26, 18 December 2024 (UTC)
==See also==
* [[Wikifunctions:User groups]]
** [[mw:Help:Wikifunctions/User rights]] for additional context about functioneers, maintainers, sysops, and bureaucrats
[[Category:User groups|*]]
r6l09e34ne5w7x0nv91ydqp4r0ni0g8
Z15788
0
29198
147109
99071
2024-12-19T05:10:44Z
Jérémy-Günther-Heinz Jähnick
6055
Traduction en français (fr)
147109
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z15788"
},
"Z2K2": {
"Z1K1": "Z14",
"Z14K1": "Z801",
"Z14K3": {
"Z1K1": "Z16",
"Z16K1": "Z610",
"Z16K2": "def Z801(Z801K1):\n\treturn Z801K1"
}
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Python echo"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "écho, en Python"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Returns its one input unchanged"
}
]
}
}
2ecv8s8pzxh8fpu12vgbt43312jt3jr
Wikifunctions:Type proposals/Gregorian calendar date
4
32934
147030
145702
2024-12-18T14:17:04Z
Feeglgeef
8776
change to done
147030
wikitext
text/x-wiki
{{done}} [[Z20420]]
== Summary ==
A Gregorian calendar date identifies a specific day using the Gregorian calendar system introduced in 1582. It is the most widely used calendar system today.
The Type is proleptic, i.e. it is also calculated backwards before its introduction.
There is no year 0. Another type can be introduced that has a year 0. The Type is naïve with regards to UTC, i.e. it ignores it as it only resolves to the level of days. When we introduce Functions and Types with a higher resolution, we need to resolve possible discrepancies.
== Uses ==
* ''Why should this exist?''
In order to be able to reference dates and have functions that work with dates.
* ''What kinds of functions would be created using this?''
** How old was a person when they died?
** How many days have passed between two days
** What day of the week was a certain day (requires days of the week as a type)
** What is this date in another calendar? (requires the other calendar)
** What is the Julian number of a given date?
** When is Easter Sunday in a given year? (one of the main use cases for introducing the calendar)
* ''What standard concepts, if any, does this align with?''
The Gregorian calendar date is widely used. It was introduced through the Papal bull Inter gravissimas.
This is not the same as the time datatype in Wikidata, but it can be used in using it.
== Structure ==
A Gregorian calendar date has two keys:
# K1 of Type [[Wikifunctions:Type proposals/Gregorian year|Gregorian year]]
# K2 of Type [[Wikifunctions:Type proposals/Day of Roman year|Roman day of the year]]
=== Example values ===
Value for October 27, 2014:
{|class="wikitable" style="margin:.6em 1.6em"
|-
| <syntaxhighlight lang="json" line="line">{
"type": "Gregorian calendar date",
"year": {
"type": "Gregorian year",
"era": "CE",
"year": {
"type": "Natural number",
"value": "2014"
}
},
"day of the year": {
"type": "Day of the Roman year",
"month": "October",
"day": {
"type": "Natural number",
"value": "27"
}
}
}</syntaxhighlight>
| <syntaxhighlight lang="json">{
"Z1K1": "Znnn",
"ZnnnK1": {
"Z1K1": "Zppp",
"ZpppK1": "Zqqq",
"ZpppK2": {
"Z1K1": "Z13518",
"Z13518K1": "2014"
}
},
"ZnnnK2": {
"Z1K1": "Zmmm",
"ZmmmK1": "Z16110",
"ZmmmK2": {
"Z1K1": "Z13518",
"Z13518K1": "27"
}
}
}</syntaxhighlight>
|}
== Validator ==
The validator ensures that:
* February 29 only appears in leap years
* Further validation will be performed by the types used in the keys.
* If we limit the years, the validator should implement the limitations
== Identity ==
Two dates are the same if their day of the year and their year are the same.
== Converting to code ==
=== Python ===
Here are three proposals how to convert to Python.
==== 4 keys ====
We convert the Gregorian calendar into a dictionary with the following structure (for the above example date):
<syntaxhighlight lang="python">{
'K1': True,
'K2': 2014,
'K3': 10,
'K4': 27
}</syntaxhighlight>
==== 3 keys ====
1 BC is represented by 0, and 2 BC by -1, etc.
<syntaxhighlight lang="python">{
'K1': 2014,
'K2': 10,
'K3': 27
}</syntaxhighlight>
==== 2 keys ====
We could use a two-key object, with one key being Python's date object, and the other being an offset. The offset must be a multiple of 400, in order to ensure that weekdays line up. It is usually 0, unless it is out of range for Python (i.e. after December 31st 9999 or before January 1st 1). For conversion, the offset is a multiple of 2000. The multiple can be negative.
<syntaxhighlight lang="python">{
'K1': datetime.date(2014, 10, 27),
'K2': 0
}</syntaxhighlight>
The proper handling of the offset is a bit iffy.
=== JavaScript ===
==== 4 keys ====
We will use the following object to convert to:
<syntaxhighlight lang="javascript">{
K1: true,
K2: 2014n,
K3: 9,
K4: 27
}</syntaxhighlight>
Note that as with Gregorian calendar months, months are started to be counted with 0, i.e. October is 9, not 10.
==== 3 keys ====
We will use the following object:
<syntaxhighlight lang="javascript">{
K1: 2014n,
K2: 9,
K3: 27
}</syntaxhighlight>
Non-positive numbers for K1 represent the years BC, with 0 being 1 BC, -1 being 2 BC, etc.
==== 2 keys ====
The language standard Date object has an impressive range, covering more than a quarter million years into the future and the past (to be exact, from 20 April 271821 BCE to 13 September 275760 CE). Nevertheless, in order to cover the unlimited range of the Wikifunctions type, we need more.
We use a two-key object, with one key being JavaScript's Date object, and the other being an offset. The offset must be a multiple of 200000 as a BigInt, in order to ensure that weekdays line up. It is usually 0, unless it is out of range for JavaScript (i.e. after September 13th 275760 or before April 20th 271821 BC). The multiple can be negative.
<syntaxhighlight lang="javascript">{
K1: new Date(2014, 10, 27),
K2: 0n
}</syntaxhighlight>
The proper handling of the offset is a bit iffy.
==== Pure date object ====
We limited to dates for the Gregorian calendar date in the range of arbitrary years within the range of the JavaScript object, e.g. we say that all dates have to be before 100000AD and after 100000BC. In that case we can just use JavaScript's builtin Date object directly.
== Renderer ==
Renderers depend on the language. We will start with a general renderer outputting an ISO string as the default behaviour, i.e. “2014-10-27 CE”, but we will have a configuration that can be adjusted for a given language, e.g. "27 October 2014" or "le 27 octobre 2014 AD".
== Parsers ==
Parsers depend on the language. We will start with a general parser that can take an ISO string as the default behaviour, but we will have a configuration that can be adjusted for a given language.
== Alternatives ==
# We could use different calendars for dates. And we certainly should! This is just to support a first calendar. Proposals for other calendars are welcome.
# We could follow ISO 8601 and have a year 0. But this would be inconsistent with most usages on Wikipedia. The suggestion is that we should have an ISO 8601 compatible calendar date as its own Type.
# The Type could be non-proleptic, i.e. not allow dates before its introduction (though its introduction varied by location and polity, so this becomes complicated).
# The Type could use both the Julian calendar before the introduction of the Gregorian calendar, and Gregorian aftwards, instead of being proleptic. Whereas such a date Type might be very interesting, as it may be the closest to what most written texts including Wikipedia and encyclopaedias are doing, it would be very difficult to implement correctly, might be confusing for users, and it would need an underlying proleptic Gregorian calendar date as a supporting Type anyway. So, we start here with the proleptic Gregorian calendar date, and allow for the development of a more complex Type later, that supports a mixed calendar model.
# Instead of using two keys with the new “day of the Roman year” Type and “Gregorian year” type, we could have a flatter representation with four keys, for a day, month, year, and era. Since both these subtypes seem useful in their own right, we used the more composed approach instead.
# some mixes between the previous and current proposal could also be possible, i.e. flatten the day of the year but not the year or the other way around.
# Instead of using a year and an era, we could use the Integer Type, and interpret negative numbers as being BCE. This seems more aligned with the ISO 8601 calendar though, which allows a year 0. Since we do not have a year 0, using the Integer Type could easier lead to mistakes.
# We could represent every day with just an Integer for the Julian day number, and make it look like a calendar day using parsers and renderers.
# The Type could be aware of UTC and define itself with a specific time zone in mind. There is a necessity for a naive date type, in order to express birthdays, events, etc., which often are intentionally naive with regards to a timezone (e.g. if a person is born in San Francisco at 23:30 on December 31st 2000, the person would have been born on January 1st 2001 6:30 UTC. We don’t want to record their Birthdate as January 1st 2001 instead of December 31st 2000. So we need to have Functions that assume naivety with regards to UTC.
# Instead of leaving unlimited time frames, we could stop at some big (but ultimately arbitrary) date, e.g. 100,000 BCE to 100,000 CE. Given the imprecision of the Gregorian calendar and the change in speed of the Earth, it is likely that the Gregorian proleptic calendar would fail outside of this time frame anyway. In addition, this would allow us to use the built-in JavaScript Date object, which could be a real advantage of this limitation. Dates outside this timeframe seem extremely rare.
# We could even constrain it to the space that Python covers (from 1CE to 9999 CE), but that seems too limiting
== Discussion ==
* {{s}} as proposer with the three-key representation. --[[User:DVrandecic (WMF)|DVrandecic (WMF)]] ([[User talk:DVrandecic (WMF)|talk]]) 20:30, 26 June 2024 (UTC)
*:Another alternative is a variation of 8 that recognises that the Gregorian calendar is a 146,097-day cycle. Specifying a Natural number representing the day within the cycle and an integer representing the cycle is guaranteed to convert as simply as possible. [[User:GrounderUK|GrounderUK]] ([[User talk:GrounderUK|talk]]) 18:23, 27 November 2024 (UTC)
*::(Bearing in mind that 146,097 is a multiple of seven, so the weekdays also repeat.) [[User:GrounderUK|GrounderUK]] ([[User talk:GrounderUK|talk]]) 19:22, 27 November 2024 (UTC)
*::{{o}} this, we should approach how people think of a calendar. This is convincing in its simplicity. Maybe its own type in the mid-far future? [[User:Feeglgeef|Feeglgeef]] ([[User talk:Feeglgeef|talk]]) 19:28, 27 November 2024 (UTC)
*:::Yeah, that’s why I flagged it as an “alternative”. It’s relevant for extensions beyond the ranges supported by date types in Python and JavaScript, however, as in [[Z20311]]. [[User:GrounderUK|GrounderUK]] ([[User talk:GrounderUK|talk]]) 19:52, 27 November 2024 (UTC)
* {{S}} will be a useful type --[[User:Ameisenigel|Ameisenigel]] ([[User talk:Ameisenigel|talk]]) 17:54, 6 July 2024 (UTC)
* I'm personally in favor of a three key type converter, where K1 is the ISO year, same as the existing year type converter, K2 is the month, from 1-12, and K3 is the day, from 1-31. This would be better than the offset system, which I think will lead to confusion and complicate things, and better than the 4 key system, because it matches the year conversion and is easier to work with. [[User:Feeglgeef|Feeglgeef]] ([[User talk:Feeglgeef|talk]]) 17:29, 27 November 2024 (UTC)
*:@[[User:Feeglgeef|Feeglgeef]] I like the proposal in general, but shouldn't the month be 0-11 in JavaScript and 1-12 in Python, to keep it consistent with the respective languages? --[[User:Denny|Denny]] ([[User talk:Denny|talk]]) 18:53, 27 November 2024 (UTC)
*::Yes, sorry! [[User:Feeglgeef|Feeglgeef]] ([[User talk:Feeglgeef|talk]]) 19:11, 27 November 2024 (UTC)
*:# I can’t see why the Wikifunctions representation of month would be anything other than [[Z16098]]. This avoids any possibility of confusion between days and months. It already converts to an integer in Python and JavaScript and I’m not aware of any issues with that.
*:# Automatic conversion to native Date representations in code is a high priority. I don’t see that introducing an intermediate representation (as in the original proposal) is an advantage.
*:#Avoiding a year zero is desirable, but precise dates from the period are uncommon and, of course, were not recorded using this calendar.
*:#For years, I do see advantages in consistency with ISO 8601, however. It may be unimportant to recall that the ISO 8601 representation of a year is a string with a minimum of four characters (where year 0000 represents 1 BC). Years outside this range require an initial + or - character. This converts easily to an integer, of course, but the decision of when to convert it for Wikifunctions seems finely balanced. A hybrid representation with an ISO 8601 string year and a [[Z16098]] seems a viable date object, at least, and would offer simpler conversions to an ISO 8601 type, once it’s available.
*:#It would seem a little odd not to extend that thinking to the day as well. However, I think people generally intuit the day of the month as a positive Natural number. I am tempted to propose a new type of “little counting number” that represents the natural numbers from 1 to 31, but I won’t.
*:#I see no real advantage in embedding the day of the month within a [[Z20342]] (in the case where the year is known), but consistency between the date type and [[Z20342]] should be conserved, even if that means changes to [[Z20342]]. This reinforces point 1.
*:#{{neutral}} {[[Z6]], [[Z16098]], [[Z13518]]}, where [[Z6]] is an ISO 8601 representation of the year (which would be better as a specific subtype of Type Z6, even if that is a general “constrained string” of some kind (with a Regular Expression filter, for example)).
*:#{{neutral}} {[[Z16683]], [[Z16098]], [[Z13518]]}. This is likely to be less efficient because of the explicit [[Z16659]] in the [[Z16683]].
*:[[User:GrounderUK|GrounderUK]] ([[User talk:GrounderUK|talk]]) 11:25, 28 November 2024 (UTC)
* I'm going to create a definition of this type from scratch, as I'd like to make this technically real-calendar independent. Below is a possibly up-for-interpretation definition I will use.
** "The start of 30 Nov" will be the start of the date 30 November, 2024 in [[w:UTC]], around the time this comment was sent. It is the Unix timestamp in seconds 1732924800. You can view said time in your timezone [https://zonestamp.toolforge.org/1732924800 here]
: With that out of the way, here's my definition for this type:
: A day is equal to the duration of 794,243,384,932,000 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the caesium 133 atom, at rest, at a temperature of absolute zero
: A month can be equal to anywhere from 28-31 days.
:* January is 31 days long
:* February is 28 or 29 days long, depending on whether the day is in a leap year.
:* March is 31 days long
:* April is 30 days long
:* May is 31 days long
:* June is 30 days long
:* July is 31 days long
:* August is 31 days long
:* September is 30 days long
:* October is 31 days long
:* November is 30 days long
:* December is 31 days long
:A literal year is equal to the duration of 290,091,439,521,026,010 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the caesium 133 atom, at rest, at a temperature of 0 Kelvin
:To advance days, you add one to the day number in the month. If this number becomes larger than the length of the month, the day number is set to 1 and the month is incremented by 1. If the month is December, one is added to the calendar year counter, and the month counter is reset to January and the day counter to 1.
:The start of 30 Nov is the time at which the day 30 November 2024 (Day counter: 30, Month: November, Calendar year: 2024) is started, thus, 1 December 2024 (Day counter: 1, Month: December, Calendar year: 2024) counter starts one day after 30 November.
:This can also be applied in reverse, so the 29 November 2024 (Day counter: 29, Month: November, Calendar year: 2024) starts one day before The start of 30 Nov.
:Because there is not a round number of days in one literal year, some calendar years are leap years, where February has 29 days. February only has 29 days in calendar years where the number is visible by 4, and, either the number is not divisible by 100 or the number is divisible by 400
:Days can be added or subtracted infinitely. The only anchor for this system is The start of 30 Nov.
:When the Calendar year goes to or above 0, the date to be in the era BC. Otherwise, the date is in the era AD
:Every day has an attached Weekday. Weekdays are a cycle of 7. They are Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, where adding one day moves one forward, and removing one day moves one backward. The day of 30 November 2024 is Saturday.
: I hope this clears everything up. Thanks! [[User:Feeglgeef|Feeglgeef]] ([[User talk:Feeglgeef|talk]]) 00:06, 30 November 2024 (UTC)
::The current definition of the SI second is likely to be superseded within ten years.
::https://www.bipm.org/en/redefinition-second
::Although it is unlikely that additional leap seconds will be agreed between now and 2035 (when it has been agreed that they will cease), it makes sense to define t<sub>O</sub> as some point in 2036. I don’t see the relevance of the definition of a second for this particular type, however. [[User:GrounderUK|GrounderUK]] ([[User talk:GrounderUK|talk]]) 10:59, 30 November 2024 (UTC)
:::I don't see where the definition of a second is mentioned? This actively avoids said definition. [[User:Feeglgeef|Feeglgeef]] ([[User talk:Feeglgeef|talk]]) 13:06, 30 November 2024 (UTC)
== Comments and Votes ==
Given the above options for conversion, which ones should be used?
* I am for the three key solution, for both Python and JavaScript --[[User:Denny|Denny]] ([[User talk:Denny|talk]]) 20:11, 28 November 2024 (UTC)
*I would prefer three keys as well. --[[User:Ameisenigel|Ameisenigel]] ([[User talk:Ameisenigel|talk]]) 20:25, 28 November 2024 (UTC)
*Three keys, as effective proposer. Two keys looks good on paper, but when I did testing with it I found it to have too many flaws, especially with full support of all years, and I don't think it would be appropriate for a type that does support BC years. I think we should have a type in the future for the 1-9999 AD range, so that we can convert well in Python. Thanks![[User:Feeglgeef|Feeglgeef]] ([[User talk:Feeglgeef|talk]]) 20:38, 28 November 2024 (UTC)
:@[[User:GrounderUK|GrounderUK]] @[[User:Ameisenigel|Ameisenigel]] @[[User:Feeglgeef|Feeglgeef]] -- pings to see if you have thoughts on the three options. --[[User:Denny|Denny]] ([[User talk:Denny|talk]]) 20:14, 28 November 2024 (UTC)
::{{ping|99of9}} too [[User:Feeglgeef|Feeglgeef]] ([[User talk:Feeglgeef|talk]]) 20:39, 28 November 2024 (UTC)
::JavaScript’s range is difficult to justify, so extending it further by the use of a BigInt for the year seems gratuitous. As it adds some complexity for the coder if the three numbers are of different types, I would prefer to see the year being converted into a Number (integer) (or an ISO 8601 string if the BigInt range is important).
::On the assumption that some sort of access to common Python functions (implementations) will become available even if full re-entrancy (across languages) is delayed, I’m inclined to oppose conversion to a Python Date object with offset. I don’t oppose a separate value representing the Gregorian era, allowing the avoidance of a year zero but it would be confusing to diverge from JavaScript for little benefit. (This would a little weight to the option for the year to be an ISO 8601 string in both conversions but I don’t believe Python
::natively supports the extended range above 9999 or below 0000, so, in fact, it pushes us back to an integer year.)
::So, yeah…
::<s>{{S}}</s> Three keys, with the year as either Number or BigInt in JavaScript, depending on whether the range is limited by the converter (which I would argue is sensible, even if the JavaScript limits are not chosen; the actual limits could be changed with little or no impact, so long as they remain within the safe integer range, I believe). [[User:GrounderUK|GrounderUK]] ([[User talk:GrounderUK|talk]]) 12:25, 29 November 2024 (UTC)
:::{{o}} On reflection, I believe that year, month and day should all be converted to BigInt in JavaScript. This is because accompanying number arguments will be BigInt-based and having to approach months and days differently from years is an unnecessary source of confusion and error. (It will also be consistent with Python.) I also believe that it was a mistake to implement [[Z20342]] with conversions to Number rather than BigInt (as in [[Z20236]]). We should change this while we still have very few JavaScript implementations (like [[Z20335]], where the impact is small).
:::(For the avoidance of doubt, I remain ambivalent on the question of limiting years in any way, but this would be an irrelevant consideration if year, month and day are all BigInt.) [[User:GrounderUK|GrounderUK]] ([[User talk:GrounderUK|talk]]) 12:40, 1 December 2024 (UTC)
::::{{s}} this is fine. [[User:Feeglgeef|Feeglgeef]] ([[User talk:Feeglgeef|talk]]) 12:58, 1 December 2024 (UTC)
:::::At second thought, I {{o}} this, making months and days BigInts is counterintuitive, especially with what the BigInt spec says they are for. [[User:Feeglgeef|Feeglgeef]] ([[User talk:Feeglgeef|talk]]) 01:06, 3 December 2024 (UTC)
::::This argument-typing issue has the potential to be very difficult. I agree that if we have 3 JS keys, they are better off all being either int or bigint (I'd go with int though, to simplify the efforts of implementation writers, and because int covers the natural range of all three args). But I see that if we are calling our other functions, they are currently bigint based. Are we anticipating never ever having a small int type? If we anticipate one, maybe we should make that first? It might also help to have more information about how re-entrancy will work. If one JS function calls another inline, will the object returned go through conversion from code and then conversion to code before it is returned, or do we get it directly? [[User:99of9|99of9]] ([[User talk:99of9|talk]]) 00:04, 3 December 2024 (UTC)
:::::Instead of re-entrancy, what we really should do is eval the functions themselves inside the evaluator, avoiding the whole re-entrancy thing. This does mean that a function must have an implementation in the programming language you are using, but this a sacrifice worth making. Otherwise, I see a large amount of implementations that are too slow to run. [[User:Feeglgeef|Feeglgeef]] ([[User talk:Feeglgeef|talk]]) 01:04, 3 December 2024 (UTC)
* I'll put my placeholder vote in, but I feel we still need discussion/information to get this right. For Python I agree with 3 keys. For JS: my preference if we can get it to work is for a single key in Date type. My second preference would be three keys all int. My third would be three keys all bigint. My fourth would be three keys with int,int,bigint. I don't put any value on Gregorian dates outside the (-250k,+250k) range, so am happy for the JS code-converter to return an error if infinite-input is allowed through the validator. But as in my reply to [[User:GrounderUK|GrounderUK]] above, if he is right about re-entrancy issues, then my programmer-centric-idealism order may have to change. --[[User:99of9|99of9]] ([[User talk:99of9|talk]]) 00:18, 3 December 2024 (UTC)
*:You not putting any value on dates where 250000>x>-250000 does not mean that others won't! [[User:Feeglgeef|Feeglgeef]] ([[User talk:Feeglgeef|talk]]) 01:07, 3 December 2024 (UTC)
== Decision ==
Unfortunately, we didn't come to a consensus, but the discussion has quieted down. So I made a decision to go with the three key solution for both programming languages. For Python it was uncontroversial, for JavaScript there have been good arguments laid out for both the 1-key and 3-key solution. I chose the 3-key solution in order to not have an arbitrary (although very defensible) limit on the type. I also choose to remain consistent with the JavaScript representations of the components, [[Z20342]] and [[Z20159]]. I have seen good arguments for other options, but in the end I decided that consistency is the way to go.
[[Z20420]] is the type, and I hope I got the conversions right. A few functions have been already created, but the implementations are not perfect yet, which should become visible with more test cases:
* [[Z20430]], this one should be good
* [[Z20440]], this one should be fine for Python, but JavaScript should run into issues beyond the JS date type borders
* [[Z20421]], this one should run into issues both for Python and for JavaScript beyond their respective borders
For now, I am still leaving a warning on the type, but I plan to remove this within 24 hours unless significant issues are discovered.
Thanks everybody for joining this lively discussion! --[[User:DVrandecic (WMF)|DVrandecic (WMF)]] ([[User talk:DVrandecic (WMF)|talk]]) 16:07, 10 December 2024 (UTC)
2qe8u5o2feww8sfwl68cc4s332izmfx
Translations:User:WikiLambda system/Page display title/arz
1198
33192
147032
112664
2024-12-18T16:15:14Z
Meno25
27
147032
wikitext
text/x-wiki
يوزر:نظام ويكي لامبدا
fu58ezt89uztoafgnxpphy2e1xclk6m
User:Feeglgeef
2
41873
147031
146854
2024-12-18T15:36:07Z
Feeglgeef
8776
147031
wikitext
text/x-wiki
{{#babel:en|hu-3|la-2|de-2|es-1|dag-1|ml-0|functioneer}}
Hello! I'm Feeglgeef (fiːɡələɡːif/FEE-guhluhg-eef). I'm a functioneer here, and I contribute wherever I can. If you need anything, feel free to leave me a message on [[User talk:Feeglgeef]], ping me on any talk page, or ping me on the Telegram. I'd consider myself proficient with both Javascript and Python.
==Things I'm proud of==
*[[Z20181]] (FOTW 2024-11-27)
*[[Z20756]]
*[[Z20290]]
*[[Z20808]]
*[[Z19601]]
nw78sga3b7uca1c4z1x0b28u066ijsr
147035
147031
2024-12-18T17:12:14Z
Feeglgeef
8776
147035
wikitext
text/x-wiki
{{#babel:en|hu-3|la-2|de-2|es-1|dag-1|ml-0|functioneer}}
Hello! I'm Feeglgeef (fiːɡələɡːif/FEE-guhluhg-eef). I'm a functioneer here, and I contribute wherever I can. If you need anything, feel free to leave me a message on [[User talk:Feeglgeef]], ping me on any talk page, or ping me on the Telegram. I'd consider myself proficient with both Javascript and Python.
==Functions I'm proud of==
*[[Z20181]] (FOTW 2024-11-27)
*[[Z19514]] (FOTW 2024-11-07)
*[[Z20756]]
*[[Z20290]]
*[[Z20808]]
*[[Z19601]]
lhknnfv7yp0j4bothsj7h0b9rekyj0p
147036
147035
2024-12-18T17:14:01Z
Feeglgeef
8776
/* Functions I'm proud of */
147036
wikitext
text/x-wiki
{{#babel:en|hu-3|la-2|de-2|es-1|dag-1|ml-0|functioneer}}
Hello! I'm Feeglgeef (fiːɡələɡːif/FEE-guhluhg-eef). I'm a functioneer here, and I contribute wherever I can. If you need anything, feel free to leave me a message on [[User talk:Feeglgeef]], ping me on any talk page, or ping me on the Telegram. I'd consider myself proficient with both Javascript and Python.
==Functions I'm proud of==
*[[Z20181]] (FOTW 2024-11-27)
*[[Z19514]] (FOTW 2024-11-07)
*[[Z20780]] (connected renderer for [[Z20420]])
*[[Z20756]]
*[[Z20290]]
*[[Z20808]]
*[[Z19601]]
d02jfh7r5van1w4ct4l6zn8kfa57hqu
147037
147036
2024-12-18T17:16:08Z
Feeglgeef
8776
/* Functions I'm proud of */
147037
wikitext
text/x-wiki
{{#babel:en|hu-3|la-2|de-2|es-1|dag-1|ml-0|functioneer}}
Hello! I'm Feeglgeef (fiːɡələɡːif/FEE-guhluhg-eef). I'm a functioneer here, and I contribute wherever I can. If you need anything, feel free to leave me a message on [[User talk:Feeglgeef]], ping me on any talk page, or ping me on the Telegram. I'd consider myself proficient with both Javascript and Python.
==Functions I'm proud of==
*[[Z20181]] (FOTW 2024-11-27)
*[[Z19514]] (FOTW 2024-11-07)
*[[Z20780]] (connected renderer for [[Z20420]])
*[[Z20756]]
*[[Z20290]]
*[[Z20808]]
*[[Z19601]]
*[[Z20863]]
rubcmks3s6npp56rr2zh4sym95chcbf
147038
147037
2024-12-18T17:25:34Z
Feeglgeef
8776
147038
wikitext
text/x-wiki
{{#babel:en|hu-3|la-2|de-2|es-1|dag-1|ml-0|functioneer}}
Hello! I'm Feeglgeef (fiːɡələɡːif/FEE-guhluhg-eef). I'm a functioneer here, and I contribute wherever I can. If you need anything, feel free to leave me a message on [[User talk:Feeglgeef]], ping me on any talk page, or ping me on the Telegram. I'd consider myself proficient with both Javascript and Python.
==Functions I'm proud of==
*[[Z20181]] (FOTW 2024-11-27)
*[[Z19514]] (FOTW 2024-11-07)
*[[Z20780]] (connected renderer for [[Z20420]])
*[[Z20430]] (connected equality function for [[Z20420]])
*[[Z20756]]
*[[Z20290]]
*[[Z20808]]
*[[Z19601]]
*[[Z20863]]
3tlymvddq9zi5zhgqrpnzkahneo7tul
Wikifunctions:Tools
4
45165
147102
145297
2024-12-19T05:01:46Z
Feeglgeef
8776
147102
wikitext
text/x-wiki
This page is a list of tools you can use to work with Wikifunctions more quickly and comfortably. If you have written a script, feel free to add it so that others can use it.
* [//wf-query.replit.app wf-query]: tool that allows you to run JSONata queries on a dump of Wikifunctions, with the table output itself also being customizable with JSONata queries. Written in [[w:Node.js|NodeJS]] Express and [[w:JavaScript|vanilla JS]]
* [//play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b148d3d147139ddf88cdbc8308bec6e3 find constants]: tool that represents a f64 using Wikifunctions representation. Prints, comma separated, the sign of the float (-1, 0, 1), the exponent of the float, and the fraction of the float. Written in [[w:Rust|Rust]].
* [//gitlab.wikimedia.org/hogue/cobol-file-collection/-/blob/main/Wikifunctionsdumpextract/Dumpextract.cbl Dumpextract]: a program to extract info from the dump of Wikifunctions. Written in [[w:COBOL|COBOL]].
*[[User:Feeglgeef/wikilambda editsource.js|wikilambda editsource.js]]: User script that allows you to edit the raw JSON content of ZObjects.
3ob1fkk6tupbg9hiqjvbtr5obxzhkpr
147103
147102
2024-12-19T05:03:08Z
Feeglgeef
8776
link to correct article
147103
wikitext
text/x-wiki
This page is a list of tools you can use to work with Wikifunctions more quickly and comfortably. If you have written a script, feel free to add it so that others can use it.
* [//wf-query.replit.app wf-query]: tool that allows you to run JSONata queries on a dump of Wikifunctions, with the table output itself also being customizable with JSONata queries. Written in [[w:Node.js|NodeJS]] Express and [[w:JavaScript|vanilla JS]]
* [//play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b148d3d147139ddf88cdbc8308bec6e3 find constants]: tool that represents a f64 using Wikifunctions representation. Prints, comma separated, the sign of the float (-1, 0, 1), the exponent of the float, and the fraction of the float. Written in [[w:Rust (programming language)|Rust]].
* [//gitlab.wikimedia.org/hogue/cobol-file-collection/-/blob/main/Wikifunctionsdumpextract/Dumpextract.cbl Dumpextract]: a program to extract info from the dump of Wikifunctions. Written in [[w:COBOL|COBOL]].
*[[User:Feeglgeef/wikilambda editsource.js|wikilambda editsource.js]]: User script that allows you to edit the raw JSON content of ZObjects.
sbf0xndlqmqd6wsp6k35kiaa2bfyksw
Wikifunctions:Status updates/2024-12-12
4
45270
147015
146948
2024-12-18T13:45:09Z
DVrandecic (WMF)
7
/* ==== Stage 2: Lexeme-based generation ==== */
147015
wikitext
text/x-wiki
<languages/>
{{Wikifunctions updates
| prevlabel = <translate><!--T:1--> Previous update</translate>
| prev = 2024-11-27
| nextlabel = <translate><!--T:2--> Next update</translate>
| next =
}}
<translate>
=== Sketching a path to Abstract Wikipedia === <!--T:3-->
<!--T:4-->
The main goal of Wikifunctions is to support Abstract Wikipedia: a source of multi-lingual Wikipedia content where we can create and maintain the content only once, but have it available across many different languages to fill some of the gaps that currently exist in some Wikipedias.
<!--T:5-->
Today, I would like to sketch out how the natural language generation for Abstract Wikipedia might develop. As an example goal, let’s take the following sentence (based on the [[:en:Waakye|English Wikipedia article about Waakye]]):
</translate>
; <translate><!--T:68--> English: "''<tvar name="1">Waakye is a Ghanaian dish of cooked rice and beans.</tvar>''"</translate>
; <translate><!--T:69--> French: "''<tvar name="1">Le waakye est un mets ghanéen de riz et de haricots cuits.</tvar>''"</translate>
; <translate><!--T:70--> German: "''<tvar name="1">Waakye ist ein ghanaisches Gericht aus gekochten Reis und Bohnen.</tvar>''"</translate>
<translate>
<!--T:7-->
We look at four stages to work towards this text.
==== Stage 1: String-based substitution ==== <!--T:8-->
<!--T:9-->
In Stage 1, we use simple string substitution, in the style of [[:en:Mad Libs|Mad Libs]]. This approach requires the user to carefully select the right strings, which is quite simple in English, but gets more complicated in French or German.
<!--T:10-->
So we could have the following function calls:
</translate>
<code><translate><!--T:71--> Instance with origin string-based English(<tvar name="1">"Waakye", "dish", "Ghanaian"</tvar>)</translate></code> <br />
: → "''Waakye is a Ghanaian dish.''"
<code><translate><!--T:72--> Instance with origin string-based French(<tvar name="1">"Le waakye", "un mets", "ghanéen"</tvar>)</translate></code> <br />
: → "''Le waakye est un mets ghanéen.''"
<code><translate><!--T:73--> Instance with origin string-based German(<tvar name="1">"Waakye", "ein Gericht", "ghanaisches"</tvar>)</translate></code> <br />
: → "''Waakye ist ein ghanaisches Gericht.''"
<translate>
<!--T:14-->
This is possible right now. It requires quite detailed grammatical knowledge by the function caller, as they need to enter the right form manually. The benefit of this method is difficult to see in this example.
==== Stage 2: Lexeme-based generation ==== <!--T:15-->
<!--T:16-->
In Stage 2, instead of using strings, we use Wikidata Lexemes, possible in the past few months. This allows for a version of the function where the function caller does not have to worry about agreement and entering the right form manually, but the function implementer needs to select the right form from the Lexeme instead. This shifts some of the burden from the function user to the function author.
<!--T:17-->
This makes the calling much simpler: we don’t have to know whether "''waakye''" in French will be "''L'''e''' waakye''" or "''L'''a''' waakye''", we don’t have to select the agreeing adjective in German ("''ghanaische'''s''' Gericht''" or "''ghanaische'''r''' Gericht''"), ''etc.'' The correct form will be chosen by the Function.
<!--T:18-->
Now we would have the following function calls:
</translate>
<code><translate><!--T:74--> Instance with origin Lexeme-based English(<tvar name="1">Lxxx/Waakye, L3964/dish, Lxxx/Ghanaian</tvar>)</translate></code> <br />
: → "''Waakye is a Ghanaian dish.''"
<code><translate><!--T:75--> Zxxx/Instance with origin Lexeme-based French(<tvar name="1">Lxxx/waakye, L24812/mets, Lxxx/ghanéen</tvar>)</translate></code> <br />
: → "''Le waakye est un mets ghanéen.''"
<code><translate><!--T:76--> Zxxx/Instance with origin Lexeme-based German(<tvar name="1">Lxxx/Waakye, L500931/Gericht, Lxxx/ghanaisch</tvar>)</translate></code> <br />
: → "''Waakye ist ein ghanaisches Gericht.''"
<translate>
<!--T:22-->
You also will find that a lot of Lexemes are missing for this particular example, such as the French Lexeme for something from Ghana. We in the Wikimedia movement need to think about how to approach this gap in what is now – and ever should be – in Wikidata's Lexemes.
<!--T:23-->
We were hoping that this would be possible right now, and we created a number of functions during our offsite to test these capabilities. Unfortunately, we learned that the system is currently failing to evaluate most such function calls, and accordingly we decided to put a big focus in the upcoming Quarter on getting these functions to run.
==== Stage 3: Item-based generation ==== <!--T:24-->
<!--T:25-->
In the third stage, we would use Wikidata items to help us select Lexemes from a given language that have comparable meanings. The function caller does not have to know or look up the right Lexeme in all the languages they want to generate the text in. They can just put in the relevant Wikidata items, and the function developer can implement the relevant lookups.
<!--T:26-->
This means that whether or not the function caller knows that the concept "''dish''" is called "''mets''" in French or "''Gericht''" in German, they will still be able to create perfectly fluid and correct sentences in those languages.
<!--T:27-->
This allows us to make the following calls (note that all three calls use ''the same function'' here, and the caller does not have to know the languages at all):
</translate>
<code><translate><!--T:77--> Instance with origin(Q14783691/Waakye, Q746549/dish, Q117/Ghana, Z1002/English)</translate></code> <br />
: → "''Waakye is a Ghanaian dish.''"
<code><translate><!--T:78--> Instance with origin(Q14783691/Waakye, Q746549/dish, Q117/Ghana, Z1004/French)</translate></code> <br />
: → "''Le waakye est un mets ghanéen.''"
<code><translate><!--T:79--> Instance with origin(Q14783691/Waakye, Q746549/dish, Q117/Ghana, Z1430/German)</translate></code> <br />
: → "''Waakye ist ein ghanaisches Gericht.''"
<translate>
<!--T:31-->
Note that the function will in most cases just route to the language-specific functions developed for the previous stage, but that happens behind the scenes and transparently for the function caller.
<!--T:32-->
This is currently not possible to implement on Wikifunctions — we still need to add a function that allows us to find the Lexemes connected to a given Item. We will work on that in the coming Quarter, and are thankful to the Search and Wikidata teams for the necessary pre-work they have recently performed to unlock the possibility.
==== Stage 4: Item-based content ==== <!--T:33-->
<!--T:34-->
The final stage we want to discuss today is based on using the knowledge in Wikidata to create text. We can pull from Wikidata that [[<tvar name="1">:d:Q14783691</tvar>|Q14783691/Waakye]] is a dish from [[<tvar name="2">:d:Q117</tvar>|Q117/Ghana]], we can look up the ingredients and their Lexemes, ''etc.'' Given the current knowledge about Waakye in Wikidata, this could then generate the following sentences:
</translate>
<code><translate><!--T:80--> Food with origin and ingredients(Q14783691/Waakye, Z1002/English)</translate></code> <br />
: → "''Waakye is a Ghanaian dish with bean, rice, water, and salt.''"
<code><translate><!--T:81--> Food with origin and ingredients(Q14783691/Waakye, Z1004/French)</translate></code> <br />
: → "''Le waakye est un plat ghanéen composé de haricots, de riz, d'eau et de sel.''"
<code><translate><!--T:82--> Food with origin and ingredients(Q14783691/Waakye, Z1430/German)</translate></code> <br />
: → "''Waakye ist ein ghanaisches Gericht aus Bohnen, Reis, Wasser und Salz.''"
<translate>
<!--T:38-->
This further simplifies writing the function calls: all we need to select is the dish and the language, and we get a whole sentence that can, in many cases, make a good opening sentence for the Wikipedia article about the given dish, or as an entry or short description in various places.
<!--T:39-->
I hope that this gives a good overview of our next few planned steps with regards to natural language generation and how Wikifunctions can support bringing together our different language communities.
=== Team offsite in Lisbon === <!--T:40-->
</translate>
[[File:Abstract Wikipedia team Lisbon 2024.jpg|thumb|440x440px|<translate><!--T:41--> Abstract Wikipedia team at the offsite in Lisbon 2024. From left to right, front row: Cory Massaro, Grace Choi, Genoveva Galarza Heredero, Daphne Smit. Back row: James Forrester, Denny Vrandečić, David Martin, Sharvani Haran. Not in picture: Amy Tsay, Amin Al Hazwani, Luca Martinelli, Elena Tonkovidova, Vaughn Walters.</translate>]]
<translate>
<!--T:42-->
Last week, the team met for its annual meeting in Lisbon, Portugal. What a beautiful city! We enjoyed walking through the city, and had very productive meetings, discussing our plans, team procedures, and using the time for bonding and social cohesion – very difficult and important to achieve in a team that is fully remote.
<!--T:43-->
The most tangible outcome is the planning for the next Quarter; we had very lively discussions to find a consensus, which we still need to write up. We will report on the plan in one of the next two updates.
=== New tool for querying Wikifunctions === <!--T:44-->
<!--T:45-->
[[<tvar name="1">User:Feeglgeef</tvar>|Feeglgeef]] created a new tool that allows you to query Wikifunctions in a very flexible way. You can search for functions with implementations in Python, Types that use numbers as keys, functions that take three arguments, or return booleans. The tool is available on Replit (note that this is ''outside'' of Wikimedia servers), and examples and documentation of the query language are linked from the front page of the tool: [<tvar name="2">https://wf-query.replit.app/</tvar> wf-query.replit.app]
<!--T:46-->
[[<tvar name="1">User:Hogü-456</tvar>|Hogü-456]] created an overview of existing tools. If you are aware of more tools, feel free to add them: <tvar name="2">{{ll|Wikifunctions:Tools}}</tvar>
=== Recent Changes in the software === <!--T:47-->
<!--T:48-->
There's no release of MediaWiki software this week due to the Release Engineering team's ordered release freeze, so nothing new to update. As always, please alert us if you run into any issues.
=== News in Types: Gregorian calendar date, Byte, Unicode code point === <!--T:49-->
<!--T:50-->
We finally have a Type for [[<tvar name="1">Z20420</tvar>|Gregorian calendar dates]]. We have been working a while towards it, having created a Type for the [[<tvar name="2">Z16098</tvar>|relevant months]], for [[<tvar name="3">Z20159</tvar>|years]], ''etc.'' The [[<tvar name="4">Wikifunctions:Type proposals/Gregorian calendar date</tvar>|discussion]] was lengthy and didn’t lead to a full consensus. A [[<tvar name="5">Wikifunctions:Type proposals/Gregorian calendar date#Decision</tvar>|rationale for the decisions]] on the design of the Type is provided. We invite you to create functions using the Type!
<!--T:51-->
This has been by far the most complex Type we are providing so far.
<!--T:52-->
We would like to create Types for other, non-Gregorian calendars, like the Chinese, Ethiopian, Japanese, Hebrew, and other calendars. If you know any of these calendars well, please reach out so that we can create the respective calendars.
<!--T:53-->
In other Type-related work, [[<tvar name="1">Wikifunctions:Type proposals/Byte</tvar>|proposals for fixing the Byte]] Type and [[<tvar name="2">Wikifunctions:Type proposals/Unicode codepoint</tvar>|the Unicode code point]] Type (previously character Type) have been made. Input is and discussions are very welcome.
=== Recordings of December’s Volunteers’ Corner === <!--T:54-->
</translate>
[[File:Abstract Wikipedia Volunteer Corner 2024-12.webm|thumb|<translate><!--T:55--> December 2024 Volunteers' Corner</translate>]]
<translate>
<!--T:56-->
We had a Volunteers’ Corner this Monday, December 9. It was lively with many good questions. A [[<tvar name="1">:commons:File:Abstract_Wikipedia_Volunteer_Corner_2024-12.webm</tvar>|recording of the Corner is available on Commons]].
<!--T:57-->
The function we built together is featured below as the Function of the Week.
=== Recording of Denny’s SWIB24 keynote === <!--T:58-->
<!--T:59-->
Denny Vrandečić gave a keynote address at the Semantic Web in Libraries 2024 conference. The topic was on the role of knowledge representations in a world of large language models. The [<tvar name="1">https://www.youtube.com/watch?v=NmCbTOZ4Yos</tvar> recording is available on YouTube].
=== Function of the Week: how many days between two days in the Roman year === <!--T:60-->
<!--T:61-->
The last newsletter introduced the [[<tvar name="1">Z20342</tvar>|days of the Roman year]] as a new Type. As of now, we have 18 new functions using the Type. Also, this week’s Volunteers’ Corner created such a function, so we will take a look at the resulting function.
<!--T:62-->
How many days are there between two days? [[<tvar name="1">Z20733</tvar>|Function Z20733]] can answer that question. The function has three arguments: the two [[<tvar name="2">Z20342</tvar>|days]], and a [[<tvar name="3">Z40</tvar>|Boolean]] which tells us whether the days are in a leap year or not. It returns a natural number stating how many days are between the two given days.
<!--T:63-->
It might be easiest to clarify what the function does by looking at the tests:
</translate>
* <translate><!--T:83--> From [[<tvar name="1">Z20735</tvar>|1 January to 15 January]], that’s 14 days</translate>
* <translate><!--T:84--> From [[<tvar name="1">Z20737</tvar>|1 January to 31 December]], that’s 364 days in a common year</translate>
* <translate><!--T:85--> From [[<tvar name="1">Z20736</tvar>|28 February to 1 March]], it’s one day in a common year</translate>
* <translate><!--T:86--> But [[<tvar name="1">Z20734</tvar>|two days]] in a leap year</translate>
<translate>
<!--T:65-->
The tests are incomplete, with the most notable omission being for any tests where the first day is after the second, and what that exactly means with regards to understanding the leap year.
<!--T:66-->
Currently, there is only one implementation for this function so far, which is partly due to the fact that we didn’t have much time left in the Volunteers’ Corner, and so we only did one in composition, because we found that the easiest way to implement the function.
<!--T:67-->
The core of the composition is to [[<tvar name="1">Z20357</tvar>|turn both days into]] a number, counting which day of the year it is (''i.e.'' 1 January is the first day, 2 January the second, 1 February the 32nd, ''etc.''), and then [[<tvar name="2">Z17315</tvar>|subtract]] the first number from the second. The result is then [[<tvar name="3">Z17144</tvar>|turned from an integer to a natural number]], in order to avoid negative numbers.
</translate>
[[Category:Status updates{{#translation:}}|2024-12-12]]
d2t3hnm79p2i9lznsxjy8yt6v8fgjty
Z20837
0
45505
147104
146612
2024-12-19T05:07:28Z
Jérémy-Günther-Heinz Jähnick
6055
Traduction en français (fr)
147104
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20837"
},
"Z2K2": {
"Z1K1": "Z20825",
"Z20825K1": "Z20837"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "no special value"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "pas de valeur spéciale"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
9jd1bz7wjrxdza6kvs2fa7b5vvxqxg6
Z20838
0
45506
147044
147010
2024-12-18T21:10:19Z
DVrandecic (WMF)
7
147044
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20838"
},
"Z2K2": {
"Z1K1": "Z4",
"Z4K1": "Z20838",
"Z4K2": [
"Z3",
{
"Z1K1": "Z3",
"Z3K1": "Z16659",
"Z3K2": "Z20838K1",
"Z3K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "sign"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "signe"
}
]
},
"Z3K4": {
"Z1K1": "Z40",
"Z40K1": "Z42"
}
},
{
"Z1K1": "Z3",
"Z3K1": "Z16683",
"Z3K2": "Z20838K2",
"Z3K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "exponent"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "exposant"
}
]
},
"Z3K4": {
"Z1K1": "Z40",
"Z40K1": "Z42"
}
},
{
"Z1K1": "Z3",
"Z3K1": "Z13518",
"Z3K2": "Z20838K3",
"Z3K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "fraction"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": " fraction"
}
]
},
"Z3K4": {
"Z1K1": "Z40",
"Z40K1": "Z42"
}
},
{
"Z1K1": "Z3",
"Z3K1": "Z20825",
"Z3K2": "Z20838K4",
"Z3K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "special value"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "valeur spéciale"
}
]
},
"Z3K4": {
"Z1K1": "Z40",
"Z40K1": "Z42"
}
}
],
"Z4K3": "Z101",
"Z4K4": "Z20850",
"Z4K7": [
"Z46",
"Z20840",
"Z20875"
],
"Z4K8": [
"Z64",
"Z20848",
"Z20885"
]
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "(do not use) float64"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "(ne pas utiliser) float64"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31",
{
"Z1K1": "Z31",
"Z31K1": "Z1002",
"Z31K2": [
"Z6",
"float",
"decimal",
"double",
"FP64",
"binary64",
"f64",
"DOUBLE-FLOAT",
"real64"
]
}
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Representation of a number in 64 bits, under IEEE 754, with a floating radix point."
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "représentation d'un nombre en 64 bits, selon la norme IEEE 754, avec une virgule flottante."
}
]
}
}
9brt6x7hn10kp8u6et15pnok4tv5bdc
147047
147044
2024-12-18T21:12:21Z
DVrandecic (WMF)
7
147047
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20838"
},
"Z2K2": {
"Z1K1": "Z4",
"Z4K1": "Z20838",
"Z4K2": [
"Z3",
{
"Z1K1": "Z3",
"Z3K1": "Z16659",
"Z3K2": "Z20838K1",
"Z3K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "sign"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "signe"
}
]
},
"Z3K4": {
"Z1K1": "Z40",
"Z40K1": "Z42"
}
},
{
"Z1K1": "Z3",
"Z3K1": "Z16683",
"Z3K2": "Z20838K2",
"Z3K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "exponent"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "exposant"
}
]
},
"Z3K4": {
"Z1K1": "Z40",
"Z40K1": "Z42"
}
},
{
"Z1K1": "Z3",
"Z3K1": "Z13518",
"Z3K2": "Z20838K3",
"Z3K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "fraction"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": " fraction"
}
]
},
"Z3K4": {
"Z1K1": "Z40",
"Z40K1": "Z42"
}
},
{
"Z1K1": "Z3",
"Z3K1": "Z20825",
"Z3K2": "Z20838K4",
"Z3K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "special value"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "valeur spéciale"
}
]
},
"Z3K4": {
"Z1K1": "Z40",
"Z40K1": "Z42"
}
}
],
"Z4K3": "Z101",
"Z4K4": "Z20850",
"Z4K7": [
"Z46",
"Z20840",
"Z20875"
],
"Z4K8": [
"Z64",
"Z20848",
"Z20885"
]
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "(testing) float64"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "(ne pas utiliser) float64"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31",
{
"Z1K1": "Z31",
"Z31K1": "Z1002",
"Z31K2": [
"Z6",
"float",
"decimal",
"double",
"FP64",
"binary64",
"f64",
"DOUBLE-FLOAT",
"real64"
]
}
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Representation of a number in 64 bits, under IEEE 754, with a floating radix point."
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "représentation d'un nombre en 64 bits, selon la norme IEEE 754, avec une virgule flottante."
}
]
}
}
13wyatz4h9d2nwqa969nc3t5ffb41ew
147113
147047
2024-12-19T05:14:08Z
Feeglgeef
8776
significand is much less ambiguous and also what enwiki uses
147113
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20838"
},
"Z2K2": {
"Z1K1": "Z4",
"Z4K1": "Z20838",
"Z4K2": [
"Z3",
{
"Z1K1": "Z3",
"Z3K1": "Z16659",
"Z3K2": "Z20838K1",
"Z3K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "sign"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "signe"
}
]
},
"Z3K4": {
"Z1K1": "Z40",
"Z40K1": "Z42"
}
},
{
"Z1K1": "Z3",
"Z3K1": "Z16683",
"Z3K2": "Z20838K2",
"Z3K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "exponent"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "exposant"
}
]
},
"Z3K4": {
"Z1K1": "Z40",
"Z40K1": "Z42"
}
},
{
"Z1K1": "Z3",
"Z3K1": "Z13518",
"Z3K2": "Z20838K3",
"Z3K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "significand"
}
]
},
"Z3K4": {
"Z1K1": "Z40",
"Z40K1": "Z42"
}
},
{
"Z1K1": "Z3",
"Z3K1": "Z20825",
"Z3K2": "Z20838K4",
"Z3K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "special value"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "valeur spéciale"
}
]
},
"Z3K4": {
"Z1K1": "Z40",
"Z40K1": "Z42"
}
}
],
"Z4K3": "Z101",
"Z4K4": "Z20850",
"Z4K7": [
"Z46",
"Z20840",
"Z20875"
],
"Z4K8": [
"Z64",
"Z20848",
"Z20885"
]
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "(testing) float64"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "(ne pas utiliser) float64"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31",
{
"Z1K1": "Z31",
"Z31K1": "Z1002",
"Z31K2": [
"Z6",
"float",
"decimal",
"double",
"FP64",
"binary64",
"f64",
"DOUBLE-FLOAT",
"real64"
]
}
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Representation of a number in 64 bits, under IEEE 754, with a floating radix point."
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "représentation d'un nombre en 64 bits, selon la norme IEEE 754, avec une virgule flottante."
}
]
}
}
dpsbkl1l0xjmbqmogjus0uxkpdbbrtx
Z20840
0
45508
147049
146645
2024-12-18T21:18:17Z
Feeglgeef
8776
147049
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20840"
},
"Z2K2": {
"Z1K1": "Z46",
"Z46K1": "Z20840",
"Z46K2": "Z20838",
"Z46K3": {
"Z1K1": "Z16",
"Z16K1": "Z600",
"Z16K2": "function Z20840( Z20840K1 ) {\n\t// is it a special value?\n\tlet special = Z20840K1.Z20838K4.Z20825K1;\n\tif (typeof special === 'object') {\n\t\tspecial = special.Z9K1;\n\t}\n\tif ( special === 'Z20829' ) {\n\t\treturn +0.0;\n\t}\n\tif ( special === 'Z20831' ) {\n\t\treturn -0.0;\n\t}\n\tif ( special === 'Z20832' ) {\n\t\treturn Number.POSITIVE_INFINITY;\n\t}\n\tif ( special === 'Z20833' ) {\n\t\treturn Number.NEGATIVE_INFINITY;\n\t}\n\tif ( ( special === 'Z20834' )\n\t || ( special === 'Z20835' )\n\t || ( special === 'Z20836' ) ) {\n\t\treturn Number.NaN;\n\t}\n\t\n\t// is it a positive number?\n\tlet sign = Z20840K1.Z20838K1.Z16659K1;\n\tif (typeof sign === 'object') {\n\t\tsign = sign.Z9K1;\n\t}\n\tconst positive = ( sign === 'Z16660' ) ? 0n : 1n;\n\tconst signBit = positive \u003C\u003C 63n;\n\t\n\t// exponent\n\tlet expvalue = Z20840K1.Z20838K2.Z16683K2.Z13518K1;\n\tif (typeof expvalue === 'string') {\n\t\texpvalue = BigInt( Z20840K1.Z20838K2.Z16683K2.Z13518K1 );\n\t} else {\n\t\texpvalue = BigInt( Z20840K1.Z20838K2.Z16683K2.Z13518K1.Z6K1 );\n\t}\n\tlet expsign = Z20840K1.Z20838K2.Z16683K1.Z16659K1;\n\t\n\twhile ( typeof expsign === 'object' ) {\n\t\tif ( 'Z9K1' in expsign ) {\n\t\t\texpsign = expsign.Z9K1;\n\t\t} else if ( 'Z16659K1' in expsign ) {\n\t\t\texpsign = expsign.Z16659K1;\n\t\t} else {\n\t\t\texpsign = '';\n\t\t}\n\t}\n\tif ( expsign === 'Z16662' ) { \n\t\texpsign = -1n;\n\t} else {\n\t\texpsign = 1n;\n\t}\n\tconst exponent = expsign * expvalue;\n\tif ( ( exponent \u003E 1023n ) || ( exponent \u003C -1022n ) ) {\n\t\treturn Number.NaN;\n\t}\n const exponentBits = ((exponent + 1023n) \u0026 0x7FFn) \u003C\u003C 52n;\n\n\t// mantissa\n\tlet mantvalue = Z20840K1.Z20838K3.Z13518K1;\n\tif (typeof mantvalue === 'string') {\n\t\tmantvalue = BigInt( mantvalue );\n\t} else {\n\t\tmantvalue = BigInt( mantvalue.Z6K1 );\n\t}\n\tconst mantisse = mantvalue;\n\tconst MANTISSA_MASK = (1n \u003C\u003C 52n) - 1n;\n const mantissaBits = mantisse \u0026 MANTISSA_MASK;\n \n const floatBits = signBit | exponentBits | mantissaBits;\n\n // Convert to a JavaScript Number\n const buffer = new ArrayBuffer(8);\n const view = new DataView(buffer);\n view.setBigUint64(0, floatBits, false); // Big-endian\n return view.getFloat64(0, false);\t\n}\n"
},
"Z46K4": "number"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "JavaScript converter to float64"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
mklxv87izcwvukb0ogs5imf9ra5zbz9
Z20849
0
45517
147046
146851
2024-12-18T21:11:32Z
DVrandecic (WMF)
7
Added Z20886 to the approved list of implementations
147046
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20849"
},
"Z2K2": {
"Z1K1": "Z8",
"Z8K1": [
"Z17",
{
"Z1K1": "Z17",
"Z17K1": "Z20838",
"Z17K2": "Z20849K1",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "left"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "gauche"
}
]
}
},
{
"Z1K1": "Z17",
"Z17K1": "Z20838",
"Z17K2": "Z20849K2",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "right"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "droite"
}
]
}
}
],
"Z8K2": "Z20838",
"Z8K3": [
"Z20",
"Z20852",
"Z20861"
],
"Z8K4": [
"Z14",
"Z20853",
"Z20886"
],
"Z8K5": "Z20849"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "add floats"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "ajouter des nombres en virgules flottantes"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31",
{
"Z1K1": "Z31",
"Z31K1": "Z1002",
"Z31K2": [
"Z6",
"+",
"add",
"plus",
"sum"
]
}
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
e1cc9pc5jrd7ql3yc2ugi97b9h0y32u
Z20850
0
45518
147048
146859
2024-12-18T21:17:19Z
Feeglgeef
8776
consistency
147048
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20850"
},
"Z2K2": {
"Z1K1": "Z8",
"Z8K1": [
"Z17",
{
"Z1K1": "Z17",
"Z17K1": "Z20838",
"Z17K2": "Z20850K1",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "this"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "premier nombre"
}
]
}
},
{
"Z1K1": "Z17",
"Z17K1": "Z20838",
"Z17K2": "Z20850K2",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "that"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "second nombre"
}
]
}
}
],
"Z8K2": "Z40",
"Z8K3": [
"Z20"
],
"Z8K4": [
"Z14",
"Z20851"
],
"Z8K5": "Z20850"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "same float64"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "est-ce le même nombre en virgule flottante ?"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31",
{
"Z1K1": "Z31",
"Z31K1": "Z1002",
"Z31K2": [
"Z6",
"equal",
"=",
"==",
"===",
"equality",
"float equality",
"float64 equality",
"same float"
]
}
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
dsrsho87mropp7lss6axdig80g62txb
Z20854
0
45522
147053
146672
2024-12-18T21:29:48Z
Feeglgeef
8776
Removed Z20855 from the approved list of implementations
147053
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20854"
},
"Z2K2": {
"Z1K1": "Z8",
"Z8K1": [
"Z17",
{
"Z1K1": "Z17",
"Z17K1": "Z19677",
"Z17K2": "Z20854K1",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "rational"
}
]
}
}
],
"Z8K2": "Z20838",
"Z8K3": [
"Z20"
],
"Z8K4": [
"Z14"
],
"Z8K5": "Z20854"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Rational number as float"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Takes a rational number and converts it to a float."
}
]
}
}
ixyha7rws5w64uyi92pzj8vsrtsn4eq
147056
147053
2024-12-18T21:31:21Z
Feeglgeef
8776
Added Z20887 to the approved list of implementations
147056
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20854"
},
"Z2K2": {
"Z1K1": "Z8",
"Z8K1": [
"Z17",
{
"Z1K1": "Z17",
"Z17K1": "Z19677",
"Z17K2": "Z20854K1",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "rational"
}
]
}
}
],
"Z8K2": "Z20838",
"Z8K3": [
"Z20"
],
"Z8K4": [
"Z14",
"Z20887"
],
"Z8K5": "Z20854"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Rational number as float"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Takes a rational number and converts it to a float."
}
]
}
}
56r2dl72856b1vulckgenuvfk8rtcoz
147058
147056
2024-12-18T21:33:26Z
Feeglgeef
8776
Added Z20888 to the approved list of test cases
147058
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20854"
},
"Z2K2": {
"Z1K1": "Z8",
"Z8K1": [
"Z17",
{
"Z1K1": "Z17",
"Z17K1": "Z19677",
"Z17K2": "Z20854K1",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "rational"
}
]
}
}
],
"Z8K2": "Z20838",
"Z8K3": [
"Z20",
"Z20888"
],
"Z8K4": [
"Z14",
"Z20887"
],
"Z8K5": "Z20854"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Rational number as float"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Takes a rational number and converts it to a float."
}
]
}
}
aeft56po73zgao2z9a19rc68j7g0tdy
147060
147058
2024-12-18T21:36:31Z
Feeglgeef
8776
Added Z20889 to the approved list of test cases
147060
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20854"
},
"Z2K2": {
"Z1K1": "Z8",
"Z8K1": [
"Z17",
{
"Z1K1": "Z17",
"Z17K1": "Z19677",
"Z17K2": "Z20854K1",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "rational"
}
]
}
}
],
"Z8K2": "Z20838",
"Z8K3": [
"Z20",
"Z20888",
"Z20889"
],
"Z8K4": [
"Z14",
"Z20887"
],
"Z8K5": "Z20854"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Rational number as float"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Takes a rational number and converts it to a float."
}
]
}
}
20t3n4htap9eh3s3esn4x44c1p3b453
Z20855
0
45523
147051
146689
2024-12-18T21:20:59Z
Feeglgeef
8776
147051
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20855"
},
"Z2K2": {
"Z1K1": "Z14",
"Z14K1": "Z20854",
"Z14K3": {
"Z1K1": "Z16",
"Z16K1": "Z600",
"Z16K2": "function Z20854( Z20854K1 ) {\n\tWikifunctions.Debug(Z20854K1.K1.toString());\n\tWikifunctions.Debug(Z20854K1.K2.toString());\n\treturn Number(Z20854K1.K1 / Z20854K1.K2);\n}"
}
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
jio95ceu5acjnx5pn88fl9q62fzrzwx
147052
147051
2024-12-18T21:28:14Z
Feeglgeef
8776
147052
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20855"
},
"Z2K2": {
"Z1K1": "Z14",
"Z14K1": "Z20854",
"Z14K3": {
"Z1K1": "Z16",
"Z16K1": "Z600",
"Z16K2": "function Z20854( Z20854K1 ) {\n\t//Wikifunctions.Debug(Z20854K1.K1.toString());\n\t//Wikifunctions.Debug(Z20854K1.K2.toString());\n\treturn Number(Z20854K1.K1 / Z20854K1.K2);\n}"
}
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
5s801vqepfwqzgl00cw8her7c2ibqsc
Z20862
0
45590
147074
146962
2024-12-18T22:07:34Z
Feeglgeef
8776
147074
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20862"
},
"Z2K2": {
"Z1K1": "Z20838",
"Z20838K1": "Z16660",
"Z20838K2": {
"Z1K1": "Z16683",
"Z16683K1": {
"Z1K1": "Z16659",
"Z16659K1": "Z16660"
},
"Z16683K2": {
"Z1K1": "Z13518",
"Z13518K1": "1"
}
},
"Z20838K3": {
"Z1K1": "Z13518",
"Z13518K1": "2570638124657944"
},
"Z20838K4": "Z20837"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "pi"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "The value of pi as stored in float64s"
}
]
}
}
pwcjdpxfnddugcf7ncncssak41eufsu
147097
147074
2024-12-19T04:27:08Z
Feeglgeef
8776
147097
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20862"
},
"Z2K2": {
"Z1K1": "Z20838",
"Z20838K1": "Z16660",
"Z20838K2": {
"Z1K1": "Z16683",
"Z16683K1": {
"Z1K1": "Z16659",
"Z16659K1": "Z16661"
},
"Z16683K2": {
"Z1K1": "Z13518",
"Z13518K1": "0"
}
},
"Z20838K3": {
"Z1K1": "Z13518",
"Z13518K1": "2251799813685248"
},
"Z20838K4": "Z20837"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "pi"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "The value of pi as stored in float64s"
}
]
}
}
dvyiosa8dgz5nxo9fr4kzhwl3hwtyda
147098
147097
2024-12-19T04:30:15Z
Feeglgeef
8776
147098
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20862"
},
"Z2K2": {
"Z1K1": "Z20838",
"Z20838K1": "Z16660",
"Z20838K2": {
"Z1K1": "Z16683",
"Z16683K1": {
"Z1K1": "Z16659",
"Z16659K1": "Z16660"
},
"Z16683K2": {
"Z1K1": "Z13518",
"Z13518K1": "1"
}
},
"Z20838K3": {
"Z1K1": "Z13518",
"Z13518K1": "2570638124657944"
},
"Z20838K4": "Z20837"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "pi"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "The value of pi as stored in float64s"
}
]
}
}
pwcjdpxfnddugcf7ncncssak41eufsu
Z20875
0
45606
147050
147012
2024-12-18T21:19:03Z
Feeglgeef
8776
147050
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20875"
},
"Z2K2": {
"Z1K1": "Z46",
"Z46K1": "Z20875",
"Z46K2": "Z20838",
"Z46K3": {
"Z1K1": "Z16",
"Z16K1": "Z610",
"Z16K2": "def Z20875(Z20875K1):\n\t# is it a special value?\n\tspecial = Z20875K1['Z20838K4']['Z20825K1'];\n\tif not isinstance(special, str):\n\t\tspecial = special['Z9K1'];\n\tif special == 'Z20829':\n\t\treturn +0.0\n\tif special == 'Z20831':\n\t\treturn -0.0\n\tif special == 'Z20832':\n\t\treturn float('inf')\n\tif special == 'Z20833':\n\t\treturn -float('inf')\n\tif special in ['Z20834', 'Z20835', 'Z20836']:\n\t\treturn float('nan')\n\n\t# is it a positive number?\n\tsign = Z20875K1['Z20838K1']['Z16659K1']\n\tif not isinstance(sign, str):\n\t\tsign = sign['Z9K1']\n\tpositive = sign == 'Z16660'\n\t\n\t# exponent\n\texpsign = Z20875K1['Z20838K2']['Z16683K1']\n\twhile type(expsign) != str:\n\t\tthe_ref = expsign.get('Z9K1')\n\t\tif the_ref is not None:\n\t\t\texpsign = the_ref\n\t\telse:\n\t\t\tthe_identity = expsign.get('Z16659K1')\n\t\t\tif the_identity is not None:\n\t\t\t\texpsign = the_identity\n\texpsign = {\n\t\t'Z16660': 1,\n\t\t'Z16661': 0,\n\t\t'Z16662': -1\n\t}.get(expsign)\n\texp_absolute_value = int(\n\t\tZ20875K1['Z20838K2']['Z16683K2']['Z13518K1']['Z6K1']\n\t)\n\texp = expsign * exp_absolute_value\n\t\n\t# mantissa\n\tmantissa = int(\n\t\tZ20875K1['Z20838K3']['Z13518K1']['Z6K1']\n\t)\n\tmantissa = 1 + mantissa/2**52\n\t\n\timport math\n\treturn math.ldexp(mantissa/2.0, exp+1) * (1 if positive else -1)"
},
"Z46K4": "float"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Python converter to float64"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
gu4e7vdk6a86cp95hm2x6ez2zhltsz4
Z20877
0
45608
147016
2024-12-18T13:50:32Z
Feeglgeef
8776
147016
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20877"
},
"Z2K2": {
"Z1K1": "Z8",
"Z8K1": [
"Z17",
{
"Z1K1": "Z17",
"Z17K1": "Z19677",
"Z17K2": "Z20877K1",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "length"
}
]
}
},
{
"Z1K1": "Z17",
"Z17K1": "Z19677",
"Z17K2": "Z20877K2",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "width"
}
]
}
}
],
"Z8K2": "Z19677",
"Z8K3": [
"Z20"
],
"Z8K4": [
"Z14"
],
"Z8K5": "Z20877"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "area of a rectange"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "the area of a rectangle with given length and width"
}
]
}
}
724ckcy4q4efm0tqwysl72mbcbmt2d7
147018
147016
2024-12-18T13:52:09Z
Feeglgeef
8776
Added Z20878 to the approved list of implementations
147018
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20877"
},
"Z2K2": {
"Z1K1": "Z8",
"Z8K1": [
"Z17",
{
"Z1K1": "Z17",
"Z17K1": "Z19677",
"Z17K2": "Z20877K1",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "length"
}
]
}
},
{
"Z1K1": "Z17",
"Z17K1": "Z19677",
"Z17K2": "Z20877K2",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "width"
}
]
}
}
],
"Z8K2": "Z19677",
"Z8K3": [
"Z20"
],
"Z8K4": [
"Z14",
"Z20878"
],
"Z8K5": "Z20877"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "area of a rectange"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "the area of a rectangle with given length and width"
}
]
}
}
r0p24dhitc41cj1xrhv7wxygr9jrbme
147021
147018
2024-12-18T13:55:49Z
Feeglgeef
8776
Added Z20879 to the approved list of test cases
147021
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20877"
},
"Z2K2": {
"Z1K1": "Z8",
"Z8K1": [
"Z17",
{
"Z1K1": "Z17",
"Z17K1": "Z19677",
"Z17K2": "Z20877K1",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "length"
}
]
}
},
{
"Z1K1": "Z17",
"Z17K1": "Z19677",
"Z17K2": "Z20877K2",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "width"
}
]
}
}
],
"Z8K2": "Z19677",
"Z8K3": [
"Z20",
"Z20879"
],
"Z8K4": [
"Z14",
"Z20878"
],
"Z8K5": "Z20877"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "area of a rectange"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "the area of a rectangle with given length and width"
}
]
}
}
h9tn9hfbtona0o8ye5025uh4t48p4ca
147023
147021
2024-12-18T13:58:46Z
Feeglgeef
8776
Added Z20880 to the approved list of test cases
147023
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20877"
},
"Z2K2": {
"Z1K1": "Z8",
"Z8K1": [
"Z17",
{
"Z1K1": "Z17",
"Z17K1": "Z19677",
"Z17K2": "Z20877K1",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "length"
}
]
}
},
{
"Z1K1": "Z17",
"Z17K1": "Z19677",
"Z17K2": "Z20877K2",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "width"
}
]
}
}
],
"Z8K2": "Z19677",
"Z8K3": [
"Z20",
"Z20879",
"Z20880"
],
"Z8K4": [
"Z14",
"Z20878"
],
"Z8K5": "Z20877"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "area of a rectange"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "the area of a rectangle with given length and width"
}
]
}
}
dy7r4bobd09n7yfi2cb06l6nyp3sokx
147025
147023
2024-12-18T13:59:45Z
Feeglgeef
8776
Added Z20881 to the approved list of test cases
147025
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20877"
},
"Z2K2": {
"Z1K1": "Z8",
"Z8K1": [
"Z17",
{
"Z1K1": "Z17",
"Z17K1": "Z19677",
"Z17K2": "Z20877K1",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "length"
}
]
}
},
{
"Z1K1": "Z17",
"Z17K1": "Z19677",
"Z17K2": "Z20877K2",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "width"
}
]
}
}
],
"Z8K2": "Z19677",
"Z8K3": [
"Z20",
"Z20879",
"Z20880",
"Z20881"
],
"Z8K4": [
"Z14",
"Z20878"
],
"Z8K5": "Z20877"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "area of a rectange"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "the area of a rectangle with given length and width"
}
]
}
}
q8r2xta0l8hj4zjzb32nkcx3umij21l
147027
147025
2024-12-18T14:01:12Z
Feeglgeef
8776
Added Z20882 to the approved list of test cases
147027
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20877"
},
"Z2K2": {
"Z1K1": "Z8",
"Z8K1": [
"Z17",
{
"Z1K1": "Z17",
"Z17K1": "Z19677",
"Z17K2": "Z20877K1",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "length"
}
]
}
},
{
"Z1K1": "Z17",
"Z17K1": "Z19677",
"Z17K2": "Z20877K2",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "width"
}
]
}
}
],
"Z8K2": "Z19677",
"Z8K3": [
"Z20",
"Z20879",
"Z20880",
"Z20881",
"Z20882"
],
"Z8K4": [
"Z14",
"Z20878"
],
"Z8K5": "Z20877"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "area of a rectange"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "the area of a rectangle with given length and width"
}
]
}
}
t2cdnfhgvg6mcs5u2uzlbuce067w46o
147039
147027
2024-12-18T17:25:41Z
Jérémy-Günther-Heinz Jähnick
6055
Traduction en français (fr)
147039
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20877"
},
"Z2K2": {
"Z1K1": "Z8",
"Z8K1": [
"Z17",
{
"Z1K1": "Z17",
"Z17K1": "Z19677",
"Z17K2": "Z20877K1",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "length"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "longueur"
}
]
}
},
{
"Z1K1": "Z17",
"Z17K1": "Z19677",
"Z17K2": "Z20877K2",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "width"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "largeur"
}
]
}
}
],
"Z8K2": "Z19677",
"Z8K3": [
"Z20",
"Z20879",
"Z20880",
"Z20881",
"Z20882"
],
"Z8K4": [
"Z14",
"Z20878"
],
"Z8K5": "Z20877"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "area of a rectange"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "aire d'un rectangle"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "the area of a rectangle with given length and width"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "renvoie l'aire d'un rectangle lorsque la longueur et la largeur sont données"
}
]
}
}
ely31sm4wmt0eifuz59e5tlzkr1cjkh
147041
147039
2024-12-18T17:30:07Z
Feeglgeef
8776
fix name
147041
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20877"
},
"Z2K2": {
"Z1K1": "Z8",
"Z8K1": [
"Z17",
{
"Z1K1": "Z17",
"Z17K1": "Z19677",
"Z17K2": "Z20877K1",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "length"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "longueur"
}
]
}
},
{
"Z1K1": "Z17",
"Z17K1": "Z19677",
"Z17K2": "Z20877K2",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "width"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "largeur"
}
]
}
}
],
"Z8K2": "Z19677",
"Z8K3": [
"Z20",
"Z20879",
"Z20880",
"Z20881",
"Z20882"
],
"Z8K4": [
"Z14",
"Z20878"
],
"Z8K5": "Z20877"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "area of a rectangle"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "aire d'un rectangle"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "the area of a rectangle with given length and width"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "renvoie l'aire d'un rectangle lorsque la longueur et la largeur sont données"
}
]
}
}
ejwvzxonguwmbsqk5ncf1kj23ly1ogl
Z20878
0
45609
147017
2024-12-18T13:51:37Z
Feeglgeef
8776
147017
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20878"
},
"Z2K2": {
"Z1K1": "Z14",
"Z14K1": "Z20877",
"Z14K2": {
"Z1K1": "Z7",
"Z7K1": "Z13539",
"Z13539K1": {
"Z1K1": "Z18",
"Z18K1": "Z20877K1"
},
"Z13539K2": {
"Z1K1": "Z18",
"Z18K1": "Z20877K2"
}
}
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Multiply length and width"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
oelm6pzx16kz2236z4tix1lgqw6znnz
147020
147017
2024-12-18T13:55:36Z
Feeglgeef
8776
147020
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20878"
},
"Z2K2": {
"Z1K1": "Z14",
"Z14K1": "Z20877",
"Z14K2": {
"Z1K1": "Z7",
"Z7K1": "Z19706",
"Z19706K1": {
"Z1K1": "Z18",
"Z18K1": "Z20877K1"
},
"Z19706K2": {
"Z1K1": "Z18",
"Z18K1": "Z20877K2"
}
}
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Multiply length and width"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
ditgfvf1eq1drc4wvfqu67un3rtr7x5
147040
147020
2024-12-18T17:26:22Z
Jérémy-Günther-Heinz Jähnick
6055
Traduction en français (fr)
147040
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20878"
},
"Z2K2": {
"Z1K1": "Z14",
"Z14K1": "Z20877",
"Z14K2": {
"Z1K1": "Z7",
"Z7K1": "Z19706",
"Z19706K1": {
"Z1K1": "Z18",
"Z18K1": "Z20877K1"
},
"Z19706K2": {
"Z1K1": "Z18",
"Z18K1": "Z20877K2"
}
}
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Multiply length and width"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "multiplier la longueur par la largeur, Composition"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
g5oqnzytan64zaw4i6whzltmjttk8tt
Z20879
0
45610
147019
2024-12-18T13:54:30Z
Feeglgeef
8776
147019
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20879"
},
"Z2K2": {
"Z1K1": "Z20",
"Z20K1": "Z20877",
"Z20K2": {
"Z1K1": "Z7",
"Z7K1": "Z20877",
"Z20877K1": {
"Z1K1": "Z19677",
"Z19677K1": "Z16660",
"Z19677K2": {
"Z1K1": "Z13518",
"Z13518K1": "1"
},
"Z19677K3": {
"Z1K1": "Z13518",
"Z13518K1": "1"
}
},
"Z20877K2": {
"Z1K1": "Z19677",
"Z19677K1": "Z16660",
"Z19677K2": {
"Z1K1": "Z13518",
"Z13518K1": "1"
},
"Z19677K3": {
"Z1K1": "Z13518",
"Z13518K1": "1"
}
}
},
"Z20K3": {
"Z1K1": "Z7",
"Z7K1": "Z19686",
"Z19686K2": {
"Z1K1": "Z19677",
"Z19677K1": "Z16660",
"Z19677K2": {
"Z1K1": "Z13518",
"Z13518K1": "1"
},
"Z19677K3": {
"Z1K1": "Z13518",
"Z13518K1": "1"
}
}
}
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "1, 1 is 1"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
n52yhz9y4d0imfw1n7a6eyyhayccm5d
Z20880
0
45611
147022
2024-12-18T13:58:34Z
Feeglgeef
8776
147022
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20880"
},
"Z2K2": {
"Z1K1": "Z20",
"Z20K1": "Z20877",
"Z20K2": {
"Z1K1": "Z7",
"Z7K1": "Z20877",
"Z20877K1": {
"Z1K1": "Z19677",
"Z19677K1": "Z16660",
"Z19677K2": {
"Z1K1": "Z13518",
"Z13518K1": "1"
},
"Z19677K3": {
"Z1K1": "Z13518",
"Z13518K1": "1"
}
},
"Z20877K2": {
"Z1K1": "Z19677",
"Z19677K1": "Z16660",
"Z19677K2": {
"Z1K1": "Z13518",
"Z13518K1": "1"
},
"Z19677K3": {
"Z1K1": "Z13518",
"Z13518K1": "2"
}
}
},
"Z20K3": {
"Z1K1": "Z7",
"Z7K1": "Z19686",
"Z19686K2": {
"Z1K1": "Z19677",
"Z19677K1": "Z16660",
"Z19677K2": {
"Z1K1": "Z13518",
"Z13518K1": "1"
},
"Z19677K3": {
"Z1K1": "Z13518",
"Z13518K1": "2"
}
}
}
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "1, 0.5 is 0.5"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
7n80tpldox64efgwt79rgxw64asjhxj
Z20881
0
45612
147024
2024-12-18T13:59:32Z
Feeglgeef
8776
147024
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20881"
},
"Z2K2": {
"Z1K1": "Z20",
"Z20K1": "Z20877",
"Z20K2": {
"Z1K1": "Z7",
"Z7K1": "Z20877",
"Z20877K1": {
"Z1K1": "Z19677",
"Z19677K1": "Z16660",
"Z19677K2": {
"Z1K1": "Z13518",
"Z13518K1": "2"
},
"Z19677K3": {
"Z1K1": "Z13518",
"Z13518K1": "1"
}
},
"Z20877K2": {
"Z1K1": "Z19677",
"Z19677K1": "Z16660",
"Z19677K2": {
"Z1K1": "Z13518",
"Z13518K1": "1"
},
"Z19677K3": {
"Z1K1": "Z13518",
"Z13518K1": "2"
}
}
},
"Z20K3": {
"Z1K1": "Z7",
"Z7K1": "Z19686",
"Z19686K2": {
"Z1K1": "Z19677",
"Z19677K1": "Z16660",
"Z19677K2": {
"Z1K1": "Z13518",
"Z13518K1": "1"
},
"Z19677K3": {
"Z1K1": "Z13518",
"Z13518K1": "1"
}
}
}
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "2, 0.5 is 1"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
md5p94ogc98lxkaq64iaec07ma8khmd
Z20882
0
45613
147026
2024-12-18T14:00:56Z
Feeglgeef
8776
147026
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20882"
},
"Z2K2": {
"Z1K1": "Z20",
"Z20K1": "Z20877",
"Z20K2": {
"Z1K1": "Z7",
"Z7K1": "Z20877",
"Z20877K1": {
"Z1K1": "Z19677",
"Z19677K1": "Z16661",
"Z19677K2": {
"Z1K1": "Z13518",
"Z13518K1": "0"
},
"Z19677K3": {
"Z1K1": "Z13518",
"Z13518K1": "1"
}
},
"Z20877K2": {
"Z1K1": "Z19677",
"Z19677K1": "Z16661",
"Z19677K2": {
"Z1K1": "Z13518",
"Z13518K1": "0"
},
"Z19677K3": {
"Z1K1": "Z13518",
"Z13518K1": "1"
}
}
},
"Z20K3": {
"Z1K1": "Z7",
"Z7K1": "Z19686",
"Z19686K2": {
"Z1K1": "Z19677",
"Z19677K1": "Z16662",
"Z19677K2": {
"Z1K1": "Z13518",
"Z13518K1": "0"
},
"Z19677K3": {
"Z1K1": "Z13518",
"Z13518K1": "1"
}
}
}
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "0, 0 is 0"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
e92lff15opqbzvld68msv5wsvp4t12e
Talk:Z20877
1
45614
147028
2024-12-18T14:01:39Z
Feeglgeef
8776
Created page with "tegory:Mensuration functions]]a"
147028
wikitext
text/x-wiki
tegory:Mensuration functions]]a
jdn4q9e0osub40b95g9dtfmw12t7ms1
147029
147028
2024-12-18T14:01:53Z
Feeglgeef
8776
147029
wikitext
text/x-wiki
[[Category:Mensuration functions]]
hvpkwbbsj8lyt18iwwouela179biqm7
Z20883
0
45615
147033
2024-12-18T16:15:33Z
Feeglgeef
8776
147033
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20883"
},
"Z2K2": {
"Z1K1": "Z14",
"Z14K1": "Z12941",
"Z14K2": {
"Z1K1": "Z7",
"Z7K1": "Z820",
"Z820K1": "executorDebugLogs",
"Z820K2": {
"Z1K1": "Z18",
"Z18K1": "Z12941K1"
}
}
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
0x5hl7zeeo22ipwy5fp2rjod8ckmym4
Z20884
0
45616
147042
2024-12-18T19:44:26Z
Shweeze503
9337
Defined a new function
147042
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20884"
},
"Z2K2": {
"Z1K1": "Z8",
"Z8K1": [
"Z17",
{
"Z1K1": "Z17",
"Z17K1": "Z16683",
"Z17K2": "Z20884K1",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Number"
}
]
}
},
{
"Z1K1": "Z17",
"Z17K1": "Z16683",
"Z17K2": "Z20884K2",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Number"
}
]
}
}
],
"Z8K2": "Z16683",
"Z8K3": [
"Z20"
],
"Z8K4": [
"Z14"
],
"Z8K5": "Z20884"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Addition"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31",
{
"Z1K1": "Z31",
"Z31K1": "Z1002",
"Z31K2": [
"Z6",
"Sum",
"FindSum",
"GetSum"
]
}
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "A function to add numbers"
}
]
}
}
4rw3gpjfqaslqeosv66spu3bjqhbwk3
Z20885
0
45617
147043
2024-12-18T21:09:54Z
DVrandecic (WMF)
7
147043
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20885"
},
"Z2K2": {
"Z1K1": "Z64",
"Z64K1": "Z20885",
"Z64K2": "Z20838",
"Z64K3": {
"Z1K1": "Z16",
"Z16K1": "Z610",
"Z16K2": "def Z20885(Z20885K1):\n\tdef package(positive, exp, mantissa, special):\n\t\treturn {\n\t\t\t\"Z1K1\": {\n\t\t\t\t\"Z1K1\": \"Z9\",\n\t\t\t\t\"Z9K1\": \"Z20838\"\n\t\t\t},\n\t\t\t\"Z20838K1\": {\n\t\t\t\t\"Z1K1\": {\n\t\t\t\t\t\"Z1K1\": \"Z9\",\n\t\t\t\t\t\"Z9K1\": \"Z16659\"\n\t\t\t\t},\n\t\t\t\t\"Z16659K1\": {\n\t\t\t\t\t\"Z1K1\": \"Z9\",\n\t\t\t\t\t\"Z9K1\": \"Z16660\" if positive else \"Z16662\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"Z20838K2\": {\n\t\t\t\t\"Z1K1\": {\n\t\t\t\t\t\"Z1K1\": \"Z9\",\n\t\t\t\t\t\"Z9K1\": \"Z16683\"\n\t\t\t\t},\n\t\t\t\t\"Z16683K1\": {\n\t\t\t\t\t\"Z1K1\": {\n\t\t\t\t\t\t\"Z1K1\": \"Z9\",\n\t\t\t\t\t\t\"Z9K1\": \"Z16659\"\n\t\t\t\t\t},\n\t\t\t\t\t\"Z16659K1\": {\n\t\t\t\t\t\t\"Z1K1\": \"Z9\",\n\t\t\t\t\t\t\"Z9K1\": \"Z16662\" if exp \u003C 0 else \"Z16661\" if exp == 0 else \"Z16660\"\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t\"Z16683K2\": {\n\t\t\t\t\t\"Z1K1\": {\n\t\t\t\t\t\t\"Z1K1\": \"Z9\",\n\t\t\t\t\t\t\"Z9K1\": \"Z13518\"\n\t\t\t\t\t},\n\t\t\t\t\t\"Z13518K1\": {\n\t\t\t\t\t\t\"Z1K1\": \"Z6\",\n\t\t\t\t\t\t\"Z6K1\": str( exp )\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"Z20838K3\": {\n\t\t\t\t\"Z1K1\": {\n\t\t\t\t\t\"Z1K1\": \"Z9\",\n\t\t\t\t\t\"Z9K1\": \"Z13518\"\n\t\t\t\t},\n\t\t\t\t\"Z13518K1\": {\n\t\t\t\t\t\"Z1K1\": \"Z6\",\n\t\t\t\t\t\"Z6K1\": str( mantissa )\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"Z20838K4\": {\n\t\t\t\t\"Z1K1\": {\n\t\t\t\t\t\"Z1K1\": \"Z9\",\n\t\t\t\t\t\"Z9K1\": \"Z20825\"\n\t\t\t\t},\n\t\t\t\t\"Z20825K1\": {\n\t\t\t\t\t\"Z1K1\": \"Z9\",\n\t\t\t\t\t\"Z9K1\": special\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\timport math\n\t# special values\n\tif math.isnan( Z20885K1 ):\n\t\treturn package( True, 0, 0, \"Z20834\" )\n\tif math.isinf( Z20885K1 ):\n\t\tif Z20885K1 \u003E 0:\n\t\t\treturn package( True, 0, 0, \"Z20832\" )\n\t\telse:\n\t\t\treturn package( False, 0, 0, \"Z20833\" )\n\tif Z20885K1 == 0:\n\t\tif math.copysign(Z20885K1, 1) \u003C 0:\n\t\t\treturn package( False, 0, 0, \"Z20831\" )\n\t\telse:\n\t\t\treturn package( True, 0, 0, \"Z20829\" )\n\t\t\t\n\tpositive = Z20885K1 \u003E= 0\n\tmantissa, exp = math.frexp( math.fabs( Z20885K1 ) )\n\tmantissa = (mantissa - 0.5) * 2**53\n\texp = exp - 1\n\treturn package( positive, int( exp ), int( mantissa ), \"Z20837\" )\n"
},
"Z64K4": "float"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Python converter from float64"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
4js35mf5ledq7dt7qvbf4do3hxtuzat
147121
147043
2024-12-19T07:33:35Z
DVrandecic (WMF)
7
made the exponent always positive for the integer value
147121
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20885"
},
"Z2K2": {
"Z1K1": "Z64",
"Z64K1": "Z20885",
"Z64K2": "Z20838",
"Z64K3": {
"Z1K1": "Z16",
"Z16K1": "Z610",
"Z16K2": "def Z20885(Z20885K1):\n\tdef package(positive, exp, mantissa, special):\n\t\treturn {\n\t\t\t\"Z1K1\": {\n\t\t\t\t\"Z1K1\": \"Z9\",\n\t\t\t\t\"Z9K1\": \"Z20838\"\n\t\t\t},\n\t\t\t\"Z20838K1\": {\n\t\t\t\t\"Z1K1\": {\n\t\t\t\t\t\"Z1K1\": \"Z9\",\n\t\t\t\t\t\"Z9K1\": \"Z16659\"\n\t\t\t\t},\n\t\t\t\t\"Z16659K1\": {\n\t\t\t\t\t\"Z1K1\": \"Z9\",\n\t\t\t\t\t\"Z9K1\": \"Z16660\" if positive else \"Z16662\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"Z20838K2\": {\n\t\t\t\t\"Z1K1\": {\n\t\t\t\t\t\"Z1K1\": \"Z9\",\n\t\t\t\t\t\"Z9K1\": \"Z16683\"\n\t\t\t\t},\n\t\t\t\t\"Z16683K1\": {\n\t\t\t\t\t\"Z1K1\": {\n\t\t\t\t\t\t\"Z1K1\": \"Z9\",\n\t\t\t\t\t\t\"Z9K1\": \"Z16659\"\n\t\t\t\t\t},\n\t\t\t\t\t\"Z16659K1\": {\n\t\t\t\t\t\t\"Z1K1\": \"Z9\",\n\t\t\t\t\t\t\"Z9K1\": \"Z16662\" if exp \u003C 0 else \"Z16661\" if exp == 0 else \"Z16660\"\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t\"Z16683K2\": {\n\t\t\t\t\t\"Z1K1\": {\n\t\t\t\t\t\t\"Z1K1\": \"Z9\",\n\t\t\t\t\t\t\"Z9K1\": \"Z13518\"\n\t\t\t\t\t},\n\t\t\t\t\t\"Z13518K1\": {\n\t\t\t\t\t\t\"Z1K1\": \"Z6\",\n\t\t\t\t\t\t\"Z6K1\": str( abs( exp ) )\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"Z20838K3\": {\n\t\t\t\t\"Z1K1\": {\n\t\t\t\t\t\"Z1K1\": \"Z9\",\n\t\t\t\t\t\"Z9K1\": \"Z13518\"\n\t\t\t\t},\n\t\t\t\t\"Z13518K1\": {\n\t\t\t\t\t\"Z1K1\": \"Z6\",\n\t\t\t\t\t\"Z6K1\": str( mantissa )\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"Z20838K4\": {\n\t\t\t\t\"Z1K1\": {\n\t\t\t\t\t\"Z1K1\": \"Z9\",\n\t\t\t\t\t\"Z9K1\": \"Z20825\"\n\t\t\t\t},\n\t\t\t\t\"Z20825K1\": {\n\t\t\t\t\t\"Z1K1\": \"Z9\",\n\t\t\t\t\t\"Z9K1\": special\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\timport math\n\t# special values\n\tif math.isnan( Z20885K1 ):\n\t\treturn package( True, 0, 0, \"Z20834\" )\n\tif math.isinf( Z20885K1 ):\n\t\tif Z20885K1 \u003E 0:\n\t\t\treturn package( True, 0, 0, \"Z20832\" )\n\t\telse:\n\t\t\treturn package( False, 0, 0, \"Z20833\" )\n\tif Z20885K1 == 0:\n\t\tif math.copysign(Z20885K1, 1) \u003C 0:\n\t\t\treturn package( False, 0, 0, \"Z20831\" )\n\t\telse:\n\t\t\treturn package( True, 0, 0, \"Z20829\" )\n\t\t\t\n\tpositive = Z20885K1 \u003E= 0\n\tmantissa, exp = math.frexp( math.fabs( Z20885K1 ) )\n\tmantissa = (mantissa - 0.5) * 2**53\n\texp = exp - 1\n\treturn package( positive, int( exp ), int( mantissa ), \"Z20837\" )\n"
},
"Z64K4": "float"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Python converter from float64"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
384b8w1qh4g2k0mj2rb64lwsvzc6a81
Z20886
0
45618
147045
2024-12-18T21:11:20Z
DVrandecic (WMF)
7
147045
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20886"
},
"Z2K2": {
"Z1K1": "Z14",
"Z14K1": "Z20849",
"Z14K3": {
"Z1K1": "Z16",
"Z16K1": "Z610",
"Z16K2": "def Z20849(Z20849K1, Z20849K2):\n\treturn Z20849K1 + Z20849K2"
}
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "float +"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
jkae9mqqhaoru2qt3sq2g8ixbztded8
Z20887
0
45619
147054
2024-12-18T21:30:32Z
Feeglgeef
8776
147054
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20887"
},
"Z2K2": {
"Z1K1": "Z14",
"Z14K1": "Z20854",
"Z14K3": {
"Z1K1": "Z16",
"Z16K1": "Z610",
"Z16K2": "def Z20854(Z20854K1):\n\treturn float(Z20854K1)"
}
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
ctsbua1vk2f22aox5dhj6aqetyzy0sy
147055
147054
2024-12-18T21:31:00Z
Feeglgeef
8776
147055
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20887"
},
"Z2K2": {
"Z1K1": "Z14",
"Z14K1": "Z20854",
"Z14K3": {
"Z1K1": "Z16",
"Z16K1": "Z610",
"Z16K2": "def Z20854(Z20854K1):\n\treturn float(Z20854K1)"
}
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Convert and return"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
phy1rwkjgntwgegkktdcyh2cynbbg5v
Z20888
0
45620
147057
2024-12-18T21:33:09Z
Feeglgeef
8776
147057
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20888"
},
"Z2K2": {
"Z1K1": "Z20",
"Z20K1": "Z20854",
"Z20K2": {
"Z1K1": "Z7",
"Z7K1": "Z20854",
"Z20854K1": {
"Z1K1": "Z19677",
"Z19677K1": "Z16660",
"Z19677K2": {
"Z1K1": "Z13518",
"Z13518K1": "1"
},
"Z19677K3": {
"Z1K1": "Z13518",
"Z13518K1": "2"
}
}
},
"Z20K3": {
"Z1K1": "Z7",
"Z7K1": "Z20850",
"Z20850K2": {
"Z1K1": "Z20838",
"Z20838K1": "Z16660",
"Z20838K2": {
"Z1K1": "Z16683",
"Z16683K1": {
"Z1K1": "Z16659",
"Z16659K1": "Z16660"
},
"Z16683K2": {
"Z1K1": "Z13518",
"Z13518K1": "1"
}
},
"Z20838K3": {
"Z1K1": "Z13518",
"Z13518K1": "0"
},
"Z20838K4": "Z20837"
}
}
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "1/2 is 0.5"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
8gh7vok52h52rj8aesok21bjhfhmpkq
Z20889
0
45621
147059
2024-12-18T21:36:06Z
Feeglgeef
8776
147059
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20889"
},
"Z2K2": {
"Z1K1": "Z20",
"Z20K1": "Z20854",
"Z20K2": {
"Z1K1": "Z7",
"Z7K1": "Z20854",
"Z20854K1": {
"Z1K1": "Z19677",
"Z19677K1": "Z16661",
"Z19677K2": {
"Z1K1": "Z13518",
"Z13518K1": "0"
},
"Z19677K3": {
"Z1K1": "Z13518",
"Z13518K1": "1"
}
}
},
"Z20K3": {
"Z1K1": "Z7",
"Z7K1": "Z20850",
"Z20850K2": {
"Z1K1": "Z20838",
"Z20838K1": "Z16661",
"Z20838K2": {
"Z1K1": "Z16683",
"Z16683K1": {
"Z1K1": "Z16659",
"Z16659K1": "Z16661"
},
"Z16683K2": {
"Z1K1": "Z13518",
"Z13518K1": "I am the globglogabgalab"
}
},
"Z20838K3": {
"Z1K1": "Z13518",
"Z13518K1": "I am the globglogabgalab"
},
"Z20838K4": "Z20829"
}
}
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "0/1 is positive 0"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
ghlfu2k9m97cp8fvjivr9x40qts5fdf
Z20890
0
45622
147061
2024-12-18T21:41:36Z
Lucas Werkmeister
53
try creating object
147061
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20890"
},
"Z2K2": {
"Z1K1": "Z20838",
"Z20838K1": "Z16660",
"Z20838K2": {
"Z1K1": "Z16683",
"Z16683K1": {
"Z1K1": "Z16659",
"Z16659K1": "Z16661"
},
"Z16683K2": {
"Z1K1": "Z13518",
"Z13518K1": "0"
}
},
"Z20838K3": {
"Z1K1": "Z13518",
"Z13518K1": "1617426887497577"
},
"Z20838K4": "Z20837"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "(testing) e"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31",
{
"Z1K1": "Z31",
"Z31K1": "Z1002",
"Z31K2": [
"Z6",
"Euler’s number",
"Napier’s constant",
"E"
]
}
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "float64 representation of the mathematical constant e"
}
]
}
}
g7v6nlkh5lbcuf8gpvoo3ip1a7k0b3v
147071
147061
2024-12-18T21:58:10Z
Lucas Werkmeister
53
fix exponent
147071
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20890"
},
"Z2K2": {
"Z1K1": "Z20838",
"Z20838K1": "Z16660",
"Z20838K2": {
"Z1K1": "Z16683",
"Z16683K1": {
"Z1K1": "Z16659",
"Z16659K1": "Z16660"
},
"Z16683K2": {
"Z1K1": "Z13518",
"Z13518K1": "1"
}
},
"Z20838K3": {
"Z1K1": "Z13518",
"Z13518K1": "1617426887497577"
},
"Z20838K4": "Z20837"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "(testing) e"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31",
{
"Z1K1": "Z31",
"Z31K1": "Z1002",
"Z31K2": [
"Z6",
"Euler’s number",
"Napier’s constant",
"E"
]
}
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "float64 representation of the mathematical constant e"
}
]
}
}
72fo4kpg14a4orrwg81psajyjnuf526
147075
147071
2024-12-18T22:08:50Z
Lucas Werkmeister
53
add German terms
147075
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20890"
},
"Z2K2": {
"Z1K1": "Z20838",
"Z20838K1": "Z16660",
"Z20838K2": {
"Z1K1": "Z16683",
"Z16683K1": {
"Z1K1": "Z16659",
"Z16659K1": "Z16660"
},
"Z16683K2": {
"Z1K1": "Z13518",
"Z13518K1": "1"
}
},
"Z20838K3": {
"Z1K1": "Z13518",
"Z13518K1": "1617426887497577"
},
"Z20838K4": "Z20837"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "(testing) e"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1430",
"Z11K2": "(Test) e"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31",
{
"Z1K1": "Z31",
"Z31K1": "Z1002",
"Z31K2": [
"Z6",
"Euler’s number",
"Napier’s constant",
"E"
]
},
{
"Z1K1": "Z31",
"Z31K1": "Z1430",
"Z31K2": [
"Z6",
"Eulersche Zahl",
"Napiers Konstante",
"Nepersche Konstante"
]
}
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "float64 representation of the mathematical constant e"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1430",
"Z11K2": "float64-Darstellung der mathematischen Konstante e"
}
]
}
}
rlfuybpbbai1z8o8q01mblgt7yq6j09
Talk:Z20890
1
45623
147063
2024-12-18T21:45:40Z
Feeglgeef
8776
cat
147063
wikitext
text/x-wiki
[[Category:Constants]]
t3ja8jlvrsjrvpyvv48djjqnlvw710h
147072
147063
2024-12-18T22:03:37Z
Lucas Werkmeister
53
/* Creation */ new section
147072
wikitext
text/x-wiki
[[Category:Constants]]
== Creation ==
I obtained the constants for this function from the following Rust program: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b148d3d147139ddf88cdbc8308bec6e3
I guessed (apparently correctly) that the exponent must be the “unbiased” exponent, i.e. not directly corresponding to the bits in the float64 representation (because Z20838K2 is an {{Z|Z16683}}, not a {{Z|Z13518}}), while the fraction should be directly the bits in the float64 representation (because enwiki also labels it that way, and the “mantissa”, which is the term I expected, is apparently calculated from that). I also tried to get the float bits out of Python or JavaScript but in the end Rust seemed to work best for me. [[User:Lucas Werkmeister|Lucas Werkmeister]] ([[User talk:Lucas Werkmeister|talk]]) 22:03, 18 December 2024 (UTC)
arj9i1g0q93m51h8pn0wcffmc8upucz
147073
147072
2024-12-18T22:05:30Z
Lucas Werkmeister
53
/* Creation */ Reply
147073
wikitext
text/x-wiki
[[Category:Constants]]
== Creation ==
I obtained the constants for this function from the following Rust program: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b148d3d147139ddf88cdbc8308bec6e3
I guessed (apparently correctly) that the exponent must be the “unbiased” exponent, i.e. not directly corresponding to the bits in the float64 representation (because Z20838K2 is an {{Z|Z16683}}, not a {{Z|Z13518}}), while the fraction should be directly the bits in the float64 representation (because enwiki also labels it that way, and the “mantissa”, which is the term I expected, is apparently calculated from that). I also tried to get the float bits out of Python or JavaScript but in the end Rust seemed to work best for me. [[User:Lucas Werkmeister|Lucas Werkmeister]] ([[User talk:Lucas Werkmeister|talk]]) 22:03, 18 December 2024 (UTC)
:(In the [[Special:Permalink/147061|initial revision]] my Rust code was missing the 64-character width in the format string, so the sign bit was not printed and I misinterpreted the <code>1</code> at the beginning of the exponent as the sign and thought the exponent was all zeroes, and also didn’t understand the bias part yet. [[Special:Diff/147071|This edit]] fixed it, and {{Z|Z20891}} appears to confirm that it’s the right value now.) [[User:Lucas Werkmeister|Lucas Werkmeister]] ([[User talk:Lucas Werkmeister|talk]]) 22:05, 18 December 2024 (UTC)
dnjhqlr58ge1v2qz6uj4d87d5181tzm
Talk:Z20862
1
45624
147064
2024-12-18T21:46:07Z
Feeglgeef
8776
cat
147064
wikitext
text/x-wiki
[[Category:Constants]]
t3ja8jlvrsjrvpyvv48djjqnlvw710h
Category:Constants
14
45625
147065
2024-12-18T21:48:02Z
Feeglgeef
8776
Created page with "Mathematical constants, represented by [[Z20838]], [[Z13518]], [[Z16683]], and [[Z19677]]"
147065
wikitext
text/x-wiki
Mathematical constants, represented by [[Z20838]], [[Z13518]], [[Z16683]], and [[Z19677]]
1hbiidwcd5t4k9ijozmmz49iu9cw2lx
Talk:Z15654
1
45626
147066
2024-12-18T21:49:11Z
Feeglgeef
8776
cat
147066
wikitext
text/x-wiki
[[Category:Constants]]
t3ja8jlvrsjrvpyvv48djjqnlvw710h
Talk:Z14692
1
45627
147067
2024-12-18T21:50:22Z
Feeglgeef
8776
cat
147067
wikitext
text/x-wiki
[[Category:Constants]]
t3ja8jlvrsjrvpyvv48djjqnlvw710h
Z20892
0
45629
147069
2024-12-18T21:54:44Z
Feeglgeef
8776
147069
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20892"
},
"Z2K2": {
"Z1K1": "Z14",
"Z14K1": "Z20891",
"Z14K3": {
"Z1K1": "Z16",
"Z16K1": "Z610",
"Z16K2": "def Z20891(Z20891K1):\n\treturn str(Z20891K1)"
}
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
aec0wsgdnygqsbdrddrez5p6lg0an3p
Z20893
0
45630
147076
2024-12-18T22:10:10Z
Feeglgeef
8776
147076
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20893"
},
"Z2K2": {
"Z1K1": "Z20838",
"Z20838K1": "Z16660",
"Z20838K2": {
"Z1K1": "Z16683",
"Z16683K1": "Z16661",
"Z16683K2": {
"Z1K1": "Z13518",
"Z13518K1": "0"
}
},
"Z20838K3": {
"Z1K1": "Z13518",
"Z13518K1": "1865452045155277"
},
"Z20838K4": "Z20837"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Square root of 2"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
rmkkn46hvx8kkysg72u16c2ngog3djx
147110
147076
2024-12-19T05:12:26Z
Jérémy-Günther-Heinz Jähnick
6055
Traduction en français (fr)
147110
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20893"
},
"Z2K2": {
"Z1K1": "Z20838",
"Z20838K1": "Z16660",
"Z20838K2": {
"Z1K1": "Z16683",
"Z16683K1": "Z16661",
"Z16683K2": {
"Z1K1": "Z13518",
"Z13518K1": "0"
}
},
"Z20838K3": {
"Z1K1": "Z13518",
"Z13518K1": "1865452045155277"
},
"Z20838K4": "Z20837"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Square root of 2"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "racine carrée de 2"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
60319e8gaye0e9u43gqb3otb0v9bq57
Talk:Z20893
1
45631
147077
2024-12-18T22:10:33Z
Feeglgeef
8776
cat
147077
wikitext
text/x-wiki
[[Category:Constants]]
t3ja8jlvrsjrvpyvv48djjqnlvw710h
Z20894
0
45632
147078
2024-12-18T22:16:24Z
Feeglgeef
8776
147078
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20894"
},
"Z2K2": {
"Z1K1": "Z20838",
"Z20838K1": "Z16660",
"Z20838K2": {
"Z1K1": "Z16683",
"Z16683K1": {
"Z1K1": "Z16659",
"Z16659K1": "Z16661"
},
"Z16683K2": {
"Z1K1": "Z13518",
"Z13518K1": "0"
}
},
"Z20838K3": {
"Z1K1": "Z13518",
"Z13518K1": "2783377641436328"
},
"Z20838K4": "Z20837"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Golden ratio"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1360",
"Z11K2": "φ"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
9wwcl7dyk7ewgiz3pvltk9paz5r2eef
147105
147078
2024-12-19T05:08:12Z
Jérémy-Günther-Heinz Jähnick
6055
Traduction en français (fr)
147105
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20894"
},
"Z2K2": {
"Z1K1": "Z20838",
"Z20838K1": "Z16660",
"Z20838K2": {
"Z1K1": "Z16683",
"Z16683K1": {
"Z1K1": "Z16659",
"Z16659K1": "Z16661"
},
"Z16683K2": {
"Z1K1": "Z13518",
"Z13518K1": "0"
}
},
"Z20838K3": {
"Z1K1": "Z13518",
"Z13518K1": "2783377641436328"
},
"Z20838K4": "Z20837"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Golden ratio"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1360",
"Z11K2": "φ"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1004",
"Z11K2": "nombre d'or"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
tmjkcrxsm7j0kp2zv61axagh1oal2z3
Z20895
0
45633
147079
2024-12-19T01:14:58Z
Feeglgeef
8776
147079
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20895"
},
"Z2K2": {
"Z1K1": "Z7",
"Z7K1": "Z881",
"Z881K1": "Z20838"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
5h703ycqkgmr39g7nd13x3flitw7ega
147081
147079
2024-12-19T01:20:28Z
Feeglgeef
8776
147081
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20895"
},
"Z2K2": {
"Z1K1": "Z7",
"Z7K1": "Z18475",
"Z18475K1": [
"Z20838",
"Z20890",
"Z20893",
"Z20894"
]
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
bhkj9t4fbt0drdirxrytvpahz8dtnaz
147082
147081
2024-12-19T01:22:05Z
Feeglgeef
8776
147082
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20895"
},
"Z2K2": {
"Z1K1": "Z7",
"Z7K1": "Z18475",
"Z18475K1": [
"Z20862",
"Z20890",
"Z20893",
"Z20894"
]
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
ag73oqenojbw6c4jsp6z8ou6i5gag0n
147083
147082
2024-12-19T01:24:04Z
Feeglgeef
8776
147083
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20895"
},
"Z2K2": {
"Z1K1": "Z7",
"Z7K1": "Z802",
"Z802K1": [
"Z20862",
"Z20890",
"Z20893",
"Z20894"
]
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
mwkaz73fiwkvd28rpbwlg4q1da6dhng
147084
147083
2024-12-19T01:24:25Z
Feeglgeef
8776
147084
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20895"
},
"Z2K2": {
"Z1K1": "Z7",
"Z7K1": "Z801",
"Z801K1": [
"Z20862",
"Z20890",
"Z20893",
"Z20894"
]
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
kmw2agawiaens77nnjcp1f5b6p7f83w
147085
147084
2024-12-19T01:27:02Z
Feeglgeef
8776
147085
zobject
text/plain
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z20895"
},
"Z2K2": {
"Z1K1": "Z7",
"Z7K1": "Z801",
"Z801K1": [
"Z20838",
"Z20862",
"Z20890",
"Z20893",
"Z20894"
]
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
"Z31"
]
},
"Z2K5": {
"Z1K1": "Z12",
"Z12K1": [
"Z11"
]
}
}
szpuksm2e2aep3uye8g72ywrmijltsp
Wikifunctions:Working with Wikidata content
4
45634
147080
2024-12-19T01:16:36Z
DMartin (WMF)
24
Initial text, pasted from a Google doc
147080
wikitext
text/x-wiki
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of function calls that a user can step through on Wikifunctions.org, with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
Wikifunctions has capabilities for importing and using content from Wikidata. There is a primary focus currently on lexicographic content (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at Wikidata:Lexicographical data/Documentation.
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, Fetch Wikidata lexeme form, and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit Fetch Wikidata lexeme form in your browser.
** Notice, in the About box, that this function takes a single input, which is of type Wikidata lexeme form reference, and returns a Wikidata lexeme form.
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure A). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure B), click on it. Your selection should then appear as in Figure C.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a Wikidata lexeme form reference, as shown in Figure D, with just the type and the Wikidata ID L6758-F4. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID L6758-F4,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of Wikidata lexeme form.
* The result should appear as shown in Figure E. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure F). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a Wikidata lexeme reference, and each value in the ''grammatical features'' list is represented as a Wikidata item reference.
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne''.
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
Here we show how to compose a call to grammatical gender from Lexeme, an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property P5185/grammatical gender.
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit grammatical gender from Lexeme in your browser.
** Notice, in the About box, that this function takes a single input, which is of type Wikidata lexeme.
** Notice also that its output will be a Typed list of Wikidata item reference. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 1). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click ''Run function''.
* The result should appear as shown in Figure 4. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a Wikidata item reference, which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the Wikidata item reference for ''masculine)'' shown in Figure 5, with just the type and the Wikidata item ID Q499327.
== Getting a lexeme form having given grammatical features ==
Here we show how to compose a call to first matching representation string from lexeme, an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit first matching representation string from lexeme in your browser.
** Notice, in the About box, that this function takes an input of type Wikidata lexeme, and a second input which is a Typed list of Wikidata item reference, and returns a String.
* Locate the input selectors (shown in Figure 6).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (as shown in Figure 7), click on it. Your selection should then appear as in Figure 8.
* Enter the grammatical feature ''singular''.
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input choices should now appear as in Figure 9.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the Wikidata item reference, showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 9.
== Generating a phrase with agreement ==
Here we show how to compose a call to German indef noun phrase from noun and adjective, an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling grammatical gender from Lexeme and (2) and (4) by calls to first matching representation string from lexeme.
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
* Visit German indef noun phrase from noun and adjective in your browser.
* Notice, in the About box, that this function takes two inputs of type Wikidata lexeme and returns a String.
* Locate the input selectors (shown in Figure 11). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as shown in Figure 2).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as shown in Figure 7).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 12).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire Wikidata lexeme as its second input; not just a reference to a lexeme. Knowing this, it produces a Wikidata lexeme reference for the selected lexeme, and also constructs a call that passes that reference to the function Fetch Wikidata lexeme. When ''Run function'' is clicked, the result of this call will be used as the second input to German indef noun phrase from noun and adjective.
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how German indef noun phrase from noun and adjective has been implemented, visit the implementation at agree adjective with noun. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to grammatical gender from Lexeme and first matching representation string from lexeme.
kj03bg4m80b0gbbwzgzm03kknklwrkl
147086
147080
2024-12-19T01:31:06Z
DMartin (WMF)
24
Added some formatting details
147086
wikitext
text/x-wiki
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of function calls that a user can step through on Wikifunctions.org, with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
Wikifunctions has capabilities for importing and using content from Wikidata. There is a primary focus currently on lexicographic content (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne''.
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
Here we show how to compose a call to grammatical gender from Lexeme, an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property P5185/grammatical gender.
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit grammatical gender from Lexeme in your browser.
** Notice, in the About box, that this function takes a single input, which is of type Wikidata lexeme.
** Notice also that its output will be a Typed list of Wikidata item reference. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 1). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click ''Run function''.
* The result should appear as shown in Figure 4. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a Wikidata item reference, which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the Wikidata item reference for ''masculine)'' shown in Figure 5, with just the type and the Wikidata item ID Q499327.
== Getting a lexeme form having given grammatical features ==
Here we show how to compose a call to first matching representation string from lexeme, an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit first matching representation string from lexeme in your browser.
** Notice, in the About box, that this function takes an input of type Wikidata lexeme, and a second input which is a Typed list of Wikidata item reference, and returns a String.
* Locate the input selectors (shown in Figure 6).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (as shown in Figure 7), click on it. Your selection should then appear as in Figure 8.
* Enter the grammatical feature ''singular''.
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input choices should now appear as in Figure 9.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the Wikidata item reference, showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 9.
== Generating a phrase with agreement ==
Here we show how to compose a call to German indef noun phrase from noun and adjective, an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling grammatical gender from Lexeme and (2) and (4) by calls to first matching representation string from lexeme.
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
* Visit German indef noun phrase from noun and adjective in your browser.
* Notice, in the About box, that this function takes two inputs of type Wikidata lexeme and returns a String.
* Locate the input selectors (shown in Figure 11). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as shown in Figure 2).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as shown in Figure 7).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 12).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire Wikidata lexeme as its second input; not just a reference to a lexeme. Knowing this, it produces a Wikidata lexeme reference for the selected lexeme, and also constructs a call that passes that reference to the function Fetch Wikidata lexeme. When ''Run function'' is clicked, the result of this call will be used as the second input to German indef noun phrase from noun and adjective.
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how German indef noun phrase from noun and adjective has been implemented, visit the implementation at agree adjective with noun. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to grammatical gender from Lexeme and first matching representation string from lexeme.
3em7xq9q11r9ue0mkzgipvv66u4gtfp
147087
147086
2024-12-19T01:45:45Z
Feeglgeef
8776
wikilinks and minor ce
147087
wikitext
text/x-wiki
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of function calls that a user can step through on Wikifunctions.org, with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
Wikifunctions has capabilities for importing and using content from Wikidata. There is a primary focus currently on lexicographic content (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
Here we show how to compose a call to grammatical gender from Lexeme, an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property P5185/grammatical gender.
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit grammatical gender from Lexeme in your browser.
** Notice, in the About box, that this function takes a single input, which is of type Wikidata lexeme.
** Notice also that its output will be a Typed list of Wikidata item reference. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 1). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click ''Run function''.
* The result should appear as shown in Figure 4. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a Wikidata item reference, which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the Wikidata item reference for ''masculine)'' shown in Figure 5, with just the type and the Wikidata item ID Q499327.
== Getting a lexeme form having given grammatical features ==
Here we show how to compose a call to first matching representation string from lexeme, an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit first matching representation string from lexeme in your browser.
** Notice, in the About box, that this function takes an input of type Wikidata lexeme, and a second input which is a Typed list of Wikidata item reference, and returns a String.
* Locate the input selectors (shown in Figure 6).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (as shown in Figure 7), click on it. Your selection should then appear as in Figure 8.
* Enter the grammatical feature ''singular''.
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input choices should now appear as in Figure 9.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the Wikidata item reference, showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 9.
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling grammatical gender from Lexeme and (2) and (4) by calls to first matching representation string from lexeme.
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type Wikidata lexeme and returns a String.
* Locate the input selectors (shown in Figure 11). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as shown in Figure 2).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as shown in Figure 7).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 12).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire Wikidata lexeme as its second input; not just a reference to a lexeme. Knowing this, it produces a Wikidata lexeme reference for the selected lexeme, and also constructs a call that passes that reference to the function Fetch Wikidata lexeme. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at agree adjective with noun. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to grammatical gender from Lexeme and first matching representation string from lexeme.
ktwk6bmqqy31trt8j0li61loji9vz0t
147088
147087
2024-12-19T01:47:22Z
Feeglgeef
8776
link
147088
wikitext
text/x-wiki
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of function calls that a user can step through on [wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
Wikifunctions has capabilities for importing and using content from Wikidata. There is a primary focus currently on lexicographic content (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
Here we show how to compose a call to grammatical gender from Lexeme, an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property P5185/grammatical gender.
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit grammatical gender from Lexeme in your browser.
** Notice, in the About box, that this function takes a single input, which is of type Wikidata lexeme.
** Notice also that its output will be a Typed list of Wikidata item reference. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 1). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click ''Run function''.
* The result should appear as shown in Figure 4. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a Wikidata item reference, which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the Wikidata item reference for ''masculine)'' shown in Figure 5, with just the type and the Wikidata item ID Q499327.
== Getting a lexeme form having given grammatical features ==
Here we show how to compose a call to first matching representation string from lexeme, an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit first matching representation string from lexeme in your browser.
** Notice, in the About box, that this function takes an input of type Wikidata lexeme, and a second input which is a Typed list of Wikidata item reference, and returns a String.
* Locate the input selectors (shown in Figure 6).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (as shown in Figure 7), click on it. Your selection should then appear as in Figure 8.
* Enter the grammatical feature ''singular''.
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input choices should now appear as in Figure 9.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the Wikidata item reference, showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 9.
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling grammatical gender from Lexeme and (2) and (4) by calls to first matching representation string from lexeme.
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type Wikidata lexeme and returns a String.
* Locate the input selectors (shown in Figure 11). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as shown in Figure 2).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as shown in Figure 7).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 12).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire Wikidata lexeme as its second input; not just a reference to a lexeme. Knowing this, it produces a Wikidata lexeme reference for the selected lexeme, and also constructs a call that passes that reference to the function Fetch Wikidata lexeme. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at agree adjective with noun. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to grammatical gender from Lexeme and first matching representation string from lexeme.
5mtk2czaemj4h220c4vh24sbew3nptd
147089
147088
2024-12-19T01:47:42Z
Feeglgeef
8776
fix
147089
wikitext
text/x-wiki
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of function calls that a user can step through on [https://www.wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
Wikifunctions has capabilities for importing and using content from Wikidata. There is a primary focus currently on lexicographic content (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
Here we show how to compose a call to grammatical gender from Lexeme, an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property P5185/grammatical gender.
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit grammatical gender from Lexeme in your browser.
** Notice, in the About box, that this function takes a single input, which is of type Wikidata lexeme.
** Notice also that its output will be a Typed list of Wikidata item reference. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 1). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click ''Run function''.
* The result should appear as shown in Figure 4. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a Wikidata item reference, which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the Wikidata item reference for ''masculine)'' shown in Figure 5, with just the type and the Wikidata item ID Q499327.
== Getting a lexeme form having given grammatical features ==
Here we show how to compose a call to first matching representation string from lexeme, an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit first matching representation string from lexeme in your browser.
** Notice, in the About box, that this function takes an input of type Wikidata lexeme, and a second input which is a Typed list of Wikidata item reference, and returns a String.
* Locate the input selectors (shown in Figure 6).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (as shown in Figure 7), click on it. Your selection should then appear as in Figure 8.
* Enter the grammatical feature ''singular''.
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input choices should now appear as in Figure 9.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the Wikidata item reference, showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 9.
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling grammatical gender from Lexeme and (2) and (4) by calls to first matching representation string from lexeme.
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type Wikidata lexeme and returns a String.
* Locate the input selectors (shown in Figure 11). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as shown in Figure 2).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as shown in Figure 7).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 12).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire Wikidata lexeme as its second input; not just a reference to a lexeme. Knowing this, it produces a Wikidata lexeme reference for the selected lexeme, and also constructs a call that passes that reference to the function Fetch Wikidata lexeme. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at agree adjective with noun. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to grammatical gender from Lexeme and first matching representation string from lexeme.
8338q49fify26vdlz64hbi9ge3sqjn0
147090
147089
2024-12-19T01:52:57Z
Feeglgeef
8776
more links
147090
wikitext
text/x-wiki
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of [[Wikifunctions:Function model#Z7/Function calls|function calls]] that a user can step through on [https://www.wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
Wikifunctions has capabilities for importing and using content from [[d:|Wikidata]]. There is a primary focus currently on [[d:Wikidata:Lexicographical data|lexicographic content]] (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
Here we show how to compose a call to grammatical gender from Lexeme, an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property P5185/grammatical gender.
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit grammatical gender from Lexeme in your browser.
** Notice, in the About box, that this function takes a single input, which is of type Wikidata lexeme.
** Notice also that its output will be a Typed list of Wikidata item reference. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 1). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click ''Run function''.
* The result should appear as shown in Figure 4. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a Wikidata item reference, which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the Wikidata item reference for ''masculine)'' shown in Figure 5, with just the type and the Wikidata item ID Q499327.
== Getting a lexeme form having given grammatical features ==
Here we show how to compose a call to first matching representation string from lexeme, an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit first matching representation string from lexeme in your browser.
** Notice, in the About box, that this function takes an input of type Wikidata lexeme, and a second input which is a Typed list of Wikidata item reference, and returns a String.
* Locate the input selectors (shown in Figure 6).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (as shown in Figure 7), click on it. Your selection should then appear as in Figure 8.
* Enter the grammatical feature ''singular''.
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input choices should now appear as in Figure 9.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the Wikidata item reference, showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 9.
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling grammatical gender from Lexeme and (2) and (4) by calls to first matching representation string from lexeme.
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type Wikidata lexeme and returns a String.
* Locate the input selectors (shown in Figure 11). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as shown in Figure 2).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as shown in Figure 7).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 12).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire Wikidata lexeme as its second input; not just a reference to a lexeme. Knowing this, it produces a Wikidata lexeme reference for the selected lexeme, and also constructs a call that passes that reference to the function Fetch Wikidata lexeme. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at agree adjective with noun. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to grammatical gender from Lexeme and first matching representation string from lexeme.
0qaanaobqa3w5o4tesy8gimwdpeq8sh
147091
147090
2024-12-19T02:17:48Z
DMartin (WMF)
24
/* Getting acquainted with Wikidata content on Wikifunctions */ Inserted 6 new figures
147091
wikitext
text/x-wiki
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of [[Wikifunctions:Function model#Z7/Function calls|function calls]] that a user can step through on [https://www.wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
[[File:Lexeme form selector.png|thumb|Fig. 1. Lexeme form selector]]
[[File:Lexeme form selector with "schoner".png|thumb|Fig. 2. Lexeme form selector with 2 choices showing]]
[[File:Lexeme form selector with "schoner" selected.png|thumb|Fig. 3. Lexeme form selector with "schöner" selected]]
[[File:Lexeme form reference for L6758-F4.png|thumb|Fig. 4. Lexeme form reference]]
[[File:Compact view of a lexeme form.png|thumb|Fig. 5. Compact view of lexeme form]]
[[File:Expanded view of a lexeme form.png|thumb|Fig. 6. Expanded view of lexeme form]]
Wikifunctions has capabilities for importing and using content from [[d:|Wikidata]]. There is a primary focus currently on [[d:Wikidata:Lexicographical data|lexicographic content]] (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
Here we show how to compose a call to grammatical gender from Lexeme, an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property P5185/grammatical gender.
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit grammatical gender from Lexeme in your browser.
** Notice, in the About box, that this function takes a single input, which is of type Wikidata lexeme.
** Notice also that its output will be a Typed list of Wikidata item reference. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 1). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click ''Run function''.
* The result should appear as shown in Figure 4. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a Wikidata item reference, which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the Wikidata item reference for ''masculine)'' shown in Figure 5, with just the type and the Wikidata item ID Q499327.
== Getting a lexeme form having given grammatical features ==
Here we show how to compose a call to first matching representation string from lexeme, an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit first matching representation string from lexeme in your browser.
** Notice, in the About box, that this function takes an input of type Wikidata lexeme, and a second input which is a Typed list of Wikidata item reference, and returns a String.
* Locate the input selectors (shown in Figure 6).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (as shown in Figure 7), click on it. Your selection should then appear as in Figure 8.
* Enter the grammatical feature ''singular''.
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input choices should now appear as in Figure 9.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the Wikidata item reference, showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 9.
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling grammatical gender from Lexeme and (2) and (4) by calls to first matching representation string from lexeme.
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type Wikidata lexeme and returns a String.
* Locate the input selectors (shown in Figure 11). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as shown in Figure 2).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as shown in Figure 7).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 12).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire Wikidata lexeme as its second input; not just a reference to a lexeme. Knowing this, it produces a Wikidata lexeme reference for the selected lexeme, and also constructs a call that passes that reference to the function Fetch Wikidata lexeme. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at agree adjective with noun. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to grammatical gender from Lexeme and first matching representation string from lexeme.
176cz36bt2feva04507pborq2b6w7ex
147092
147091
2024-12-19T03:07:24Z
DMartin (WMF)
24
/* Getting acquainted with Wikidata content on Wikifunctions */ Repositioned the figures
147092
wikitext
text/x-wiki
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of [[Wikifunctions:Function model#Z7/Function calls|function calls]] that a user can step through on [https://www.wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
[[File:Lexeme form selector.png|thumb|Fig. 1. Lexeme form selector]]
[[File:Expanded view of a lexeme form.png|thumb|Fig. 6. Expanded view of lexeme form]]
Wikifunctions has capabilities for importing and using content from [[d:|Wikidata]]. There is a primary focus currently on [[d:Wikidata:Lexicographical data|lexicographic content]] (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
<gallery mode=packed heights=200px>
File:Lexeme form selector with "schoner".png|Fig. 2. Lexeme form selector with 2 choices showing
File:Lexeme form selector with "schoner" selected.png|Fig. 3. Lexeme form selector with "schöner" selected
File:Lexeme form reference for L6758-F4.png|Fig. 4. Lexeme form reference
File:Compact view of a lexeme form.png|Fig. 5. Compact view of lexeme form
</gallery>
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
Here we show how to compose a call to grammatical gender from Lexeme, an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property P5185/grammatical gender.
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit grammatical gender from Lexeme in your browser.
** Notice, in the About box, that this function takes a single input, which is of type Wikidata lexeme.
** Notice also that its output will be a Typed list of Wikidata item reference. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 1). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click ''Run function''.
* The result should appear as shown in Figure 4. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a Wikidata item reference, which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the Wikidata item reference for ''masculine)'' shown in Figure 5, with just the type and the Wikidata item ID Q499327.
== Getting a lexeme form having given grammatical features ==
Here we show how to compose a call to first matching representation string from lexeme, an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit first matching representation string from lexeme in your browser.
** Notice, in the About box, that this function takes an input of type Wikidata lexeme, and a second input which is a Typed list of Wikidata item reference, and returns a String.
* Locate the input selectors (shown in Figure 6).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (as shown in Figure 7), click on it. Your selection should then appear as in Figure 8.
* Enter the grammatical feature ''singular''.
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input choices should now appear as in Figure 9.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the Wikidata item reference, showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 9.
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling grammatical gender from Lexeme and (2) and (4) by calls to first matching representation string from lexeme.
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type Wikidata lexeme and returns a String.
* Locate the input selectors (shown in Figure 11). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as shown in Figure 2).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as shown in Figure 7).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 12).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire Wikidata lexeme as its second input; not just a reference to a lexeme. Knowing this, it produces a Wikidata lexeme reference for the selected lexeme, and also constructs a call that passes that reference to the function Fetch Wikidata lexeme. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at agree adjective with noun. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to grammatical gender from Lexeme and first matching representation string from lexeme.
cw46t5evp9etdoxzhq9y3wcah8nsdlh
147093
147092
2024-12-19T03:12:58Z
DMartin (WMF)
24
/* Calling the function */
147093
wikitext
text/x-wiki
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of [[Wikifunctions:Function model#Z7/Function calls|function calls]] that a user can step through on [https://www.wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
[[File:Lexeme form selector.png|thumb|Fig. 1. Lexeme form selector]]
[[File:Expanded view of a lexeme form.png|thumb|Fig. 6. Expanded view of lexeme form]]
Wikifunctions has capabilities for importing and using content from [[d:|Wikidata]]. There is a primary focus currently on [[d:Wikidata:Lexicographical data|lexicographic content]] (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
<gallery mode=packed heights=200px>
File:Lexeme form selector with "schoner".png|Fig. 2. Lexeme form selector with 2 choices showing
File:Lexeme form selector with "schoner" selected.png|Fig. 3. Lexeme form selector with "schöner" selected
File:Lexeme form reference for L6758-F4.png|Fig. 4. Lexeme form reference
File:Compact view of a lexeme form.png|Fig. 5. Compact view of lexeme form
</gallery>
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
Here we show how to compose a call to grammatical gender from Lexeme, an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property P5185/grammatical gender.
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit grammatical gender from Lexeme in your browser.
** Notice, in the About box, that this function takes a single input, which is of type Wikidata lexeme.
** Notice also that its output will be a Typed list of Wikidata item reference. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 1). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click ''Run function''.
* The result should appear as shown in Figure 4. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a Wikidata item reference, which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the Wikidata item reference for ''masculine)'' shown in Figure 5, with just the type and the Wikidata item ID Q499327.
== Getting a lexeme form having given grammatical features ==
Here we show how to compose a call to first matching representation string from lexeme, an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit first matching representation string from lexeme in your browser.
** Notice, in the About box, that this function takes an input of type Wikidata lexeme, and a second input which is a Typed list of Wikidata item reference, and returns a String.
* Locate the input selectors (shown in Figure 6).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (as shown in Figure 7), click on it. Your selection should then appear as in Figure 8.
* Enter the grammatical feature ''singular''.
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input choices should now appear as in Figure 9.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the Wikidata item reference, showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 9.
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling grammatical gender from Lexeme and (2) and (4) by calls to first matching representation string from lexeme.
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type Wikidata lexeme and returns a String.
* Locate the input selectors (shown in Figure 11). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as shown in Figure 2).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as shown in Figure 7).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 12).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire Wikidata lexeme as its second input; not just a reference to a lexeme. Knowing this, it produces a Wikidata lexeme reference for the selected lexeme, and also constructs a call that passes that reference to the function Fetch Wikidata lexeme. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at agree adjective with noun. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to grammatical gender from Lexeme and first matching representation string from lexeme.
g9m13xxss6ygr5v5yu28f9543808rr2
147094
147093
2024-12-19T03:24:56Z
DMartin (WMF)
24
/* Getting the value of a statement in a lexeme */ Added some links and formatting
147094
wikitext
text/x-wiki
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of [[Wikifunctions:Function model#Z7/Function calls|function calls]] that a user can step through on [https://www.wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
[[File:Lexeme form selector.png|thumb|Fig. 1. Lexeme form selector]]
[[File:Expanded view of a lexeme form.png|thumb|Fig. 6. Expanded view of lexeme form]]
Wikifunctions has capabilities for importing and using content from [[d:|Wikidata]]. There is a primary focus currently on [[d:Wikidata:Lexicographical data|lexicographic content]] (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
<gallery mode=packed heights=200px>
File:Lexeme form selector with "schoner".png|Fig. 2. Lexeme form selector with 2 choices showing
File:Lexeme form selector with "schoner" selected.png|Fig. 3. Lexeme form selector with "schöner" selected
File:Lexeme form reference for L6758-F4.png|Fig. 4. Lexeme form reference
File:Compact view of a lexeme form.png|Fig. 5. Compact view of lexeme form
</gallery>
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
Here we show how to compose a call to grammatical gender from Lexeme, an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property [[wikidata:Property:P5185|P5185/grammatical gender]].
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit [[Z20616|<u>grammatical gender from Lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6005|<u>Wikidata lexeme</u>]].
** Notice also that its output will be a Typed list of [[Z6091|<u>Wikidata item reference</u>]]. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 1). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click ''Run function''.
* The result should appear as shown in Figure 4. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a [[Z6091|<u>Wikidata item reference</u>]], which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the [[Z6091|<u>Wikidata item reference</u>]] for ''masculine)'' shown in Figure 5, with just the type and the Wikidata item ID <code>Q499327</code>.
== Getting a lexeme form having given grammatical features ==
Here we show how to compose a call to first matching representation string from lexeme, an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit first matching representation string from lexeme in your browser.
** Notice, in the About box, that this function takes an input of type Wikidata lexeme, and a second input which is a Typed list of Wikidata item reference, and returns a String.
* Locate the input selectors (shown in Figure 6).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (as shown in Figure 7), click on it. Your selection should then appear as in Figure 8.
* Enter the grammatical feature ''singular''.
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input choices should now appear as in Figure 9.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the Wikidata item reference, showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 9.
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling grammatical gender from Lexeme and (2) and (4) by calls to first matching representation string from lexeme.
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type Wikidata lexeme and returns a String.
* Locate the input selectors (shown in Figure 11). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as shown in Figure 2).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as shown in Figure 7).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 12).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire Wikidata lexeme as its second input; not just a reference to a lexeme. Knowing this, it produces a Wikidata lexeme reference for the selected lexeme, and also constructs a call that passes that reference to the function Fetch Wikidata lexeme. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at agree adjective with noun. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to grammatical gender from Lexeme and first matching representation string from lexeme.
p03bkq8hh4cavjbai02vg7s9relaaxk
147095
147094
2024-12-19T03:26:31Z
DMartin (WMF)
24
Added Draft template
147095
wikitext
text/x-wiki
{{Draft}}
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of [[Wikifunctions:Function model#Z7/Function calls|function calls]] that a user can step through on [https://www.wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
[[File:Lexeme form selector.png|thumb|Fig. 1. Lexeme form selector]]
[[File:Expanded view of a lexeme form.png|thumb|Fig. 6. Expanded view of lexeme form]]
Wikifunctions has capabilities for importing and using content from [[d:|Wikidata]]. There is a primary focus currently on [[d:Wikidata:Lexicographical data|lexicographic content]] (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
<gallery mode=packed heights=200px>
File:Lexeme form selector with "schoner".png|Fig. 2. Lexeme form selector with 2 choices showing
File:Lexeme form selector with "schoner" selected.png|Fig. 3. Lexeme form selector with "schöner" selected
File:Lexeme form reference for L6758-F4.png|Fig. 4. Lexeme form reference
File:Compact view of a lexeme form.png|Fig. 5. Compact view of lexeme form
</gallery>
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
Here we show how to compose a call to grammatical gender from Lexeme, an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property [[wikidata:Property:P5185|P5185/grammatical gender]].
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit [[Z20616|<u>grammatical gender from Lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6005|<u>Wikidata lexeme</u>]].
** Notice also that its output will be a Typed list of [[Z6091|<u>Wikidata item reference</u>]]. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 1). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click ''Run function''.
* The result should appear as shown in Figure 4. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a [[Z6091|<u>Wikidata item reference</u>]], which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the [[Z6091|<u>Wikidata item reference</u>]] for ''masculine)'' shown in Figure 5, with just the type and the Wikidata item ID <code>Q499327</code>.
== Getting a lexeme form having given grammatical features ==
Here we show how to compose a call to first matching representation string from lexeme, an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit first matching representation string from lexeme in your browser.
** Notice, in the About box, that this function takes an input of type Wikidata lexeme, and a second input which is a Typed list of Wikidata item reference, and returns a String.
* Locate the input selectors (shown in Figure 6).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (as shown in Figure 7), click on it. Your selection should then appear as in Figure 8.
* Enter the grammatical feature ''singular''.
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input choices should now appear as in Figure 9.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the Wikidata item reference, showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 9.
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling grammatical gender from Lexeme and (2) and (4) by calls to first matching representation string from lexeme.
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type Wikidata lexeme and returns a String.
* Locate the input selectors (shown in Figure 11). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as shown in Figure 2).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as shown in Figure 7).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 12).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire Wikidata lexeme as its second input; not just a reference to a lexeme. Knowing this, it produces a Wikidata lexeme reference for the selected lexeme, and also constructs a call that passes that reference to the function Fetch Wikidata lexeme. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at agree adjective with noun. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to grammatical gender from Lexeme and first matching representation string from lexeme.
2yapj3tpbuge19ipjtjwdb0i75bkfib
147096
147095
2024-12-19T03:28:19Z
DMartin (WMF)
24
/* Getting the value of a statement in a lexeme */
147096
wikitext
text/x-wiki
{{Draft}}
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of [[Wikifunctions:Function model#Z7/Function calls|function calls]] that a user can step through on [https://www.wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
[[File:Lexeme form selector.png|thumb|Fig. 1. Lexeme form selector]]
[[File:Expanded view of a lexeme form.png|thumb|Fig. 6. Expanded view of lexeme form]]
Wikifunctions has capabilities for importing and using content from [[d:|Wikidata]]. There is a primary focus currently on [[d:Wikidata:Lexicographical data|lexicographic content]] (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
<gallery mode=packed heights=200px>
File:Lexeme form selector with "schoner".png|Fig. 2. Lexeme form selector with 2 choices showing
File:Lexeme form selector with "schoner" selected.png|Fig. 3. Lexeme form selector with "schöner" selected
File:Lexeme form reference for L6758-F4.png|Fig. 4. Lexeme form reference
File:Compact view of a lexeme form.png|Fig. 5. Compact view of lexeme form
</gallery>
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
Here we show how to compose a call to [[Z20616|<u>grammatical gender from Lexeme</u>]], an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property [[wikidata:Property:P5185|P5185/grammatical gender]].
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit [[Z20616|<u>grammatical gender from Lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6005|<u>Wikidata lexeme</u>]].
** Notice also that its output will be a Typed list of [[Z6091|<u>Wikidata item reference</u>]]. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 1). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click ''Run function''.
* The result should appear as shown in Figure 4. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a [[Z6091|<u>Wikidata item reference</u>]], which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the [[Z6091|<u>Wikidata item reference</u>]] for ''masculine)'' shown in Figure 5, with just the type and the Wikidata item ID <code>Q499327</code>.
== Getting a lexeme form having given grammatical features ==
Here we show how to compose a call to first matching representation string from lexeme, an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit first matching representation string from lexeme in your browser.
** Notice, in the About box, that this function takes an input of type Wikidata lexeme, and a second input which is a Typed list of Wikidata item reference, and returns a String.
* Locate the input selectors (shown in Figure 6).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (as shown in Figure 7), click on it. Your selection should then appear as in Figure 8.
* Enter the grammatical feature ''singular''.
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input choices should now appear as in Figure 9.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the Wikidata item reference, showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 9.
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling grammatical gender from Lexeme and (2) and (4) by calls to first matching representation string from lexeme.
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type Wikidata lexeme and returns a String.
* Locate the input selectors (shown in Figure 11). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as shown in Figure 2).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as shown in Figure 7).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 12).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire Wikidata lexeme as its second input; not just a reference to a lexeme. Knowing this, it produces a Wikidata lexeme reference for the selected lexeme, and also constructs a call that passes that reference to the function Fetch Wikidata lexeme. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at agree adjective with noun. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to grammatical gender from Lexeme and first matching representation string from lexeme.
nqg6z18pqp7vd38vczcfls6hgt5dl1h
147099
147096
2024-12-19T04:43:55Z
DMartin (WMF)
24
/* Getting the value of a statement in a lexeme */
147099
wikitext
text/x-wiki
{{Draft}}
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of [[Wikifunctions:Function model#Z7/Function calls|function calls]] that a user can step through on [https://www.wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
[[File:Lexeme form selector.png|thumb|Fig. 1. Lexeme form selector]]
[[File:Expanded view of a lexeme form.png|thumb|Fig. 6. Expanded view of lexeme form]]
Wikifunctions has capabilities for importing and using content from [[d:|Wikidata]]. There is a primary focus currently on [[d:Wikidata:Lexicographical data|lexicographic content]] (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
<gallery mode=packed heights=200px>
File:Lexeme form selector with "schoner".png|Fig. 2. Lexeme form selector with 2 choices showing
File:Lexeme form selector with "schoner" selected.png|Fig. 3. Lexeme form selector with "schöner" selected
File:Lexeme form reference for L6758-F4.png|Fig. 4. Lexeme form reference
File:Compact view of a lexeme form.png|Fig. 5. Compact view of lexeme form
</gallery>
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
[[File:Lexeme selector.png|thumb|Fig. 7. Lexeme selector]]
[[File:Lexeme selector showing several choices.png|thumb|Fig. 8. Lexeme selector showing several choices]]
Here we show how to compose a call to [[Z20616|<u>grammatical gender from Lexeme</u>]], an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property [[wikidata:Property:P5185|P5185/grammatical gender]].
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit [[Z20616|<u>grammatical gender from Lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6005|<u>Wikidata lexeme</u>]].
** Notice also that its output will be a Typed list of [[Z6091|<u>Wikidata item reference</u>]]. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 7). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 8), click on it. Your selection should then appear as in Figure 9.
* Click ''Run function''.
* The result should appear as shown in Figure 10. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a [[Z6091|<u>Wikidata item reference</u>]], which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the [[Z6091|<u>Wikidata item reference</u>]] for ''masculine)'' shown in Figure 11, containing the type and the Wikidata item ID <code>Q499327</code>.
<gallery mode=packed heights=200px>
File:Lexeme selector with "Hut" selected.png|Fig. 9. Lexeme selector with "Hut" selected
File:Compact view for a Wikidata item.png|Fig. 10. Compact view for a Wikidata item reference
File:Wikidata item reference for Q499327.png|Fig. 11. Wikidata item reference for the concept "masculine"
</gallery>
== Getting a lexeme form having given grammatical features ==
Here we show how to compose a call to first matching representation string from lexeme, an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit first matching representation string from lexeme in your browser.
** Notice, in the About box, that this function takes an input of type Wikidata lexeme, and a second input which is a Typed list of Wikidata item reference, and returns a String.
* Locate the input selectors (shown in Figure 6).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (as shown in Figure 7), click on it. Your selection should then appear as in Figure 8.
* Enter the grammatical feature ''singular''.
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input choices should now appear as in Figure 9.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the Wikidata item reference, showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 9.
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling grammatical gender from Lexeme and (2) and (4) by calls to first matching representation string from lexeme.
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type Wikidata lexeme and returns a String.
* Locate the input selectors (shown in Figure 11). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as shown in Figure 2).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as shown in Figure 7).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 12).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire Wikidata lexeme as its second input; not just a reference to a lexeme. Knowing this, it produces a Wikidata lexeme reference for the selected lexeme, and also constructs a call that passes that reference to the function Fetch Wikidata lexeme. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at agree adjective with noun. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to grammatical gender from Lexeme and first matching representation string from lexeme.
rvekftuky2k64sght388rwcil11odm7
147100
147099
2024-12-19T04:51:35Z
DMartin (WMF)
24
/* Getting a lexeme form having given grammatical features */ Added some formatting
147100
wikitext
text/x-wiki
{{Draft}}
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of [[Wikifunctions:Function model#Z7/Function calls|function calls]] that a user can step through on [https://www.wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
[[File:Lexeme form selector.png|thumb|Fig. 1. Lexeme form selector]]
[[File:Expanded view of a lexeme form.png|thumb|Fig. 6. Expanded view of lexeme form]]
Wikifunctions has capabilities for importing and using content from [[d:|Wikidata]]. There is a primary focus currently on [[d:Wikidata:Lexicographical data|lexicographic content]] (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
<gallery mode=packed heights=200px>
File:Lexeme form selector with "schoner".png|Fig. 2. Lexeme form selector with 2 choices showing
File:Lexeme form selector with "schoner" selected.png|Fig. 3. Lexeme form selector with "schöner" selected
File:Lexeme form reference for L6758-F4.png|Fig. 4. Lexeme form reference
File:Compact view of a lexeme form.png|Fig. 5. Compact view of lexeme form
</gallery>
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
[[File:Lexeme selector.png|thumb|Fig. 7. Lexeme selector]]
[[File:Lexeme selector showing several choices.png|thumb|Fig. 8. Lexeme selector showing several choices]]
Here we show how to compose a call to [[Z20616|<u>grammatical gender from Lexeme</u>]], an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property [[wikidata:Property:P5185|P5185/grammatical gender]].
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit [[Z20616|<u>grammatical gender from Lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6005|<u>Wikidata lexeme</u>]].
** Notice also that its output will be a Typed list of [[Z6091|<u>Wikidata item reference</u>]]. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 7). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 8), click on it. Your selection should then appear as in Figure 9.
* Click ''Run function''.
* The result should appear as shown in Figure 10. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a [[Z6091|<u>Wikidata item reference</u>]], which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the [[Z6091|<u>Wikidata item reference</u>]] for ''masculine)'' shown in Figure 11, containing the type and the Wikidata item ID <code>Q499327</code>.
<gallery mode=packed heights=200px>
File:Lexeme selector with "Hut" selected.png|Fig. 9. Lexeme selector with "Hut" selected
File:Compact view for a Wikidata item.png|Fig. 10. Compact view for a Wikidata item reference
File:Wikidata item reference for Q499327.png|Fig. 11. Wikidata item reference for the concept "masculine"
</gallery>
== Getting a lexeme form having given grammatical features ==
Here we show how to compose a call to [[Z19241|<u>first matching representation string from lexeme</u>]], an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit [[Z19241|<u>first matching representation string from lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes an input of type [[Z6005|<u>Wikidata lexeme</u>]], and a second input which is a Typed list of [[Z6091|<u>Wikidata item reference</u>]], and returns a String.
* Locate the input selectors (shown in Figure 12).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (as shown in Figure 13), click on it. Your selection should then appear as in Figure 14.
* Enter the grammatical feature ''singular'' as follows:
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input selections should now appear as in Figure 15.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the [[Z6091|<u>Wikidata item reference</u>]], showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 16.
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling grammatical gender from Lexeme and (2) and (4) by calls to first matching representation string from lexeme.
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type Wikidata lexeme and returns a String.
* Locate the input selectors (shown in Figure 11). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as shown in Figure 2).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as shown in Figure 7).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 12).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire Wikidata lexeme as its second input; not just a reference to a lexeme. Knowing this, it produces a Wikidata lexeme reference for the selected lexeme, and also constructs a call that passes that reference to the function Fetch Wikidata lexeme. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at agree adjective with noun. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to grammatical gender from Lexeme and first matching representation string from lexeme.
3blh2t53q8zut1qxu3dlfhhnymmw12q
147101
147100
2024-12-19T05:01:04Z
DMartin (WMF)
24
/* Getting a lexeme form having given grammatical features */ Added 2 figures
147101
wikitext
text/x-wiki
{{Draft}}
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of [[Wikifunctions:Function model#Z7/Function calls|function calls]] that a user can step through on [https://www.wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
[[File:Lexeme form selector.png|thumb|Fig. 1. Lexeme form selector]]
[[File:Expanded view of a lexeme form.png|thumb|Fig. 6. Expanded view of lexeme form]]
Wikifunctions has capabilities for importing and using content from [[d:|Wikidata]]. There is a primary focus currently on [[d:Wikidata:Lexicographical data|lexicographic content]] (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
<gallery mode=packed heights=200px>
File:Lexeme form selector with "schoner".png|Fig. 2. Lexeme form selector with 2 choices showing
File:Lexeme form selector with "schoner" selected.png|Fig. 3. Lexeme form selector with "schöner" selected
File:Lexeme form reference for L6758-F4.png|Fig. 4. Lexeme form reference
File:Compact view of a lexeme form.png|Fig. 5. Compact view of lexeme form
</gallery>
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
[[File:Lexeme selector.png|thumb|Fig. 7. Lexeme selector]]
[[File:Lexeme selector showing several choices.png|thumb|Fig. 8. Lexeme selector showing several choices]]
Here we show how to compose a call to [[Z20616|<u>grammatical gender from Lexeme</u>]], an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property [[wikidata:Property:P5185|P5185/grammatical gender]].
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit [[Z20616|<u>grammatical gender from Lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6005|<u>Wikidata lexeme</u>]].
** Notice also that its output will be a Typed list of [[Z6091|<u>Wikidata item reference</u>]]. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 7). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 8), click on it. Your selection should then appear as in Figure 9.
* Click ''Run function''.
* The result should appear as shown in Figure 10. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a [[Z6091|<u>Wikidata item reference</u>]], which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the [[Z6091|<u>Wikidata item reference</u>]] for ''masculine)'' shown in Figure 11, containing the type and the Wikidata item ID <code>Q499327</code>.
<gallery mode=packed heights=200px>
File:Lexeme selector with "Hut" selected.png|Fig. 9. Lexeme selector with "Hut" selected
File:Compact view for a Wikidata item.png|Fig. 10. Compact view for a Wikidata item reference
File:Wikidata item reference for Q499327.png|Fig. 11. Wikidata item reference for the concept "masculine"
</gallery>
== Getting a lexeme form having given grammatical features ==
[[File:Two input selectors for a function.png|thumb|Fig. 12. Input selectors for the function]]
[[File:Lexeme selector showing choices for "schon".png|thumb|Fig. 13. Lexeme selector showing choices for "schon"]]
Here we show how to compose a call to [[Z19241|<u>first matching representation string from lexeme</u>]], an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit [[Z19241|<u>first matching representation string from lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes an input of type [[Z6005|<u>Wikidata lexeme</u>]], and a second input which is a Typed list of [[Z6091|<u>Wikidata item reference</u>]], and returns a String.
* Locate the input selectors (shown in Figure 12).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (the third choice shown in Figure 13), click on it. Your selection should then appear as in Figure 14.
* Enter the grammatical feature ''singular'' as follows:
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input selections should now appear as in Figure 15.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the [[Z6091|<u>Wikidata item reference</u>]], showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 16.
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling grammatical gender from Lexeme and (2) and (4) by calls to first matching representation string from lexeme.
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type Wikidata lexeme and returns a String.
* Locate the input selectors (shown in Figure 11). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as shown in Figure 2).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as shown in Figure 7).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 12).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire Wikidata lexeme as its second input; not just a reference to a lexeme. Knowing this, it produces a Wikidata lexeme reference for the selected lexeme, and also constructs a call that passes that reference to the function Fetch Wikidata lexeme. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at agree adjective with noun. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to grammatical gender from Lexeme and first matching representation string from lexeme.
owbslm82dvyygdi5din0dqawcsb161m
147111
147101
2024-12-19T05:13:30Z
DMartin (WMF)
24
/* Fetching a lexeme form from Wikidata */
147111
wikitext
text/x-wiki
{{Draft}}
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of [[Wikifunctions:Function model#Z7/Function calls|function calls]] that a user can step through on [https://www.wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
[[File:Lexeme form selector.png|thumb|Fig. 1. Lexeme form selector]]
[[File:Expanded view of a lexeme form.png|thumb|Fig. 6. Expanded view of lexeme form]]
Wikifunctions has capabilities for importing and using content from [[d:|Wikidata]]. There is a primary focus currently on [[d:Wikidata:Lexicographical data|lexicographic content]] (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
<gallery mode=packed heights=176px>
File:Lexeme form selector with "schoner".png|Fig. 2. Lexeme form selector with 2 choices showing
File:Lexeme form selector with "schoner" selected.png|Fig. 3. Lexeme form selector with "schöner" selected
File:Lexeme form reference for L6758-F4.png|Fig. 4. Lexeme form reference
File:Compact view of a lexeme form.png|Fig. 5. Compact view of lexeme form
</gallery>
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
[[File:Lexeme selector.png|thumb|Fig. 7. Lexeme selector]]
[[File:Lexeme selector showing several choices.png|thumb|Fig. 8. Lexeme selector showing several choices]]
Here we show how to compose a call to [[Z20616|<u>grammatical gender from Lexeme</u>]], an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property [[wikidata:Property:P5185|P5185/grammatical gender]].
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit [[Z20616|<u>grammatical gender from Lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6005|<u>Wikidata lexeme</u>]].
** Notice also that its output will be a Typed list of [[Z6091|<u>Wikidata item reference</u>]]. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 7). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 8), click on it. Your selection should then appear as in Figure 9.
* Click ''Run function''.
* The result should appear as shown in Figure 10. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a [[Z6091|<u>Wikidata item reference</u>]], which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the [[Z6091|<u>Wikidata item reference</u>]] for ''masculine)'' shown in Figure 11, containing the type and the Wikidata item ID <code>Q499327</code>.
<gallery mode=packed heights=200px>
File:Lexeme selector with "Hut" selected.png|Fig. 9. Lexeme selector with "Hut" selected
File:Compact view for a Wikidata item.png|Fig. 10. Compact view for a Wikidata item reference
File:Wikidata item reference for Q499327.png|Fig. 11. Wikidata item reference for the concept "masculine"
</gallery>
== Getting a lexeme form having given grammatical features ==
[[File:Two input selectors for a function.png|thumb|Fig. 12. Input selectors for the function]]
[[File:Lexeme selector showing choices for "schon".png|thumb|Fig. 13. Lexeme selector showing choices for "schon"]]
Here we show how to compose a call to [[Z19241|<u>first matching representation string from lexeme</u>]], an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit [[Z19241|<u>first matching representation string from lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes an input of type [[Z6005|<u>Wikidata lexeme</u>]], and a second input which is a Typed list of [[Z6091|<u>Wikidata item reference</u>]], and returns a String.
* Locate the input selectors (shown in Figure 12).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (the third choice shown in Figure 13), click on it. Your selection should then appear as in Figure 14.
* Enter the grammatical feature ''singular'' as follows:
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input selections should now appear as in Figure 15.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the [[Z6091|<u>Wikidata item reference</u>]], showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 16.
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling grammatical gender from Lexeme and (2) and (4) by calls to first matching representation string from lexeme.
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type Wikidata lexeme and returns a String.
* Locate the input selectors (shown in Figure 11). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as shown in Figure 2).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as shown in Figure 7).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 12).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire Wikidata lexeme as its second input; not just a reference to a lexeme. Knowing this, it produces a Wikidata lexeme reference for the selected lexeme, and also constructs a call that passes that reference to the function Fetch Wikidata lexeme. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at agree adjective with noun. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to grammatical gender from Lexeme and first matching representation string from lexeme.
g2rw0ad36pkexwfc2wi8y5qgvlagqut
147112
147111
2024-12-19T05:14:03Z
DMartin (WMF)
24
/* Calling the function */
147112
wikitext
text/x-wiki
{{Draft}}
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of [[Wikifunctions:Function model#Z7/Function calls|function calls]] that a user can step through on [https://www.wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
[[File:Lexeme form selector.png|thumb|Fig. 1. Lexeme form selector]]
[[File:Expanded view of a lexeme form.png|thumb|Fig. 6. Expanded view of lexeme form]]
Wikifunctions has capabilities for importing and using content from [[d:|Wikidata]]. There is a primary focus currently on [[d:Wikidata:Lexicographical data|lexicographic content]] (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
<gallery mode=packed heights=176px>
File:Lexeme form selector with "schoner".png|Fig. 2. Lexeme form selector with 2 choices showing
File:Lexeme form selector with "schoner" selected.png|Fig. 3. Lexeme form selector with "schöner" selected
File:Lexeme form reference for L6758-F4.png|Fig. 4. Lexeme form reference
File:Compact view of a lexeme form.png|Fig. 5. Compact view of lexeme form
</gallery>
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
[[File:Lexeme selector.png|thumb|Fig. 7. Lexeme selector]]
[[File:Lexeme selector showing several choices.png|thumb|Fig. 8. Lexeme selector showing several choices]]
Here we show how to compose a call to [[Z20616|<u>grammatical gender from Lexeme</u>]], an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property [[wikidata:Property:P5185|P5185/grammatical gender]].
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit [[Z20616|<u>grammatical gender from Lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6005|<u>Wikidata lexeme</u>]].
** Notice also that its output will be a Typed list of [[Z6091|<u>Wikidata item reference</u>]]. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 7). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 8), click on it. Your selection should then appear as in Figure 9.
* Click ''Run function''.
* The result should appear as shown in Figure 10. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a [[Z6091|<u>Wikidata item reference</u>]], which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the [[Z6091|<u>Wikidata item reference</u>]] for ''masculine)'' shown in Figure 11, containing the type and the Wikidata item ID <code>Q499327</code>.
<gallery mode=packed heights=176px>
File:Lexeme selector with "Hut" selected.png|Fig. 9. Lexeme selector with "Hut" selected
File:Compact view for a Wikidata item.png|Fig. 10. Compact view for a Wikidata item reference
File:Wikidata item reference for Q499327.png|Fig. 11. Wikidata item reference for the concept "masculine"
</gallery>
== Getting a lexeme form having given grammatical features ==
[[File:Two input selectors for a function.png|thumb|Fig. 12. Input selectors for the function]]
[[File:Lexeme selector showing choices for "schon".png|thumb|Fig. 13. Lexeme selector showing choices for "schon"]]
Here we show how to compose a call to [[Z19241|<u>first matching representation string from lexeme</u>]], an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit [[Z19241|<u>first matching representation string from lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes an input of type [[Z6005|<u>Wikidata lexeme</u>]], and a second input which is a Typed list of [[Z6091|<u>Wikidata item reference</u>]], and returns a String.
* Locate the input selectors (shown in Figure 12).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (the third choice shown in Figure 13), click on it. Your selection should then appear as in Figure 14.
* Enter the grammatical feature ''singular'' as follows:
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input selections should now appear as in Figure 15.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the [[Z6091|<u>Wikidata item reference</u>]], showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 16.
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling grammatical gender from Lexeme and (2) and (4) by calls to first matching representation string from lexeme.
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type Wikidata lexeme and returns a String.
* Locate the input selectors (shown in Figure 11). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as shown in Figure 2).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as shown in Figure 7).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 12).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire Wikidata lexeme as its second input; not just a reference to a lexeme. Knowing this, it produces a Wikidata lexeme reference for the selected lexeme, and also constructs a call that passes that reference to the function Fetch Wikidata lexeme. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at agree adjective with noun. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to grammatical gender from Lexeme and first matching representation string from lexeme.
ddtef4vn4t4u5iozys2yporzegqpyc1
147114
147112
2024-12-19T05:32:24Z
DMartin (WMF)
24
/* Getting a lexeme form having given grammatical features */ added 3 more figures
147114
wikitext
text/x-wiki
{{Draft}}
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of [[Wikifunctions:Function model#Z7/Function calls|function calls]] that a user can step through on [https://www.wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
[[File:Lexeme form selector.png|thumb|Fig. 1. Lexeme form selector]]
[[File:Expanded view of a lexeme form.png|thumb|Fig. 6. Expanded view of lexeme form]]
Wikifunctions has capabilities for importing and using content from [[d:|Wikidata]]. There is a primary focus currently on [[d:Wikidata:Lexicographical data|lexicographic content]] (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
<gallery mode=packed heights=176px>
File:Lexeme form selector with "schoner".png|Fig. 2. Lexeme form selector with 2 choices showing
File:Lexeme form selector with "schoner" selected.png|Fig. 3. Lexeme form selector with "schöner" selected
File:Lexeme form reference for L6758-F4.png|Fig. 4. Lexeme form reference
File:Compact view of a lexeme form.png|Fig. 5. Compact view of lexeme form
</gallery>
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
[[File:Lexeme selector.png|thumb|Fig. 7. Lexeme selector]]
[[File:Lexeme selector showing several choices.png|thumb|Fig. 8. Lexeme selector showing several choices]]
Here we show how to compose a call to [[Z20616|<u>grammatical gender from Lexeme</u>]], an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property [[wikidata:Property:P5185|P5185/grammatical gender]].
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit [[Z20616|<u>grammatical gender from Lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6005|<u>Wikidata lexeme</u>]].
** Notice also that its output will be a Typed list of [[Z6091|<u>Wikidata item reference</u>]]. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 7). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 8), click on it. Your selection should then appear as in Figure 9.
* Click ''Run function''.
* The result should appear as shown in Figure 10. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a [[Z6091|<u>Wikidata item reference</u>]], which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the [[Z6091|<u>Wikidata item reference</u>]] for ''masculine)'' shown in Figure 11, containing the type and the Wikidata item ID <code>Q499327</code>.
<gallery mode=packed heights=176px>
File:Lexeme selector with "Hut" selected.png|Fig. 9. Lexeme selector with "Hut" selected
File:Compact view for a Wikidata item.png|Fig. 10. Compact view for a Wikidata item reference
File:Wikidata item reference for Q499327.png|Fig. 11. Wikidata item reference for the concept "masculine"
</gallery>
== Getting a lexeme form having given grammatical features ==
[[File:Two input selectors for a function.png|thumb|Fig. 12. Input selectors for the function]]
[[File:Lexeme selector showing choices for "schon".png|thumb|Fig. 13. Lexeme selector showing choices for "schon"]]
Here we show how to compose a call to [[Z19241|<u>first matching representation string from lexeme</u>]], an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit [[Z19241|<u>first matching representation string from lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes an input of type [[Z6005|<u>Wikidata lexeme</u>]], and a second input which is a Typed list of [[Z6091|<u>Wikidata item reference</u>]], and returns a String.
* Locate the input selectors (shown in Figure 12).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (the third choice shown in Figure 13), click on it. Your selection should then appear as in Figure 14.
* Enter the grammatical feature ''singular'' as follows:
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input selections should now appear as in Figure 15.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the [[Z6091|<u>Wikidata item reference</u>]], showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 16.
<gallery mode=packed heights=200px>
File:Two input selectors with "schon" selected in the first.png|Fig. 14. "schon" selected in the first input selector
File:Two input selectors with selections made.png|Fig. 15. Selections ready for the function call
File:Function call result- "schoner".png|Fig. 16. Function call result, a string
</gallery>
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling grammatical gender from Lexeme and (2) and (4) by calls to first matching representation string from lexeme.
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type Wikidata lexeme and returns a String.
* Locate the input selectors (shown in Figure 11). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as shown in Figure 2).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as shown in Figure 7).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 12).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire Wikidata lexeme as its second input; not just a reference to a lexeme. Knowing this, it produces a Wikidata lexeme reference for the selected lexeme, and also constructs a call that passes that reference to the function Fetch Wikidata lexeme. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at agree adjective with noun. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to grammatical gender from Lexeme and first matching representation string from lexeme.
69aamcyppc7v0ke92858njnt1i7lahn
147115
147114
2024-12-19T05:44:06Z
DMartin (WMF)
24
/* Generating a phrase with agreement */ Added some formatting and links
147115
wikitext
text/x-wiki
{{Draft}}
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of [[Wikifunctions:Function model#Z7/Function calls|function calls]] that a user can step through on [https://www.wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
[[File:Lexeme form selector.png|thumb|Fig. 1. Lexeme form selector]]
[[File:Expanded view of a lexeme form.png|thumb|Fig. 6. Expanded view of lexeme form]]
Wikifunctions has capabilities for importing and using content from [[d:|Wikidata]]. There is a primary focus currently on [[d:Wikidata:Lexicographical data|lexicographic content]] (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
<gallery mode=packed heights=176px>
File:Lexeme form selector with "schoner".png|Fig. 2. Lexeme form selector with 2 choices showing
File:Lexeme form selector with "schoner" selected.png|Fig. 3. Lexeme form selector with "schöner" selected
File:Lexeme form reference for L6758-F4.png|Fig. 4. Lexeme form reference
File:Compact view of a lexeme form.png|Fig. 5. Compact view of lexeme form
</gallery>
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
[[File:Lexeme selector.png|thumb|Fig. 7. Lexeme selector]]
[[File:Lexeme selector showing several choices.png|thumb|Fig. 8. Lexeme selector showing several choices]]
Here we show how to compose a call to [[Z20616|<u>grammatical gender from Lexeme</u>]], an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property [[wikidata:Property:P5185|P5185/grammatical gender]].
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit [[Z20616|<u>grammatical gender from Lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6005|<u>Wikidata lexeme</u>]].
** Notice also that its output will be a Typed list of [[Z6091|<u>Wikidata item reference</u>]]. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 7). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 8), click on it. Your selection should then appear as in Figure 9.
* Click ''Run function''.
* The result should appear as shown in Figure 10. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a [[Z6091|<u>Wikidata item reference</u>]], which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the [[Z6091|<u>Wikidata item reference</u>]] for ''masculine)'' shown in Figure 11, containing the type and the Wikidata item ID <code>Q499327</code>.
<gallery mode=packed heights=176px>
File:Lexeme selector with "Hut" selected.png|Fig. 9. Lexeme selector with "Hut" selected
File:Compact view for a Wikidata item.png|Fig. 10. Compact view for a Wikidata item reference
File:Wikidata item reference for Q499327.png|Fig. 11. Wikidata item reference for the concept "masculine"
</gallery>
== Getting a lexeme form having given grammatical features ==
[[File:Two input selectors for a function.png|thumb|Fig. 12. Input selectors for the function]]
[[File:Lexeme selector showing choices for "schon".png|thumb|Fig. 13. Lexeme selector showing choices for "schon"]]
Here we show how to compose a call to [[Z19241|<u>first matching representation string from lexeme</u>]], an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit [[Z19241|<u>first matching representation string from lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes an input of type [[Z6005|<u>Wikidata lexeme</u>]], and a second input which is a Typed list of [[Z6091|<u>Wikidata item reference</u>]], and returns a String.
* Locate the input selectors (shown in Figure 12).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (the third choice shown in Figure 13), click on it. Your selection should then appear as in Figure 14.
* Enter the grammatical feature ''singular'' as follows:
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input selections should now appear as in Figure 15.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the [[Z6091|<u>Wikidata item reference</u>]], showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 16.
<gallery mode=packed heights=200px>
File:Two input selectors with "schon" selected in the first.png|Fig. 14. "schon" selected in the first input selector
File:Two input selectors with selections made.png|Fig. 15. Selections ready for the function call
File:Function call result- "schoner".png|Fig. 16. Function call result, a string
</gallery>
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling [[Z20616|<u>grammatical gender from Lexeme</u>]] and (2) and (4) by calls to [[Z19241|<u>first matching representation string from lexeme</u>]].
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type [[Z6005|<u>Wikidata lexeme</u>]] and returns a String.
* Locate the input selectors (shown in Figure 11). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as shown in Figure 2).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as shown in Figure 7).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 12).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire [[Z6005|<u>Wikidata lexeme</u>]] as its second input; not just a reference to a lexeme. Knowing this, it produces a [[Z6095|<u>Wikidata lexeme reference</u>]] for the selected lexeme, and also constructs a call that passes that reference to the function [[Z6825|<u>Fetch Wikidata lexeme</u>]]. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at [[Z20615|<u>agree adjective with noun</u>]]. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to [[Z20616|<u>grammatical gender from Lexeme</u>]] and [[Z19241|<u>first matching representation string from lexeme</u>]].
d82z5p5dafersh2fbrgl4wwfoogblyt
147116
147115
2024-12-19T05:51:46Z
DMartin (WMF)
24
/* Calling the function */
147116
wikitext
text/x-wiki
{{Draft}}
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of [[Wikifunctions:Function model#Z7/Function calls|function calls]] that a user can step through on [https://www.wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
[[File:Lexeme form selector.png|thumb|Fig. 1. Lexeme form selector]]
[[File:Expanded view of a lexeme form.png|thumb|Fig. 6. Expanded view of lexeme form]]
Wikifunctions has capabilities for importing and using content from [[d:|Wikidata]]. There is a primary focus currently on [[d:Wikidata:Lexicographical data|lexicographic content]] (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
<gallery mode=packed heights=176px>
File:Lexeme form selector with "schoner".png|Fig. 2. Lexeme form selector with 2 choices showing
File:Lexeme form selector with "schoner" selected.png|Fig. 3. Lexeme form selector with "schöner" selected
File:Lexeme form reference for L6758-F4.png|Fig. 4. Lexeme form reference
File:Compact view of a lexeme form.png|Fig. 5. Compact view of lexeme form
</gallery>
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
[[File:Lexeme selector.png|thumb|Fig. 7. Lexeme selector]]
[[File:Lexeme selector showing several choices.png|thumb|Fig. 8. Lexeme selector showing several choices]]
Here we show how to compose a call to [[Z20616|<u>grammatical gender from Lexeme</u>]], an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property [[wikidata:Property:P5185|P5185/grammatical gender]].
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit [[Z20616|<u>grammatical gender from Lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6005|<u>Wikidata lexeme</u>]].
** Notice also that its output will be a Typed list of [[Z6091|<u>Wikidata item reference</u>]]. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 7). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 8), click on it. Your selection should then appear as in Figure 9.
* Click ''Run function''.
* The result should appear as shown in Figure 10. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a [[Z6091|<u>Wikidata item reference</u>]], which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the [[Z6091|<u>Wikidata item reference</u>]] for ''masculine)'' shown in Figure 11, containing the type and the Wikidata item ID <code>Q499327</code>.
<gallery mode=packed heights=176px>
File:Lexeme selector with "Hut" selected.png|Fig. 9. Lexeme selector with "Hut" selected
File:Compact view for a Wikidata item.png|Fig. 10. Compact view for a Wikidata item reference
File:Wikidata item reference for Q499327.png|Fig. 11. Wikidata item reference for the concept "masculine"
</gallery>
== Getting a lexeme form having given grammatical features ==
[[File:Two input selectors for a function.png|thumb|Fig. 12. Input selectors for the function]]
[[File:Lexeme selector showing choices for "schon".png|thumb|Fig. 13. Lexeme selector showing choices for "schon"]]
Here we show how to compose a call to [[Z19241|<u>first matching representation string from lexeme</u>]], an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit [[Z19241|<u>first matching representation string from lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes an input of type [[Z6005|<u>Wikidata lexeme</u>]], and a second input which is a Typed list of [[Z6091|<u>Wikidata item reference</u>]], and returns a String.
* Locate the input selectors (shown in Figure 12).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (the third choice shown in Figure 13), click on it. Your selection should then appear as in Figure 14.
* Enter the grammatical feature ''singular'' as follows:
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input selections should now appear as in Figure 15.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the [[Z6091|<u>Wikidata item reference</u>]], showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 16.
<gallery mode=packed heights=200px>
File:Two input selectors with "schon" selected in the first.png|Fig. 14. "schon" selected in the first input selector
File:Two input selectors with selections made.png|Fig. 15. Selections ready for the function call
File:Function call result- "schoner".png|Fig. 16. Function call result, a string
</gallery>
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling [[Z20616|<u>grammatical gender from Lexeme</u>]] and (2) and (4) by calls to [[Z19241|<u>first matching representation string from lexeme</u>]].
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type [[Z6005|<u>Wikidata lexeme</u>]] and returns a String.
* Locate the input selectors (shown in Figure 17). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as was shown in Figure 8).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as was shown in Figure 13).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 18).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire [[Z6005|<u>Wikidata lexeme</u>]] as its second input; not just a reference to a lexeme. Knowing this, it produces a [[Z6095|<u>Wikidata lexeme reference</u>]] for the selected lexeme, and also constructs a call that passes that reference to the function [[Z6825|<u>Fetch Wikidata lexeme</u>]]. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at [[Z20615|<u>agree adjective with noun</u>]]. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to [[Z20616|<u>grammatical gender from Lexeme</u>]] and [[Z19241|<u>first matching representation string from lexeme</u>]].
d3vz6ppk24bol2cfiuupjpsab0zqgfi
147117
147116
2024-12-19T05:58:51Z
DMartin (WMF)
24
/* Calling the function */ added two figures
147117
wikitext
text/x-wiki
{{Draft}}
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of [[Wikifunctions:Function model#Z7/Function calls|function calls]] that a user can step through on [https://www.wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
[[File:Lexeme form selector.png|thumb|Fig. 1. Lexeme form selector]]
[[File:Expanded view of a lexeme form.png|thumb|Fig. 6. Expanded view of lexeme form]]
Wikifunctions has capabilities for importing and using content from [[d:|Wikidata]]. There is a primary focus currently on [[d:Wikidata:Lexicographical data|lexicographic content]] (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
<gallery mode=packed heights=176px>
File:Lexeme form selector with "schoner".png|Fig. 2. Lexeme form selector with 2 choices showing
File:Lexeme form selector with "schoner" selected.png|Fig. 3. Lexeme form selector with "schöner" selected
File:Lexeme form reference for L6758-F4.png|Fig. 4. Lexeme form reference
File:Compact view of a lexeme form.png|Fig. 5. Compact view of lexeme form
</gallery>
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
[[File:Lexeme selector.png|thumb|Fig. 7. Lexeme selector]]
[[File:Lexeme selector showing several choices.png|thumb|Fig. 8. Lexeme selector showing several choices]]
Here we show how to compose a call to [[Z20616|<u>grammatical gender from Lexeme</u>]], an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property [[wikidata:Property:P5185|P5185/grammatical gender]].
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit [[Z20616|<u>grammatical gender from Lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6005|<u>Wikidata lexeme</u>]].
** Notice also that its output will be a Typed list of [[Z6091|<u>Wikidata item reference</u>]]. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 7). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 8), click on it. Your selection should then appear as in Figure 9.
* Click ''Run function''.
* The result should appear as shown in Figure 10. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a [[Z6091|<u>Wikidata item reference</u>]], which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the [[Z6091|<u>Wikidata item reference</u>]] for ''masculine)'' shown in Figure 11, containing the type and the Wikidata item ID <code>Q499327</code>.
<gallery mode=packed heights=176px>
File:Lexeme selector with "Hut" selected.png|Fig. 9. Lexeme selector with "Hut" selected
File:Compact view for a Wikidata item.png|Fig. 10. Compact view for a Wikidata item reference
File:Wikidata item reference for Q499327.png|Fig. 11. Wikidata item reference for the concept "masculine"
</gallery>
== Getting a lexeme form having given grammatical features ==
[[File:Two input selectors for a function.png|thumb|Fig. 12. Input selectors for the function]]
[[File:Lexeme selector showing choices for "schon".png|thumb|Fig. 13. Lexeme selector showing choices for "schon"]]
Here we show how to compose a call to [[Z19241|<u>first matching representation string from lexeme</u>]], an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct word-form in various language generation tasks.
=== '''Calling the function''' ===
* Visit [[Z19241|<u>first matching representation string from lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes an input of type [[Z6005|<u>Wikidata lexeme</u>]], and a second input which is a Typed list of [[Z6091|<u>Wikidata item reference</u>]], and returns a String.
* Locate the input selectors (shown in Figure 12).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (the third choice shown in Figure 13), click on it. Your selection should then appear as in Figure 14.
* Enter the grammatical feature ''singular'' as follows:
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input selections should now appear as in Figure 15.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the [[Z6091|<u>Wikidata item reference</u>]], showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 16.
<gallery mode=packed heights=200px>
File:Two input selectors with "schon" selected in the first.png|Fig. 14. "schon" selected in the first input selector
File:Two input selectors with selections made.png|Fig. 15. Selections ready for the function call
File:Function call result- "schoner".png|Fig. 16. Function call result, a string
</gallery>
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling [[Z20616|<u>grammatical gender from Lexeme</u>]] and (2) and (4) by calls to [[Z19241|<u>first matching representation string from lexeme</u>]].
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
[[File:Two lexeme selectors for a function.png|thumb|Fig. 17. Lexeme selectors for noun and adjective inputs]]
[[File:Function call produced by a lexeme selector.png|thumb|Fig. 18. Function call produced by lexeme selector]]
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type [[Z6005|<u>Wikidata lexeme</u>]] and returns a String.
* Locate the input selectors (shown in Figure 17). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as was shown in Figure 8).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as was shown in Figure 13).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 18).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire [[Z6005|<u>Wikidata lexeme</u>]] as its second input; not just a reference to a lexeme. Knowing this, it produces a [[Z6095|<u>Wikidata lexeme reference</u>]] for the selected lexeme, and also constructs a call that passes that reference to the function [[Z6825|<u>Fetch Wikidata lexeme</u>]]. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at [[Z20615|<u>agree adjective with noun</u>]]. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to [[Z20616|<u>grammatical gender from Lexeme</u>]] and [[Z19241|<u>first matching representation string from lexeme</u>]].
e93tsjwcbsikld0e4j0i24306wyhilc
147118
147117
2024-12-19T06:23:34Z
DMartin (WMF)
24
/* Getting a lexeme form having given grammatical features */
147118
wikitext
text/x-wiki
{{Draft}}
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of [[Wikifunctions:Function model#Z7/Function calls|function calls]] that a user can step through on [https://www.wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
[[File:Lexeme form selector.png|thumb|Fig. 1. Lexeme form selector]]
[[File:Expanded view of a lexeme form.png|thumb|Fig. 6. Expanded view of lexeme form]]
Wikifunctions has capabilities for importing and using content from [[d:|Wikidata]]. There is a primary focus currently on [[d:Wikidata:Lexicographical data|lexicographic content]] (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
<gallery mode=packed heights=176px>
File:Lexeme form selector with "schoner".png|Fig. 2. Lexeme form selector with 2 choices showing
File:Lexeme form selector with "schoner" selected.png|Fig. 3. Lexeme form selector with "schöner" selected
File:Lexeme form reference for L6758-F4.png|Fig. 4. Lexeme form reference
File:Compact view of a lexeme form.png|Fig. 5. Compact view of lexeme form
</gallery>
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
[[File:Lexeme selector.png|thumb|Fig. 7. Lexeme selector]]
[[File:Lexeme selector showing several choices.png|thumb|Fig. 8. Lexeme selector showing several choices]]
Here we show how to compose a call to [[Z20616|<u>grammatical gender from Lexeme</u>]], an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property [[wikidata:Property:P5185|P5185/grammatical gender]].
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit [[Z20616|<u>grammatical gender from Lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6005|<u>Wikidata lexeme</u>]].
** Notice also that its output will be a Typed list of [[Z6091|<u>Wikidata item reference</u>]]. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 7). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 8), click on it. Your selection should then appear as in Figure 9.
* Click ''Run function''.
* The result should appear as shown in Figure 10. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a [[Z6091|<u>Wikidata item reference</u>]], which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the [[Z6091|<u>Wikidata item reference</u>]] for ''masculine)'' shown in Figure 11, containing the type and the Wikidata item ID <code>Q499327</code>.
<gallery mode=packed heights=176px>
File:Lexeme selector with "Hut" selected.png|Fig. 9. Lexeme selector with "Hut" selected
File:Compact view for a Wikidata item.png|Fig. 10. Compact view for a Wikidata item reference
File:Wikidata item reference for Q499327.png|Fig. 11. Wikidata item reference for the concept "masculine"
</gallery>
== Getting a word form having given grammatical features ==
[[File:Two input selectors for a function.png|thumb|Fig. 12. Input selectors for the function]]
[[File:Lexeme selector showing choices for "schon".png|thumb|Fig. 13. Lexeme selector showing choices for "schon"]]
Here we show how to compose a call to [[Z19241|<u>first matching representation string from lexeme</u>]], an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct lexeme form (or its representation) in various language generation tasks.
=== '''Calling the function''' ===
* Visit [[Z19241|<u>first matching representation string from lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes an input of type [[Z6005|<u>Wikidata lexeme</u>]], and a second input which is a Typed list of [[Z6091|<u>Wikidata item reference</u>]], and returns a String.
* Locate the input selectors (shown in Figure 12).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schone”.
* When you see the choice for ''schön; German, adjective'' (the third choice shown in Figure 13), click on it. Your selection should then appear as in Figure 14.
* Enter the grammatical feature ''singular'' as follows:
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the Wikidata item reference for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input selections should now appear as in Figure 15.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the [[Z6091|<u>Wikidata item reference</u>]], showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 16.
<gallery mode=packed heights=200px>
File:Two input selectors with "schon" selected in the first.png|Fig. 14. "schon" selected in the first input selector
File:Two input selectors with selections made.png|Fig. 15. Selections ready for the function call
File:Function call result- "schoner".png|Fig. 16. Function call result, a string
</gallery>
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling [[Z20616|<u>grammatical gender from Lexeme</u>]] and (2) and (4) by calls to [[Z19241|<u>first matching representation string from lexeme</u>]].
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
[[File:Two lexeme selectors for a function.png|thumb|Fig. 17. Lexeme selectors for noun and adjective inputs]]
[[File:Function call produced by a lexeme selector.png|thumb|Fig. 18. Function call produced by lexeme selector]]
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type [[Z6005|<u>Wikidata lexeme</u>]] and returns a String.
* Locate the input selectors (shown in Figure 17). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as was shown in Figure 8).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as was shown in Figure 13).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 18).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire [[Z6005|<u>Wikidata lexeme</u>]] as its second input; not just a reference to a lexeme. Knowing this, it produces a [[Z6095|<u>Wikidata lexeme reference</u>]] for the selected lexeme, and also constructs a call that passes that reference to the function [[Z6825|<u>Fetch Wikidata lexeme</u>]]. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at [[Z20615|<u>agree adjective with noun</u>]]. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to [[Z20616|<u>grammatical gender from Lexeme</u>]] and [[Z19241|<u>first matching representation string from lexeme</u>]].
gmee5rxb9zmghfi5wcxf8q51ye8i4fq
147119
147118
2024-12-19T06:25:56Z
DMartin (WMF)
24
/* Calling the function */
147119
wikitext
text/x-wiki
{{Draft}}
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of [[Wikifunctions:Function model#Z7/Function calls|function calls]] that a user can step through on [https://www.wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
[[File:Lexeme form selector.png|thumb|Fig. 1. Lexeme form selector]]
[[File:Expanded view of a lexeme form.png|thumb|Fig. 6. Expanded view of lexeme form]]
Wikifunctions has capabilities for importing and using content from [[d:|Wikidata]]. There is a primary focus currently on [[d:Wikidata:Lexicographical data|lexicographic content]] (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
<gallery mode=packed heights=176px>
File:Lexeme form selector with "schoner".png|Fig. 2. Lexeme form selector with 2 choices showing
File:Lexeme form selector with "schoner" selected.png|Fig. 3. Lexeme form selector with "schöner" selected
File:Lexeme form reference for L6758-F4.png|Fig. 4. Lexeme form reference
File:Compact view of a lexeme form.png|Fig. 5. Compact view of lexeme form
</gallery>
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
[[File:Lexeme selector.png|thumb|Fig. 7. Lexeme selector]]
[[File:Lexeme selector showing several choices.png|thumb|Fig. 8. Lexeme selector showing several choices]]
Here we show how to compose a call to [[Z20616|<u>grammatical gender from Lexeme</u>]], an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property [[wikidata:Property:P5185|P5185/grammatical gender]].
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit [[Z20616|<u>grammatical gender from Lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6005|<u>Wikidata lexeme</u>]].
** Notice also that its output will be a Typed list of [[Z6091|<u>Wikidata item reference</u>]]. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 7). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 8), click on it. Your selection should then appear as in Figure 9.
* Click ''Run function''.
* The result should appear as shown in Figure 10. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a [[Z6091|<u>Wikidata item reference</u>]], which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the [[Z6091|<u>Wikidata item reference</u>]] for ''masculine)'' shown in Figure 11, containing the type and the Wikidata item ID <code>Q499327</code>.
<gallery mode=packed heights=176px>
File:Lexeme selector with "Hut" selected.png|Fig. 9. Lexeme selector with "Hut" selected
File:Compact view for a Wikidata item.png|Fig. 10. Compact view for a Wikidata item reference
File:Wikidata item reference for Q499327.png|Fig. 11. Wikidata item reference for the concept "masculine"
</gallery>
== Getting a word form having given grammatical features ==
[[File:Two input selectors for a function.png|thumb|Fig. 12. Input selectors for the function]]
[[File:Lexeme selector showing choices for "schon".png|thumb|Fig. 13. Lexeme selector showing choices for "schon"]]
Here we show how to compose a call to [[Z19241|<u>first matching representation string from lexeme</u>]], an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct lexeme form (or its representation) in various language generation tasks.
=== '''Calling the function''' ===
* Visit [[Z19241|<u>first matching representation string from lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes an input of type [[Z6005|<u>Wikidata lexeme</u>]], and a second input which is a Typed list of [[Z6091|<u>Wikidata item reference</u>]], and returns a String.
* Locate the input selectors (shown in Figure 12).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schon”.
* When you see the choice for ''schön; German, adjective'' (the third choice shown in Figure 13), click on it. Your selection should then appear as in Figure 14.
* Enter the grammatical feature ''singular'' as follows:
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the [[Z6091|<u>Wikidata item reference</u>]] for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input selections should now appear as in Figure 15.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the [[Z6091|<u>Wikidata item reference</u>]], showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 16.
<gallery mode=packed heights=200px>
File:Two input selectors with "schon" selected in the first.png|Fig. 14. "schon" selected in the first input selector
File:Two input selectors with selections made.png|Fig. 15. Selections ready for the function call
File:Function call result- "schoner".png|Fig. 16. Function call result, a string
</gallery>
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling [[Z20616|<u>grammatical gender from Lexeme</u>]] and (2) and (4) by calls to [[Z19241|<u>first matching representation string from lexeme</u>]].
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
[[File:Two lexeme selectors for a function.png|thumb|Fig. 17. Lexeme selectors for noun and adjective inputs]]
[[File:Function call produced by a lexeme selector.png|thumb|Fig. 18. Function call produced by lexeme selector]]
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type [[Z6005|<u>Wikidata lexeme</u>]] and returns a String.
* Locate the input selectors (shown in Figure 17). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as was shown in Figure 8).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as was shown in Figure 13).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 18).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire [[Z6005|<u>Wikidata lexeme</u>]] as its second input; not just a reference to a lexeme. Knowing this, it produces a [[Z6095|<u>Wikidata lexeme reference</u>]] for the selected lexeme, and also constructs a call that passes that reference to the function [[Z6825|<u>Fetch Wikidata lexeme</u>]]. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at [[Z20615|<u>agree adjective with noun</u>]]. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to [[Z20616|<u>grammatical gender from Lexeme</u>]] and [[Z19241|<u>first matching representation string from lexeme</u>]].
q6afph5oe5wr8dd5em8ce7t2sybvn7z
147120
147119
2024-12-19T06:29:06Z
DMartin (WMF)
24
/* Calling the function */
147120
wikitext
text/x-wiki
{{Draft}}
This page provides a tutorial-style introduction to the Wikidata concepts and UI elements that are also presented (more technically) in [[Wikifunctions:Support for Wikidata content|Support for Wikidata content]]. It describes a series of [[Wikifunctions:Function model#Z7/Function calls|function calls]] that a user can step through on [https://www.wikifunctions.org Wikifunctions.org], with figures and explanations.
= Getting acquainted with Wikidata content on Wikifunctions =
[[File:Lexeme form selector.png|thumb|Fig. 1. Lexeme form selector]]
[[File:Expanded view of a lexeme form.png|thumb|Fig. 6. Expanded view of lexeme form]]
Wikifunctions has capabilities for importing and using content from [[d:|Wikidata]]. There is a primary focus currently on [[d:Wikidata:Lexicographical data|lexicographic content]] (lexemes, lexeme forms, and lexeme senses), but also some support for using items, properties, and statements. These capabilities are evolving.
Detailed documentation of the lexicographic types can be found at [[wikidata:Wikidata:Lexicographical_data/Documentation|Wikidata:Lexicographical data/Documentation]].
== Fetching a lexeme form from Wikidata ==
Wikidata content is never stored persistently on Wikifunctions, but is retrieved from Wikidata when needed, using fetch functions. Here we show how to call a fetch function, [[Z6824|<u>Fetch Wikidata lexeme form</u>]], and examine the content that it returns. We are going to fetch the lexeme form for the German adjective ''schöner,'' which is the singular masculine form of ''schön'' (beautiful).
=== '''Calling the function''' ===
* Visit [[Z6824|<u>Fetch Wikidata lexeme form</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6094|<u>Wikidata lexeme form reference</u>]], and returns a [[Z6004|<u>Wikidata lexeme form</u>]].
* Locate the ''lexeme form selector'' for entering the input value (shown in Figure 1). In the box with the (red, green, and blue-striped) Wikidata icon, type in the letters of the word “schoner”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexeme forms that match the letters typed in.
* When you see the choice ''schöner; singular, nominative case, strong inflection, positive, masculine for: schön (L6758), German, adjective'' (as shown in Figure 2), click on it. Your selection should then appear as in Figure 3.
* Click on the chevron (which looks like ‘>’).
** Notice that it reveals a simple structure, a [[Z6094|<u>Wikidata lexeme form reference</u>]], as shown in Figure 4, with just the type and the Wikidata ID <code>L6758-F4</code>. This is the ID of the lexeme form that’s been selected.
* Click ''Run function''.
** Using the ID <code>L6758-F4</code>,Wikifunctions retrieves the content of the lexeme form from Wikidata and transforms it into a form that’s usable on Wikifunctions, which is an instance of [[Z6004|<u>Wikidata lexeme form</u>]].
* The result should appear as shown in Figure 5. This shows the ''compact view'' for the lexeme form. For readability, the compact view includes just the Wikidata icon and the word ''schöner'' (which also provides a link to the Wikidata page from which this item has been fetched).
* Try clicking on the chevron to the left of ''schöner''. You will see that it reveals an expanded view of the content (as shown in Figure 6). An instance of Wikidata lexeme form has 6 parts, which can be seen in the expanded view: ''type'', ''identity'', ''lexeme'', ''representations'', ''grammatical features'', and ''claims''. (Figure F omits the details of the ''claims'' part.) Here we are concerned with the ''lexeme'', ''representations'', and ''grammatical features'' (which will be relevant to the examples below.).
** The ''lexeme'', shown in its collapsed view as ''schön,'' simply indicates the lexeme that this lexeme form belongs to''.''
** The ''representations'' (of which there is usually just one) are the actual word-forms recorded by the lexeme form; ''schöner'' in this case.
** The ''grammatical features'' are characteristics of this particular lexeme form, such as ''singular'' and ''masculine''.
* By clicking on any of the chevrons that appear in the expanded view, you can learn more about how that part is represented in Wikifunctions. For example, the value of ''lexeme'' is represented as a [[Z6095|<u>Wikidata lexeme reference</u>]], and each value in the ''grammatical features'' list is represented as a [[Z6091|<u>Wikidata item reference</u>]].
<gallery mode=packed heights=176px>
File:Lexeme form selector with "schoner".png|Fig. 2. Lexeme form selector with 2 choices showing
File:Lexeme form selector with "schoner" selected.png|Fig. 3. Lexeme form selector with "schöner" selected
File:Lexeme form reference for L6758-F4.png|Fig. 4. Lexeme form reference
File:Compact view of a lexeme form.png|Fig. 5. Compact view of lexeme form
</gallery>
= Generating phrases with agreement =
As explained in the [[Wikifunctions:Status updates/2024-10-25|Status update for 2024-10-25]], ''agreement'' means that one word or phrase has to change in order to match another word or phrase in a given sentence. For example, in German, the noun ''Hut'' (hat) is masculine, so an adjective that modifies it must take the masculine form, such as ''schöner'' (beautiful). ''Katze'' (cat) is feminine, so the same adjective would take the form ''schöne.''
Suppose we want to generate an adjective+noun phrase, for a singular noun, in a language that has gendered nouns. We show here that lexicographic content from Wikidata can be used to select an adjective form that agrees with the gender and plurality features of the noun that it modifies. To show this, we first compose calls to two existing functions that provide essential building blocks for generating this sort of phrase:
* a function that returns the gender of a given noun, and
* a function that returns the form of a given adjective that agrees with both that gender and the singular feature.
We then compose a call to another function that builds on the above two functions to generate a simple phrase with agreement.
== Getting the value of a statement in a lexeme ==
[[File:Lexeme selector.png|thumb|Fig. 7. Lexeme selector]]
[[File:Lexeme selector showing several choices.png|thumb|Fig. 8. Lexeme selector showing several choices]]
Here we show how to compose a call to [[Z20616|<u>grammatical gender from Lexeme</u>]], an existing function that retrieves the gender, if any, associated with a noun lexeme. Lexemes contain statements, and this function gets the gender of a given noun lexeme by finding the value of the statement with the property [[wikidata:Property:P5185|P5185/grammatical gender]].
'''Applicability''': in addition to lexemes, statements are also contained within lexeme forms, lexeme senses, and items, so similar functions can be used to retrieve statement values from instances of those types.
=== '''Calling the function''' ===
* Visit [[Z20616|<u>grammatical gender from Lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes a single input, which is of type [[Z6005|<u>Wikidata lexeme</u>]].
** Notice also that its output will be a Typed list of [[Z6091|<u>Wikidata item reference</u>]]. It returns a list because that allows for cases where there is no gender statement, or multiple gender statements, in the lexeme. However, in most cases there will be a single gender statement.
* Locate the ''lexeme selector'' for entering the input value (shown in Figure 7). In the box with the Wikidata icon, type in the 3 letters “hut”.
** Notice the matching choices that show up as you type. These are Wikidata search results for lexemes that match the letters typed in.
* When you see the choice for ''Hut; German, noun'' (as shown in Figure 8), click on it. Your selection should then appear as in Figure 9.
* Click ''Run function''.
* The result should appear as shown in Figure 10. This shows the ''compact view'' for the Wikidata item reference for the concept ''masculine''. The compact view includes just the Wikidata icon and the word ''masculine''.
** Rather than returning the entire Wikidata item, this function just returns a [[Z6091|<u>Wikidata item reference</u>]], which is usually all that’s needed for identifying grammatical features.
** Note that the compact view currently does not provide a visual distinction between lexemes, lexeme forms, lexeme senses, items, and properties. Usually the entity type is apparent from context, but if not, the type can be revealed as shown in the next steps.
** Notice the two chevrons that appear to the left of the Wikidata icon. The first of these allows you to see more details of the Typed list; the second allows you to see details of the first element of the list.
* Click on the rightmost chevron.
** Notice that it reveals a simple structure (the [[Z6091|<u>Wikidata item reference</u>]] for ''masculine)'' shown in Figure 11, containing the type and the Wikidata item ID <code>Q499327</code>.
<gallery mode=packed heights=176px>
File:Lexeme selector with "Hut" selected.png|Fig. 9. Lexeme selector with "Hut" selected
File:Compact view for a Wikidata item.png|Fig. 10. Compact view for a Wikidata item reference
File:Wikidata item reference for Q499327.png|Fig. 11. Wikidata item reference for the concept "masculine"
</gallery>
== Getting a word form having given grammatical features ==
[[File:Two input selectors for a function.png|thumb|Fig. 12. Input selectors for the function]]
[[File:Lexeme selector showing choices for "schon".png|thumb|Fig. 13. Lexeme selector showing choices for "schon"]]
Here we show how to compose a call to [[Z19241|<u>first matching representation string from lexeme</u>]], an existing function that retrieves, from a given lexeme, the word-form (''representation'') having one or more given grammatical features. For example, the lexeme for ''schön'' (beautiful) has a lexeme form with grammatical features ''singular'' and ''masculine'', and that lexeme form contains the representation ''schöner''.
Lexemes contain lexeme forms, and each lexeme form contains a list of Wikidata item references, which are its grammatical features. (We saw these in the first vignette above, ''Fetching a lexeme form from Wikidata''.) The function here will first select the lexeme form having the desired grammatical features, and then get the first representation from that lexeme form.
'''Applicability''': Every lexeme form can be characterized by a wide variety of grammatical features, so functions such as this one can be used to select the correct lexeme form (or its representation) in various language generation tasks.
=== '''Calling the function''' ===
* Visit [[Z19241|<u>first matching representation string from lexeme</u>]] in your browser.
** Notice, in the About box, that this function takes an input of type [[Z6005|<u>Wikidata lexeme</u>]], and a second input which is a Typed list of [[Z6091|<u>Wikidata item reference</u>]], and returns a String.
* Locate the input selectors (shown in Figure 12).
* In the lexeme selector, where it prompts with ''Select Wikidata lexeme'', type in “schon”.
* When you see the choice for ''schön; German, adjective'' (the third choice shown in Figure 13), click on it. Your selection should then appear as in Figure 14.
* Enter the grammatical feature ''singular'' as follows:
** Click on the ‘+’ icon, which tells Wikifunctions to add a new element to the input list.
** Type in “singular”, where it says ''Select Wikidata item'', and choose ''singular; grammatical number''. This is the [[Z6091|<u>Wikidata item reference</u>]] for the linguistic concept ''singular.''
* Using the ‘+’ icon again, type in “masculine” and choose the feature ''masculine; grammatical gender'' (because we want the adjective to agree with the masculine noun ''Hut''). Your input selections should now appear as in Figure 15.
* Try clicking on the chevron to the left of ''Item 2''. You will see that it opens up to reveal the internal structure of the [[Z6091|<u>Wikidata item reference</u>]], showing its type and Wikidata ID, as explained near the end of the previous use case.
* Click ''Run function''.
* The result (the string ''schöner)'' should appear as shown in Figure 16.
<gallery mode=packed heights=208px>
File:Two input selectors with "schon" selected in the first.png|Fig. 14. "schon" selected in the first input selector
File:Two input selectors with selections made.png|Fig. 15. Selections ready for the function call
File:Function call result- "schoner".png|Fig. 16. Function call result, a string
</gallery>
== Generating a phrase with agreement ==
Here we show how to compose a call to [[Z20612|German indef noun phrase from noun and adjective]], an existing function that constructs a phrase with an indefinite article (a word like “a” or “an” in English), an adjective, and a singular noun, while ensuring that both the article and the adjective form agree with the noun. The indefinite articles in German are "ein" (masculine) and "eine" (feminine).
This function builds on the two functions visited above. In fact, this function, which takes a noun lexeme and an adjective lexeme as inputs, does the following things:
# Determine if the noun has masculine or feminine gender
# Extract the correctly gendered, singular form of the adjective from the adjective lexeme
# Choose the correct form of the indefinite article
# Extract the singular form of the noun from the noun lexeme
# Concatenate the 3 elements together into a single phrase
It does (1) by calling [[Z20616|<u>grammatical gender from Lexeme</u>]] and (2) and (4) by calls to [[Z19241|<u>first matching representation string from lexeme</u>]].
'''Applicability''': This function is specialized for generating a particular type of phrase in German. It could easily be used as a model for generating similar phrases in other languages, or could be used as a starting point for generating more elaborate phrases or sentences.
'''Caveat:''' Unfortunately, at present Wikifunctions is experiencing some performance issues, and this example function-call is returning an error. Still, it provides an excellent example for documentation purposes. We are working to resolve these issues, and will update this document as soon as that's happened.
=== '''Calling the function''' ===
[[File:Two lexeme selectors for a function.png|thumb|Fig. 17. Lexeme selectors for noun and adjective inputs]]
[[File:Function call produced by a lexeme selector.png|thumb|Fig. 18. Function call produced by lexeme selector]]
* Visit [[Z20612|German indef noun phrase from noun and adjective]] in your browser.
* Notice, in the About box, that this function takes two inputs of type [[Z6005|<u>Wikidata lexeme</u>]] and returns a String.
* Locate the input selectors (shown in Figure 17). There is a lexeme selector for inputting a noun lexeme, and another for inputting an adjective lexeme.
* In the noun selector, type in “hut” and select the choice for ''Hut; German, noun'' (as was shown in Figure 8).
* In the adjective selector, type in “schone” and select the choice for ''schön; German, adjective'' (as was shown in Figure 13).
* Try clicking on the chevron to the left of ''adjective''. You will see that it opens up to reveal the internal structure that's produced by the lexeme selector (as shown in Figure 18).
** The behavior of the lexeme selector depends on context. In this case, Wikifunctions knows that this function expects to receive an entire [[Z6005|<u>Wikidata lexeme</u>]] as its second input; not just a reference to a lexeme. Knowing this, it produces a [[Z6095|<u>Wikidata lexeme reference</u>]] for the selected lexeme, and also constructs a call that passes that reference to the function [[Z6825|<u>Fetch Wikidata lexeme</u>]]. When ''Run function'' is clicked, the result of this call will be used as the second input to [[Z20612|German indef noun phrase from noun and adjective]].
** Click ''Run function''.
** The result ''should'' be the string ''ein schöner Hut'' (and will be again once the performance issues mentioned above are resolved.) Unfortunately, at the moment, you will only see the word ''void'', and an error indication in the ''Details'' dialog.
If you want to get an idea of how [[Z20612|German indef noun phrase from noun and adjective]] has been implemented, visit the implementation at [[Z20615|<u>agree adjective with noun</u>]]. In the '''Contents''' box, under the word '''composition''', you will find an expandable summary of the implementation. Although an explanation of this composition implementation is out of scope for this document, you may be able to see how each of the 5 steps listed above are accomplished, including the calls to [[Z20616|<u>grammatical gender from Lexeme</u>]] and [[Z19241|<u>first matching representation string from lexeme</u>]].
ncs7srzqgjb5ncy4wcfrh149cnhx22h
Talk:Z14090
1
45636
147124
2024-12-19T09:30:56Z
J GVaz
9890
Wrong output when testing validation
147124
wikitext
text/x-wiki
Revision for some test validation.
Testing [[Z14090]] on [[Z14095]]
It shows as "Passed", but when look at Details, the test failed with the error:
Error type: Reached time limit in evaluator
So the test should be marked as "Failed" instead.
dqip28t0a70o3zbhi6s0todrenp52zo
147125
147124
2024-12-19T09:36:47Z
J GVaz
9890
147125
wikitext
text/x-wiki
'''Revision for some test validation.'''
Testing [[Z14090]] on [[Z14095]]
It shows as "Passed", but when look at Details, the test failed with the error:
Error type: Reached time limit in evaluator
So the test should be marked as "Failed" instead.
Same issue testing on [[Z14100]]
t31apego8gnpd13e9omu9kbcsb6z9jx
147126
147125
2024-12-19T09:45:00Z
J GVaz
9890
147126
wikitext
text/x-wiki
'''Revision for some tests validation.'''
Testing [[Z14090]] on [[Z14095]]
It shows as "Passed", but when looking at Details, the test failed with the error:
Error type: Reached time limit in evaluator
So the test should be marked as "Failed" instead.
Same issue testing on
* [[Z14100]]
* [[Z14682]]
* [[Z14696]]
* [[Z14701]]
* [[Z14702]]
tcojesl0bkyfr9pgdryh7nwl1r96rff
Talk:Z20884
1
45637
147127
2024-12-19T11:52:33Z
Denny
81
/* Different from Z16693? */ new section
147127
wikitext
text/x-wiki
== Different from [[Z16693]]? ==
Hi @[[User:Shweeze503|Shweeze503]]! Welcome to the project, and thank you for your contribution! I just wanted to check if this function is, in any way, meant to be different from [[Z16693]]? If so, let us know, otherwise we may merge it into that.
If you are interested in functions on integers, you can find [[Wikifunctions:Catalogue/Number operations#Integer functions|a catalogue of functions we already have here]]. If you want to fill gaps, this will be more than welcome! Thank you, and welcome to the project! --[[User:Denny|Denny]] ([[User talk:Denny|talk]]) 11:52, 19 December 2024 (UTC)
h1ki0ufsieiovf2zbhesqy695a06i1h