Giter VIP home page Giter VIP logo

wikipedia-game's Introduction

wikipedia_game.py

A python3 script that "plays" the wikipedia game, finding a route between two given wiki pages through links.

Required Packages:

  • requests

File Structure:

. wiki-game
├── _utils              (utility functions)
|   ├── links.py        (functions to find page names, links, and backlinks)
|   └── search.py       (implementation of simple search and BFS)
├── README.md
├── requirements.txt
└── wikipedia_game.py   (functional script)

Usage:

This package can be run as a single script via wikipedia_game.py (after installing requirements):

python3 wikipedia_game.py "{start_page}" "{end_page}"

Functionality:

The script directly accesses the Wikipedia API using the popular requests package for Python 3. First it checks for direct links between pages, followed by pages with a single intermediate link using links and backlinks. If there are two or more page hops, it finds the full path with an implementation of BFS (breadth-first search).

Future Improvements:

It could be productive to implement a bidirectional search using both interwiki links and backlinks to enhance search speed compared to traditional BFS (search time is currently quite slow for distantly related pages). Could also use any number of public word association API's to check strongest possible links first, also likely saving compute time. Additionally, try/except error handling for requests sessions may be useful.

wikipedia-game's People

Contributors

npoet avatar

Watchers

James Cloos avatar  avatar

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.