The Wikinsert API serves pre-computed sentence-level relevance scores to the browser extension in real time. Unlike a traditional full-featured REST backend, this interface is intentionally narrow: it only exposes functionality required for the user study. All data processing and scoring occurs offline.
The API is built with Ktor, a Kotlin framework for building asynchronous servers and clients. It connects to a MongoDB database that stores pre-computed article data, sentence tokenization, and relevance scores generated by the data processing pipeline.
- Minimal Interface: Only exposes endpoints required for the browser extension
- Pre-computed Data: All responses are derived from pre-computed data, eliminating real-time inference
- Low Latency: Ensures responsive user experience in the browser extension
- Model Agnostic: API design is independent of the underlying scoring framework
The API offers two main endpoints that support the complete functionality of the Wikinsert browser extension:
POST /heatmap
Retrieves sentence-level relevance scores for a source article and target entity.
| Parameter | Description |
|---|---|
| src_rev_id | Revision ID of the source article |
| src_title | Title of the source article |
| target_title | Title of the target entity |
| lang | Language code (e.g., "en") |
Returns a list of sentences from the source article, each with:
- Sentence ID
- Start and end character offsets
- Relevance score (pre-computed using the XLocEI model)
[
{
"id": 0,
"startOffset": 0,
"endOffset": 120,
"score": 0.75
},
{
"id": 1,
"startOffset": 121,
"endOffset": 245,
"score": 0.32
}
]GET /searchTargets
Searches for suitable target entities that match a query and are associated with a specific source article.
| Parameter | Description |
|---|---|
| q | Search query |
| source_title | Title of the source article |
| lang | Language code (default: "en") |
Returns a list of target entities that match the search query:
[
{
"title": "Example Entity",
"lang": "en",
"description": "This is an example entity",
"thumbnail": {
"source": "https://example.com/image.jpg",
"width": 100,
"height": 100
}
}
]- JDK 11 or higher
- MongoDB instance with pre-processed data
- Docker (optional, for containerized deployment)
| Variable | Description | Default |
|---|---|---|
| MONGODB_URI | MongoDB connection string | mongodb://odin.st.lab.au.dk:27017 |
| MONGODB_DATABASE | MongoDB database name | wikinsert |
./gradlew runBuild a fat JAR:
./gradlew buildFatJarRun the JAR:
java -jar build/libs/wikinsert-backend-all.jarBuild the Docker image:
./gradlew buildImageRun the Docker container:
docker run -p 8080:8080 -e MONGODB_URI=mongodb://your-mongodb-host:27017 -e MONGODB_DATABASE=wikinsert wikinsert-backend- Ktor: Web framework for building asynchronous servers
- kotlinx.serialization: JSON serialization/deserialization
- MongoDB Kotlin Driver: MongoDB client for Kotlin
- Koin: Dependency injection framework
- Netty: Asynchronous event-driven network application framework
curl -X POST "http://localhost:8080/heatmap?src_rev_id=1264244422&src_title=Salmon&target_title=Bream&lang=en"curl "http://localhost:8080/searchTargets?q=fish&source_title=Salmon&lang=en"