Urban Dictionary: Handle Linked Definitions #47

Open
opened 2020-09-14 12:26:56 +01:00 by SethFalco · 0 comments
SethFalco commented 2020-09-14 12:26:56 +01:00 (Migrated from gitlab.com)

The UrbanDictionary API can provide API responses with words enclosed in square brackets, for example:

{
    "definition": "a very [offensive] [curse word]",
    "permalink": "http://hello.urbanup.com/10899178",
    "thumbs_up": 727,
    "sound_urls": [
      "http://wav.urbandictionary.com/hello-25244.wav"
    ],
    "author": "i am multi coloured",
    "word": "hello",
    "defid": 10899178,
    "current_vote": "",
    "written_on": "2017-01-15T00:00:00.000Z",
    "example": "[What the] hello",
    "thumbs_down": 92
}

The words linked in [] are references to other words.
We should make a way to process these bracketed terms in the definition field.

My proposal is that we make this a dynamic implementation which can be set at runtime through a setter in the UrbanDictionary object.

It'll take a function interface which can be implemented or set inline for how to interpolate these strings.

The default implementations should handle:

  • Literal - Do nothing
  • Markdown - Convert links to a Markdown link.
  • URL - Convert links to the literal URL.

It may be desirable to also make a "DefineOptions" class which can be given as a parameter per request for exceptions to the global rule.

The UrbanDictionary API can provide API responses with words enclosed in square brackets, for example: ```json { "definition": "a very [offensive] [curse word]", "permalink": "http://hello.urbanup.com/10899178", "thumbs_up": 727, "sound_urls": [ "http://wav.urbandictionary.com/hello-25244.wav" ], "author": "i am multi coloured", "word": "hello", "defid": 10899178, "current_vote": "", "written_on": "2017-01-15T00:00:00.000Z", "example": "[What the] hello", "thumbs_down": 92 } ``` The words linked in `[]` are references to other words. We should make a way to process these bracketed terms in the `definition` field. My proposal is that we make this a dynamic implementation which can be set at runtime through a setter in the UrbanDictionary object. It'll take a function interface which can be implemented or set inline for how to interpolate these strings. The default implementations should handle: * Literal - Do nothing * Markdown - Convert links to a Markdown link. * URL - Convert links to the literal URL. It may be desirable to also make a "DefineOptions" class which can be given as a parameter per request for exceptions to the global rule.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
SethFalco/elypiai#47
No description provided.