An API for Measuring the Relatedness of Words in Wikipedia

Simone Paolo Ponzetto, Michael Strube

Introduction

In the field of Natural Language Processing (NLP), a fundamental challenge is enabling computers to quantify the semantic relatedness between concepts—for instance, recognizing that "computer" is more closely aligned with "keyboard" than with "apple." Traditionally, researchers have relied on expert-curated lexical databases like WordNet. While WordNet provides high accuracy, its manual curation makes it expensive to maintain, slow to incorporate emerging terminology, and limited in its coverage of niche topics.

This paper introduces a Java-based API that leverages Wikipedia’s vast, community-driven category hierarchy as a structured semantic network. By mapping words to Wikipedia articles and calculating paths through their associated categories, the tool offers a robust, multilingual alternative to traditional resources, capturing the real-time evolution of human knowledge.

System Architecture and Methodology

The API transforms Wikipedia's semi-structured data into a formal tool for programmatic relatedness computation through a four-step pipeline:

  1. Input Processing: The system accepts a pair of words or concepts.
  2. Disambiguation: It identifies the specific Wikipedia articles corresponding to the input. For example, it distinguishes between "King" as a chess piece and "King" as a monarch based on context.
  3. Path Finding: The Wikipedia categorization system is treated as a graph. The API identifies paths between the categories assigned to the two target articles.
  4. Scoring: Standard NLP algorithms are applied to these paths to generate a numerical relatedness score.

Technically, the API utilizes a multi-tier architecture to bridge different software environments. A Java wrapper library serves as the primary interface, communicating via XML-RPC with a Perl-based daemon. This daemon interacts with a MediaWiki instance and a MySQL database to retrieve article and category data.

Sequence diagram illustrating the multi-tier communication between the Java library, XML-RPC daemon, and the MediaWiki backend.

The Wikipedia Semantic Network

The core innovation of this tool is the treatment of Wikipedia’s user-generated categories as a proxy for a formal taxonomy. While these categories lack the rigid hierarchy of expert-vetted systems, they are sufficiently dense to support complex graph-based calculations.

Furthermore, the API is multilingual by design. At the time of its development, it supported English, German, French, and Italian. By leveraging Wikipedia’s existing cross-lingual links, the system can be extended to other languages without the need for a ground-up rebuild, facilitating cross-linguistic NLP tasks that were previously siloed.

Visualization and Relatedness Metrics

Beyond providing a single numerical score, the API emphasizes interpretability. It integrates with the JGraph library to visualize the semantic paths between concepts. This allows researchers to inspect the logic behind a score—for example, seeing the hierarchical link from Computer to Keyboard through intermediate categories like Computer hardware and Computer peripherals.

The system supports several classic NLP metrics adapted for the Wikipedia graph, including path-length, information content (measuring category specificity), and text-overlap (comparing article descriptions).

Wikipedia Similarity Web Interface showing the semantic path and relatedness scores for 'computer' and 'keyboard'.

Key Results and Utility

As a software demonstration, the project focuses on utility and flexibility. The API provides a simple programmatic interface (e.g., getRelatedness(word1, word2)) that abstracts the complexity of the underlying LAMP (Linux, Apache, MySQL, PHP) stack. By offering multiple scoring measures such as Leacock & Chodorow or Resnik, it allows researchers to select the metric best suited for specific tasks like word sense disambiguation or information extraction.

Limitations and Future Work

The authors acknowledge certain trade-offs in their approach. The multi-tier "Java-to-XML-RPC-to-Perl-to-PHP" pipeline, while functional, introduces architectural complexity and potential latency. Additionally, because Wikipedia categories are crowdsourced, they can occasionally be idiosyncratic or contain "loops" that deviate from a clean hierarchy.

Future development aims to streamline the architecture, extend support to more languages, and integrate sophisticated graph algorithms like PageRank to better weight the importance of specific categories within the network.

Summary updated

BibTeX
@inproceedings{ponzetto2007api,
  author = {Simone Paolo Ponzetto and Michael Strube},
  title = {{An API for Measuring the Relatedness of Words in Wikipedia}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2007},
}
Figure