A nodejs entity finder. entity-finder that searchs the wikipedia for titles and returns the most correct answers.
It will omit any wikipedia disambiguization pages.
import { find } from 'entity-finder';
const name = 'democratic party thailand';
const lang = 'en';
const titles = await find(name, lang, { limit: 1 });
const title = titles[0];
// title =
// {
// title: 'Democrat Party (Thailand)',
// simple: 'Democrat Party',
// special: 'Thailand',
// description: 'The Democrat Party (Thai: พรรคประชาธิปัตย์; RTGS: prachathipat) is a Thai political party...',
// }Finds entities. Returns an array of entities ordered by relevance.
- name (String), required - Entity name:
Italy. Maybe any text:David the sculpture. - lang (String), required - Language 2 chars code:
en. - options (Object), optional - Options object:
- limit (Number) - Maxim number of entities to return. Default: 2.
export type PageTitle = {
title: string
simple?: string
special?: string
description?: string
about?: string
categories?: string[]
}- modernize codebase: TypeScript strict mode, ES2020 target, Node
>=18 - replace
require("debug")with ES imports; bumpdebugto v4 - fix dropped headers in
wikipedia.openSearch(typoreaders→headers) - fix
searchTitlescrashing whendescriptionis undefined - fix
findaccidentally filtering primary results that lacked a(special)suffix - request
User-Agentis now derived frompackage.json(with contact URL) and overridable viaENTITY_FINDER_USER_AGENT - convert promise chains in
findTitlestoasync/await - modernize
run.jsCLI (arg validation, error handling) - bump dev deps:
typescriptv5,rimrafv5, add@types/debug - remove dead
wiki-entitycommented code
- expose only
findfunction
- remove
wiki-entitydependency. - remove
requestdependency. - sixes
- New option:
orderByTagsLimit- Limits titles ordered by tags.
- search only for titles
- updated API
- filters dezambiguization titles (Category:Dezambiguization)
- updated
optionsparam
- using module wiki-entity
- new results: returns an array of WikiEntity
- updated
optionsparam
- TypeScript code
- changed entity type:
grouptoorg
- node4;
- new wikipedia parser: n3 - better performance;
- added option:
tags; - news model fields:
typesandprops;