EBernhardson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/366318 )

Change subject: [WIP] MVP of human graded search relevance on article pages
......................................................................

[WIP] MVP of human graded search relevance on article pages

This is an MVP for asking our readers about the relevance of an article
page to a curated list of queries. For the MVP (and only for the MVP)
the list of articles and queries is hard-coded into the javascript
itself. This will allow a small scale evaluation of perhaps 5 queries
and 5 articles each to see if the data will be useful, or simply a bunch
of noise.

The actual articles and queries to use are not here yet, currently
looking for feedback on the implementation and if this is enough
for us to put something out there and decide it's worth pursuing
further.

Change-Id: I173a46da75d6632305883a81adb932f2a95227c6
---
M extension.json
M i18n/en.json
M i18n/qqq.json
A modules/ext.wikimediaEvents.humanSearchRelevance.js
4 files changed, 114 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikimediaEvents 
refs/changes/18/366318/1

diff --git a/extension.json b/extension.json
index 00e9134..39ae7b4 100644
--- a/extension.json
+++ b/extension.json
@@ -152,6 +152,11 @@
                        "schema": "RecentChangesTopLinks",
                        "revision": 16732249
                },
+               "schema.HumanSearchRelevance": {
+                       "class": "ResourceLoaderSchemaModule",
+                       "schema": "HumanSearchRelevance",
+                       "revision": 17014793
+               },
                "ext.wikimediaEvents": {
                        "scripts": [
                                "ext.wikimediaEvents.events.js",
@@ -163,7 +168,8 @@
                        ],
                        "skinScripts": {
                                "default": [
-                                       
"ext.wikimediaEvents.searchSatisfaction.js"
+                                       
"ext.wikimediaEvents.searchSatisfaction.js",
+                                       
"ext.wikimediaEvents.humanSearchRelevance.js"
                                ],
                                "minerva": []
                        },
diff --git a/i18n/en.json b/i18n/en.json
index 8b76ed5..ad9f041 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -13,5 +13,9 @@
        "tag-cross-wiki-upload-4": "-",
        "tag-HHVM": "[[mw:Special:MyLanguage/HHVM/About|HHVM]]",
        "tag-HHVM-description": "Revisions made with the HipHop Virtual Machine 
enabled instead of the Zend PHP interpreter (expected to improve performance, 
tagged for debugging/analysis)",
-       "abusefilter-edit-builder-vars-user-wpzero": "Whether or not a user is 
editing through a zero-rated carrier via Wikipedia Zero"
+       "abusefilter-edit-builder-vars-user-wpzero": "Whether or not a user is 
editing through a zero-rated carrier via Wikipedia Zero",
+       "wikimediaevents-humanrel-question": "Would you click this page when 
searching for '$1'?",
+       "wikimediaevents-humanrel-yes": "Yes",
+       "wikimediaevents-humanrel-no": "No",
+       "wikimediaevents-humanrel-unsure": "I don't know"
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index b35c3f5..c2a613f 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -14,5 +14,9 @@
        "tag-cross-wiki-upload-4": "{{notranslate}} Tag on cross-wiki uploads 
submitted using interface option 4.",
        "tag-HHVM": "{{notranslate}} Tag on edits made via HHVM",
        "tag-HHVM-description": "Description for the HHVM tag.",
-       "abusefilter-edit-builder-vars-user-wpzero": "Description for an 
AbuseFilter variable about whether the user is editing through a zero-rated 
carrier via Wikipedia Zero"
+       "abusefilter-edit-builder-vars-user-wpzero": "Description for an 
AbuseFilter variable about whether the user is editing through a zero-rated 
carrier via Wikipedia Zero",
+       "wikimediaevents-humanrel-question": "Would you click this page when 
searching for '$1'?",
+       "wikimediaevents-humanrel-yes": "Positive answer to articles relevance 
to a search query.\n\nAppears with the question: 
{{msg-mw|wikimediaevents-humanrel-question}}",
+       "wikimediaevents-humanrel-no": "Negative answer to articles relevance 
to a search query.\n\nAppears with the question: 
{{msg-mw|wikimediaevents-humanrel-question}}",
+       "wikimediaevents-humanrel-unsure": "Undecisive answer to articles 
relevance to a search query.\n\nSee also: 
{{msg-mw|wikimediaevents-humanrel-question}}, 
{{msg-mw|wikimediaevents-humanrel-yes}}, {{msg-mw|wikimediaevents-humanrel-no}}"
 }
