Using the glossr package

Mariana Montes

2022-08-18

What is glossr?

The {glossr} package offers useful functions to recreate interlinear glosses in R Markdown (or Quarto!) texts.

  1. ASBC (nº 100622)

    她 哇的一聲 大 哭起來,

    tā wā=de-yì-shēng dà kū-qǐlái,

    TSG waa.IDEO-LINK-one-sound big cry-inch

    “Waaaaa, she began to wail.”

Start glossr

You can start using glossr in an R Markdown or Quarto file by calling the library and then use_glossr() to activate some background stuff.

library(glossr)
use_glossr()

Styling

use_glossr() also takes some variables to set up document-wide styling options for specific parts of your glosses. The code below sets the name of the source to render in boldface and the first line of each gloss in italics.

use_glossr(styling = list(
  source = "b",
  first = "i"
))

Basic usage

Call as_gloss() inside an R chunk. There are four named, optional arguments that will be treated specially:

  • label: for cross-references

  • source: text for a non-aligned first line

  • translation: free translation

  • trans_glosses: character to surround translations

All other values will be interpreted as lines to be aligned and reproduced in the order given, but only up to 3 lines are allowed.

Example

my_gloss <- as_gloss(
  "她 哇的一聲 大 哭起來,", # first aligned line
  "tā wā=de-yì-shēng dà kū-qǐlái,", # second aligned line
  "TSG waa.IDEO-LINK-one-sound big cry-inch", # third aligned line
  translation = "Waaaaa, she began to wail.", # free translation
  label = "my-label", # label for cross-references
  source = "ASBC (nº 100622)" # first not-aligned line
)
my_gloss
  1. ASBC (nº 100622)

    她 哇的一聲 大 哭起來,

    tā wā=de-yì-shēng dà kū-qǐlái,

    TSG waa.IDEO-LINK-one-sound big cry-inch

    “Waaaaa, she began to wail.”

Cross reference

The label given to as_gloss() allows you to cross-reference the example: in PDF this looks like example (\ref{my-label}), whereas in HTML and Word you would use example (@my-label).

What should YOU do?

Tip

gloss() can be used inline to generate a reference for any output: (2) in this case.

Tables of examples

You can also get your data from a dataframe

original parsed translation label source
Ainiku sonna shumi wa nai. Tsumetai-none. Kedaru-souna koe da-tta. unfortunately such interest not.exist cold- languid-seem voice Unfortunately I never have such an interest. You are so cold. (Her) voice sounded languid. languid-jp Shindo 2015:660
gloss_df(filter(glosses, label == "languid-jp"))
  1. Shindo 2015:660

    Ainiku sonna shumi wa nai. Tsumetai-none. Kedaru-souna koe da-tta.

    unfortunately such interest TOP not.exist cold-EMPH languid-seem voice COP-PST

    “Unfortunately I never have such an interest. You are so cold. (Her) voice sounded languid.”

No numbering

You can remove numbering in gloss_df() and in as_gloss().

gloss_df(filter(glosses, label == "languid-jp"), numbering = FALSE)

Shindo 2015:660

Ainiku sonna shumi wa nai. Tsumetai-none. Kedaru-souna koe da-tta.

unfortunately such interest TOP not.exist cold-EMPH languid-seem voice COP-PST

"Unfortunately I never have such an interest. You are so cold. (Her) voice sounded languid."