User:Conrad.Irwin/How about an API

Definition from Wiktionary, the free dictionary
Jump to: navigation, search

An API supporting the following type of queries would be a very useful start to creating a higher-level interface to Wiktionary (this is not example syntax, just ideas)

FIND synonyms FOR en:dog
FIND translations FOR en:dog WHERE targetlanguage=fr
FIND antonyms, anagrams FOR fr:chien
FIND * FOR dog

In order to add this to Wiktionary without necessitating editing each of our million pages, I propose adding a parser function {{#store}} that could be used in our current templates.


Each piece of data is indexed by the un-named fields, and contains the information in the named fields. The un-named fields would be "word, language, part-of-speech, context", though part-of-speech and context may be optional. In order for this to work, a second extension might be needed that could keep track of what language and part-of-speech the part of the entry was; by looking at the headers - this could be done quite nicely using a simple custom extension with

I would then propose a SpecialPage that would allow Sysops (or just Technocrats) to define what form each type of "store" command could take.

ALLOW synonym, antonym, translation WITH targetlang, definition, etymology, descendant WITH targetlang

Once all of the above was working nicely, I might add a SpecialPage that allows the specification of additional parsing rules in order to create further {{#store}} commands from formatting.

CONVERT ^#\s*([^#:*].*)$ INTO {{#store:definition|{{PAGENAME}}|{{#var:LANGUAGE}}|{{#var:PARTOFSPEECH}}|definition=$1}}