datamuse

Types

Lookup = enum
  MeansLike = "ml: means like", SoundsLike = "sl: sounds like",
  SpelledLike = "sp: spelled like", Vocabulary = "v: vocabulary",
  Topics = "topics: concepts like", LeftContext = "lc: left context",
  RightContext = "rc: right context", MaximumResults = "max: limit results",
  QueryEcho = "qe: reproduce query"
Related = enum
  jja = "jja: nouns", jjb = "jjb: adjectives", syn = "syn: synonyms",
  trg = "trg: triggers", ant = "ant: antonyms", spc = "spc: kind of",
  gen = "gen: hyponyms", com = "com: holonyms", par = "par: meronyms",
  bga = "bga: followers", bgb = "bgb: leaders", rhy = "rhy: ideal rhymes",
  nry = "nry: near rhymes", hom = "hom: homophones", cns = "cns: consonant"
MetaData = enum
  Definitions = "d: definitions", PartsOfSpeech = "p: parts of speech",
  SyllableCount = "s: syllable count", Pronunciation = "r: pronunciation",
  WordFrequency = "f: word frequency"
Suggestion = enum
  PrefixHint = "s: starts with", MaximumSuggestions = "max: limit results",
  SuggestionVocabulary = "v: vocabulary"
Result = object
  word: string
  score: int
  syllables: range[1 .. int.high]
QueryKind = enum
  Lookups = "/words", Suggestions = "/sug"
MuseCall = object
  results: seq[Result]
  case kind: QueryKind
  of Lookups:
      lookup: QueryTable[Lookup]
      metadata: QueryTable[MetaData]
      related: QueryTable[Related]

  of Suggestions:
      suggestion: QueryTable[Suggestion]

  

Procs

proc newDataMuseCall(url: Uri; name = "datamuse"): RestCall {...}{.raises: [], tags: [].}
proc newMuseCall(kind: QueryKind; args: openArray[tuple[key, val: string]]): RestCall {...}{.
    raises: [], tags: [].}
proc suggest(s: string = ""; max: string = ""; v: string = ""): int {...}{.raises: [Exception,
    RestError, Defect, IOError, OSError, ValueError, JsonParsingError, FutureError,
    UnpackError, IndexError],
    tags: [RootEffect, TimeEffect, ReadIOEffect, WriteIOEffect].}
proc lookup(ml: string = ""; sl: string = ""; sp: string = ""; v: string = "";
           topics: string = ""; lc: string = ""; rc: string = ""; max: string = "";
           qe: string = ""; d: string = ""; p: string = ""; s: string = ""; r: string = "";
           f: string = ""; jja: string = ""; jjb: string = ""; syn: string = "";
           trg: string = ""; ant: string = ""; spc: string = ""; gen: string = "";
           com: string = ""; par: string = ""; bga: string = ""; bgb: string = "";
           rhy: string = ""; nry: string = ""; hom: string = ""; cns: string = ""): int {...}{.raises: [
    Exception, RestError, Defect, IOError, OSError, ValueError, JsonParsingError,
    FutureError, UnpackError, IndexError],
    tags: [RootEffect, TimeEffect, ReadIOEffect, WriteIOEffect].}

Templates

template newWordsCall(args: openArray[tuple[key, val: string]]): RestCall
template newSuggCall(args: openArray[tuple[key, val: string]]): RestCall