Code Monkey home page Code Monkey logo

mwaddlink-query's Introduction

mwaddlink-query

querying a trained model for link recommendation with the MediaWiki AddLink Extension Model and API

Introduction

This repository tries to provide an interface to the link-recommendation models trained with mwaddlink.

Update 2020-10-15:

  • The content of this repo has been merged intothe main repo mwaddlink
  • So check out the code there, this repo will not be maintained anymore and is most likely out of date.

Currently, the model (and the corresponding data) lives on the stat1008-machine on the wmf-cluster. So this will only work there for the moment.

Note that we only support a small number of languages so far (simple, de), but are continuouosly expanding.

Setup

Clone the repo

git clone https://github.com/martingerlach/mwaddlink-query
cd mwaddlink-query

Set up the virtual environment

virtualenv -p /usr/bin/python3 venv/
source venv/bin/activate
pip install -r requirements.txt

Additional notes:

Running the model

Get recommendations for a page in a wiki

python addlink-query_links.py -l <LANG> -p <PAGE>

for example,

python addlink-query_links.py -l de -p Garnet_Carter

this will yield a json with the following info:

  • 'page_title' (from input)
  • 'lang' (from input)
  • 'pageid', the page-id of the page in the respective wiki
  • 'revid', the revision-id of the wikitext of the page we are working with
  • 'no_added_links', the number of recommended links
  • 'added_links', a list with a dictionary for each recommended link
    • 'linkTarget': the pagetitle of the recommended link,
    • 'anchor':the anchor-text of the recommendaed link,
    • 'probability':the probability of the model for the link (confidence)
    • 'startOffset':character-offset start of anchor in wikitext (get via revid)
    • 'endOffset':character-offset end of anchor in wikitext (get via revid)

Other optional arguments_

  • -t, threshold for link recommendation (float, default=0.9)
  • -o, output-path for output-json (str, default="" will print to terminal)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.