Extension:Relevance rating

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
Relevance Rating

Release status: unknown

Description Extends Article Feedback V4 to improve the search-functionality.
Author(s) Jan Dörries
MediaWiki 1.18
License GPLv2
Download No link
Hooks used
GetPreferences

UserLoginComplete
UserSaveOptions

Check usage (experimental)

The Relevance Rating Extension extends Article Feedback Tool V4 to improve the MediaWiki search-functionality.

Rated articles will be ordered by a scoring system:

Criteria Weight
title relevance 12%
actuality/informationquality -35% (works only negative)
completeness 5%
understandability 8%
link-popularity 15%
visitor-popularity 25%
writer-count 35%

A second scoring-model is used to classify users. In this project, the classification is done by qualification-criterias:

Criteria Weight in points
Qualification (graduate (1pt)/executive (1pt)) 1-3
usage-frequency < 10 logins: 0
>= 10 logins and < 50 logins: 1
>= 50 logins: 2
writer-experience < 5 edits: 0
>= 5 edits and < 15 edits: 1
>= 15 edits: 2
Usergroup < 3: unexperienced
>= 3 and < 5: advanced
>= 5: expert

It can optionaly used for matching rating scores (ranking) and groups.

All weights here are examples, the rating system can be configured in RelevanceRating.php.

[edit] Installation

Requirements

You need to install: Extension:ArticleFeedback - version 4

Installation Steps:

1. Create a directory RelevanceRating in your extension-folder.
2. Copy the files from here to your extension-folder.

3. You have to patch the search sourcecode in your mediawiki installation.

If you are using MySQL do the following:

Look for the file SearchMySQL.php in your installation (mediawikifolder/includes/search) an make a backup copy.

Modify at function limitResult on Line ~254:

        protected function limitResult( &$query ) {
                $query['options']['LIMIT'] = $this->limit;
                $query['options']['OFFSET'] = $this->offset;
                $query['options']['ORDER BY'] = 'relevance desc'; // Add this line
        }

and modify at function queryMain on Line ~298:

        function queryMain( &$query, $filteredTerm, $fulltext ) {
                global $wgUser;
                $user_id = $wgUser->getId();
                $match = $this->parseQuery( $filteredTerm, $fulltext );
                $query['tables'][] = 'page';
                $query['tables'][] = 'searchindex';
                $query['tables'][] = 'relevance_rating';
                $query['fields'][] = 'relevance_rating.page_id';
                $query['fields'][] = 'group_id';
                $query['fields'][] = 'relevance';
                $query['fields'][] = 'page.page_id';
                $query['fields'][] = 'page_namespace';
                $query['fields'][] = 'page_title';
                $query['conds'][] = 'page.page_id=si_page';
                $query['conds'][] = 'page.page_id=relevance_rating.page_id'; // Add
                $query['conds'][] = 'relevance_rating.group_id=(select user.user_qualification from user where user.user_id='.$user_id.')'; // Add
                $query['conds'][] = $match;
        }

4. Import the SQL-File: "Relevance-Rating.sql" in your Wiki-Database.

RelevanceRating.sql

-- Add new column to user-table
ALTER TABLE `user` ADD COLUMN (
        user_qualification INTEGER(10) NOT NULL DEFAULT 0
);
 
-- Create a new table for counting user-logins
CREATE TABLE IF NOT EXISTS      user_login (
        user_id INT(10) UNSIGNED NOT NULL, 
        login_date BINARY(14) NOT NULL, 
        PRIMARY KEY (user_id,login_date)
);
 
-- Create new table for storing relevance-score per page and group
CREATE TABLE IF NOT EXISTS relevance_rating (
  page_id INT(10) UNSIGNED NOT NULL,
  group_id INT(10) UNSIGNED NOT NULL,
  relevance INT(100) NOT NULL,
  PRIMARY KEY (`page_id`,`group_id`)
);

To install this extension, add the following to LocalSettings.php:

require_once( "$IP/extensions/RelevanceRating/RelevanceRating.php");

6. To provide always fresh scores your have to schedule a Task for calculating the scores.
This can be done by creating a cronjob (Linux) or a scheduled task (Windows). E.G.:

c:
cd C:\xampp\htdocs\mediawiki
 
..\..\php\php.exe index.php rate //important part

[edit] Configuration

Various options to control the score-model can be found at RelevanceRating.php.

Personal tools
Namespaces

Variants
Actions
Navigation
Support
Download
Development
Communication
Print/export
Toolbox