diff --git a/modules/ext.wikimediaEvents.humanSearchRelevance.js 
b/modules/ext.wikimediaEvents.humanSearchRelevance.js
new file mode 100644
index 0000000..ade6d51
--- /dev/null
+++ b/modules/ext.wikimediaEvents.humanSearchRelevance.js
@@ -0,0 +1,97 @@
+( function ( mw, $, undefined ) {
+       'use strict';
+
+       function oneIn ( populationSize ) {
+               var rand = mw.user.generateRandomSessionId(),
+                       parsed = parseInt( rand.slice( 0, 13 ), 16 );
+               return parsed % populationSize === 0;
+       }
+
+       function chooseOne( options ) {
+               var rand = mw.user.generateRandomSessionId(),
+                       parsed = parseInt( rand.slice( 0, 13 ), 16 ),
+                       step = Math.pow( 2, 52 ) / options.length;
+               return options[ Math.floor( parsed / step ) ];
+       }
+
+       // Only accept NS_MAIN
+       if ( mw.config.get( 'wgNamespaceNumber' ) !== 0 ) {
+               return;
+       }
+
+       // For the MVP we are simply hardcoding the list of queries and 
articles. If the MVP shows to return
+       // data that isn't complete junk this will be revisited, perhaps 
embedding the desired queries into
+       // cached page render or some such.
+       var config = {
+                       1: {
+                               oneIn: 1,
+                               queries: ['JFK']
+                       }
+       }[mw.config.get('wgArticleId')]
+
+       // Page is not part of this test
+       if ( config === undefined ) {
+               return;
+       }
+
+       // This page view not chosen for sampling
+       if ( !oneIn( config.oneIn ) ) {
+               return;
+       }
+
+       // TODO: We probably want to vary this 60s for some AB tests, to see if 
the quality
+       // of human grades varies depending on how long we wait.
+       setTimeout( askQuestion, 5 );
+
+       function askQuestion() {
+               mw.loader.using( [
+                       'oojs-ui-core',
+                       'mediawiki.notification',
+                       'mediawiki.api.messages'
+               ] ).then( function () {
+                       return new mw.Api().loadMessagesIfMissing( [
+                               'wikimediaevents-would-you-click',
+                               'wikimediaevents-would-you-click-yes',
+                               'wikimediaevents-would-you-click-no',
+                               'wikimediaevents-would-you-click-unsure' ] );
+               } ).then( function () {
+                       var notification,
+                               clicked = false,
+                               query = chooseOne( config.queries ),
+                               logEvent = function ( choice ) {
+                                       notification.close();
+                                       if ( clicked === true ) {
+                                               // User selected more than one 
option. What now!?!?!
+                                               return;
+                                       }
+                                       clicked = true;
+                                       mw.loader.using( [ 
'schema.HumanSearchRelevance' ] ).then( function () {
+                                               mw.eventLog.logEvent( 
'HumanSearchRelevance', {
+                                                       'articleId': 
mw.config.get( 'wgArticleId' ),
+                                                       'query': query,
+                                                       'choice': choice
+                                               } );
+                                       } );
+                               },
+                               buttons = new OO.ui.ButtonGroupWidget( {
+                                       items: [ "yes", "no", "unsure" ].map( 
function ( choice ) {
+                                               return new OO.ui.ButtonWidget( {
+                                                       label: mw.message( 
'wikimediaevents-humanrel-' + choice ).text()
+                                               } ).connect( {}, {
+                                                       click: [ logEvent, 
choice ]
+                                               } );
+                                       } )
+                               } ),
+                               content = $( '<p> ').text( mw.message(
+                                       'wikimediaevents-humanrel-question', 
query
+                               ) );
+
+                       content.append( buttons.$element );
+
+                       notification = mw.notification.notify( content, {
+                               autoHide: true,
+                               autoHideSeconds: 'long'
+                       } );
+               } );
+       }
+}( mediaWiki, jQuery ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/366318
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I173a46da75d6632305883a81adb932f2a95227c6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikimediaEvents
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to