# Interlinear Glossed Text: Morpheme Segmentation and Leipzig Glosses

Source: https://www.potatoannotator.com/docs/annotation-types/interlinear-gloss

*New in v2.12.0*

An `interlinear_gloss` scheme shows a sentence as one column per word. Each column has the word (read-only), its morpheme segmentation and its [gloss](https://en.wikipedia.org/wiki/Interlinear_gloss), and the free translation goes on a line under the columns. It suits language documentation, typological data, and checking glosses imported from FLEx or Toolbox. On a narrow screen the columns wrap onto further lines, as a long example does in print.

The page checks each word against the [Leipzig Glossing Rules](https://www.eva.mpg.de/lingua/resources/glossing-rules.php) (Comrie, Haspelmath & Bickel) while the annotator types. [Linguistic Fieldwork](/docs/guides/linguistic-fieldwork) covers the FLEx and Toolbox round trip.

## Configuration

```yaml
annotation_schemes:
  - annotation_type: interlinear_gloss
    name: igt
    description: Segment each word into morphemes and gloss every morpheme
    source_field: text            # sentence string, or a list of words
    morphemes_field: morphemes    # optional pre-filled segmentation
    gloss_field: glosses          # optional pre-filled glosses
    translation_field: translation
    tiers: [pos, notes]           # optional extra lines per word
    abbreviations: leipzig        # warn on unknown category labels
    language: la                  # BCP 47 tag of the object language
    metalanguage: en              # language of the glosses and translation
    label_requirement:
      required: true
```

```json
{"id": "latin_1", "text": "Puella rosam amat.",
 "morphemes": ["puell-a", "ros-am", "ama-t"],
 "glosses": ["girl-NOM.SG", "rose-ACC.SG", "love-3SG"],
 "translation": "The girl loves the rose.",
 "pos": ["n", "n", "v"]}
```

When `source_field` holds a string, it is split on spaces, and punctuation at the edges of each word (`.`, `,`, `?`, quotes and brackets) is dropped. Hyphens and `=` inside a word are kept. To control the words exactly, give a list.

The pre-fill fields take a list with one entry per word, or a string with one space-separated entry per word. A configured tier is pre-filled from an item field of the same name when that field is a list. A word with no pre-filled segmentation starts with the word itself in the segmentation cell, so the annotator types only the boundaries.

| Key | Default | Meaning |
|---|---|---|
| `source_field` | `text` | Item field with the sentence (string) or the words (list) |
| `morphemes_field` | none | Item field with a segmentation per word |
| `gloss_field` | none | Item field with a gloss per word |
| `translation_field` | none | Item field with the free translation |
| `tiers` | `[]` | Extra lines per word, such as `[pos, notes]`. `word`, `morphemes` and `gloss` are reserved |
| `abbreviations` | none | `leipzig` for the standard list, a list of labels, or a mapping of label to meaning. `[leipzig, EVID, AOR]` adds your own labels to the standard ones. Without it, labels are not checked |
| `language` | none | Language tag set on the word and segmentation cells, and written to FLExText |
| `metalanguage` | none | Language tag for the gloss, tier and translation cells |
| `show_translation` | `true` | Shows the free translation line |
| `label_requirement` | none | `required: true` blocks Next until every word is segmented, glossed and aligned |

## Alignment and label checks

For each word, the segmentation and the gloss must have the same `-` (affix) and `=` (clitic) boundaries in the same order. `ros-am` with `rose-ACC.SG` is aligned, and `rose-ACC-SG` has one boundary too many. `vir-um=que` with `man-ACC.SG-and` has the right number of boundaries but glosses the clitic `=que` as an affix, so it is marked too.

A word is marked misaligned, with the reason under its column, when:

- the boundaries differ in number, kind or order;
- a morpheme or a gloss between two boundaries is empty (`ev--ler`, `house-`);
- a cell contains a space. Join the words of one gloss with `.` (`put.in.bag`), and separate morphemes with `-` or `=`.

Infixes in angle brackets (`s<um>ulat`) are counted in both lines but not paired by position, because the infix's gloss sits beside the stem's gloss rather than inside it.

A misaligned word has a red border, a `≠` before the word and `aria-invalid` on both cells, and a word with only one of the two lines filled is shown as not yet glossed. The count at the top of the widget says how many words are misaligned, and when the scheme is required, either state blocks Next.

Grammatical category labels (words in capitals and person-number combinations such as `ACC` and `3SG`) are shown under the gloss cell in small caps. With `abbreviations` set, a label not in the list appears as a warning under the word, such as "Unknown label: EVID", which does not block Next. The check accepts person and number written together (`3SG`), the `N-` prefix for "non-" (`NSG`, `NPST`), and `Ø`.

| Key | Action |
|---|---|
| Tab, Shift+Tab | Next or previous cell: down a word's lines, then on to the next word |
| Enter | Same line of the next word, or the translation from the last word |
| Shift+Enter | Same line of the previous word |

## Stored answer

```json
{"words": [{"word": "Puella", "morphemes": "puell-a", "gloss": "girl-NOM.SG",
            "pos": "n", "notes": ""}],
 "translation": "The girl loves the rose."}
```

An item that came with a pre-filled analysis is saved when the annotator presses Next, even if nothing was edited, so a confirmed import is stored as that person's answer. An item with no pre-fill is stored once the annotator types in it.

## Export

| Format | Files | Content |
|---|---|---|
| `flextext` | `<user>.flextext` | FieldWorks interlinear XML, one file per annotator |
| `toolbox` | `<user>.txt` | Toolbox standard format with column-aligned `\tx \mb \ge \ps \ft` lines |
| `igt` | `igt.txt`, `igt.tex` | Aligned plain text and gb4e LaTeX |

```bash
python -m potato.export --config config.yaml --format igt --output out/
```

`igt.tex` holds one `exe` environment with an `\ex` per stored answer, the segmentation and gloss on a `\gll` line, and the translation on `\glt`. Category labels are written as `\textsc{...}` in lower case, and LaTeX's special characters are escaped. Load `gb4e` in the preamble, and compile with XeLaTeX or LuaLaTeX for scripts other than Latin.

Words that are still misaligned are exported as stored, and the export prints how many there were. FLExText and Toolbox pair glosses with morphemes one to one, so a misaligned word's whole gloss goes on its first morpheme there.

## Example

```bash
python potato/flask_server.py start examples/span/interlinear-gloss/config.yaml -p 8000
```

The example has four Latin sentences glossed for illustration. One is complete, one is blank, one has a segmentation and no glosses, and one has a deliberate error, the clitic `-que` glossed with `-`.

## Further Reading

- [Linguistic Fieldwork](/docs/guides/linguistic-fieldwork) - Importing from FLEx and Toolbox and exporting back
- [Transcript Formats](/docs/annotation-types/transcript-formats) - Praat, ELAN and other time-aligned transcripts
- [Multilingual and Low-Resource Annotation](/docs/guides/multilingual-low-resource-annotation) - Annotating in many languages

For implementation details, see the [source documentation](https://github.com/davidjurgens/potato/blob/master/docs/annotation-types/text/interlinear_gloss.md).
