APIs - kpatenio/quoi-react-app GitHub Wiki

APIs

A page containing additional information related to any APIs used in this project.

Collins Dictionary

The Benedict version of the Collins Dictionary API is currently used.

Entries

The Collins Dictionary API sends HTML content as a long string.

The \" escape characters

You may have noticed that, whenever the API returns a string of HTML, the \" escape character for double quotes is included in tag attributes. Why? That is because the entire string of HTML utilizes double quotes - if we were to use double quotes for an attribute like class="bob", the double quotes wrapping bob would not render. Thus, this is why we use the \" character and see class=\"bob\".

Note that if single quotes were used instead to wrap the entire string of HTML, using double quotes would have been fine! This might not be compatible for all programming languages, however.

Tags

The only tags used (so far) are h1,div, and span. The h1 tag is used for the entry word requested.

Class attributes

Note: for explanations, assume that we are using an English --> French dictionary.

  • hom: Main, unnumbered section. Indicates a different "type" of use for a particular word.
Examples (entry = 'board'): noun [.hom] --> {children html code related to board as a noun}, transitive verb [.hom] --> {children html code related to board as a transitive verb}, intransitive verb [.hom] --> {children html code related to board as an intransitive verb}
  • gramGrp: The "type" for a hom section. Found inside hom.
Examples (entry = 'board'): noun, transitive verb, intransitive verb
  • cit:
  • cit lang_{fr or en-gb}: a phrase or word translated into French. Found inside sense.
Example (entry = 'board' -- wooden): planche f[.cit .lang_fr] 
  • lbl: Text inside round brackets that provide context on how an English word would be used and what its translation would be in French according to that context. Note that this does NOT include anything with also {some word}. Found inside sense, and can be a sibling of cit lang, re, or another lbl.
Example (entry = 'board'): (=committee) [.lbl]..., (nautical [.lbl], aviation [.lbl])
  • re: Generally, a phrase containing the English entry without any examples.
Example (entry = 'board'): "on the board"
  • sense: Refers to a section containing the "translation" or meaning of an entry or a re.
Example 1 (entry = 'board'): 2. "board" [.entry] --> ( also blackboard ) tableau m (noir) ; on the board au tableau [.sense -- for 'board'] ;
Example 2 (entry = 'board'): "on the board" [.re] --> "au tableau" [.sense -- for .re]

Tag + attribute patterns

parent -> direct child 1, direct child 2 of parent & sibling of direct child 1

  • hom -> (first child) sense: first meaning within hom.
  • hom -> (first child) sense -> lbl, cit lang: lbl describes context of first sense; cit lang shows the translation + gender of the entry's first sense according to the current lbl.
  • hom -> (first child) sense -> cit lang -> quote -> hi: quote is the text, whereas hi is the gender - for the first sense of the entry.
  • hom -> sense -> cit lang, re-> inline -> sense -> cit lang: re is a phrase (in English) based on the entry's current sense. The inline is the actual phrase text without ; in front of it. The sense and cit lang of inline are the section meaning and the translation of the inline respectively.