Documentation

Linglib.Data.Examples.Gloss

The gloss line as structured data #

A glossed token is already structured: the Leipzig Glossing Rules segment the surface word and its gloss at the same affix and clitic boundaries (Rule 2), separate by periods the several metalanguage elements that render one object-language element (Rule 4), and write grammatical category labels in capitals (Rule 3), so a row's gloss line determines a morph-by-morph token stream without any analysis beyond the source's own. This file reads that structure: a GlossedWord is a token's surface morphs beside their glosses, a gloss element is a category label or a lexical gloss by its capitalization, and Datum.glossedWords lists a row's well-aligned tokens. Readers built on it consult the row's form rather than a curated feature, the first step from annotated stimuli toward parsed ones.

Main definitions #

Implementation notes #

References #

def Gloss.toLower (c : Char) :
Char

Char.toLower extended over the Latin-1 Supplement and Latin Extended-A capitals by the Unicode case pairings of those blocks, with dotted İ lowered to i; Char.toLower itself only lowers ASCII.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    def Gloss.split (seps : List Char) :
    List Char → List (List Char)

    Splits a list of characters at the given separators. Core has List.splitOn, but its body does not reduce across the module boundary under decide, so the recursion is restated here structurally.

    Equations
    Instances For
      def Gloss.segments (s : String) :
      List (List Char)

      The morphs of a token, split at the affix boundary - and the clitic boundary = of the Leipzig rules.

      Equations
      Instances For
        def Gloss.punct :
        List Char

        The punctuation written around morphs: the brackets of optional material and sentence marks.

        Equations
        • Gloss.punct = ['(', ')', '[', ']', ',', '.', '!', '?', ';', ':', '\"', '…']
        Instances For
          def Gloss.trim (m : List Char) :
          List Char

          A surface morph with its annotation punctuation dropped: the brackets of optional material may sit inside a token, as in (þangað) til.

          Equations
          Instances For
            def Gloss.tokens (s : String) :
            List (List Char)

            The words of an orthographic sentence: split at spaces, annotation punctuation dropped, decapitalized. For a language whose sources print no gloss line, the words are matched against the forms the language's fragment declares or realizes, which play the gloss line's role.

            Equations
            Instances For
              def Gloss.formTokens (f : String) :
              List (List Char)

              A declared, possibly multiword, form as the normalized tokens a row's stream shows. The fragments keep their forms raw; normalization happens here, where a reader meets a row.

              Equations
              Instances For
                def Gloss.lookup? {α : Type u_1} (lex : List (String × α)) :
                List (List Char) → Option α

                The entry of lex whose declared form starts earliest in the stream, the first listed where several start together.

                Equations
                • One or more equations did not get rendered due to their size.
                • Gloss.lookup? lex [] = none
                Instances For
                  def Gloss.containsForm (ts : List (List Char)) (f : String) :
                  Bool

                  The stream shows the declared form f.

                  Equations
                  Instances For
                    def Gloss.IsLabel (g : List Char) :

                    A gloss is a category label, as the Leipzig rules write PST or 3SG.DF, when it has no lower-case letter; otherwise it is a lexical gloss.

                    Equations
                    Instances For
                      @[instance_reducible]
                      instance Gloss.instDecidableIsLabel (g : List Char) :
                      Decidable (IsLabel g)
                      Equations
                      def Gloss.elements (g : List Char) :
                      List (List Char)

                      The elements of a morph's gloss: an object-language element rendered by several metalanguage elements, words or category labels, has them separated by periods (Rule 4), as come.out or left.SG.MASC.

                      Equations
                      Instances For
                        def Gloss.labels (g : String) :
                        List (List Char)

                        The category labels of a gloss: the elements of its morphs written without lower-case letters (Rules 2–4), as PST and 3SG in be-PST.3SG.

                        Equations
                        Instances For
                          structure GlossedWord :

                          A token of the gloss line as the Leipzig rules structure it: each surface morph beside its gloss, in order.

                          • morphs : List (List Char × List Char)

                            The surface morphs with their glosses.

                          Instances For
                            def instDecidableEqGlossedWord.decEq (x✝ x✝¹ : GlossedWord) :
                            Decidable (x✝ = x✝¹)
                            Equations
                            Instances For
                              def instReprGlossedWord.repr :
                              GlossedWord → ℕ → Std.Format
                              Equations
                              • instReprGlossedWord.repr x✝ prec✝ = Std.Format.bracket "{ " (Std.Format.nil ++ Std.Format.text "morphs" ++ Std.Format.text " := " ++ (Std.Format.nest 10 (repr x✝.morphs)).group) " }"
                              Instances For
                                @[instance_reducible]
                                Equations
                                def GlossedWord.stem (w : GlossedWord) :
                                List Char

                                The word's first surface morph, decapitalized: the form that a lexicon keys.

                                Equations
                                Instances For
                                  def GlossedWord.labels (w : GlossedWord) :
                                  List (List Char)

                                  The category labels among the elements of the word's glosses.

                                  Equations
                                  Instances For
                                    def GlossedWord.lexicalGloss? (w : GlossedWord) :
                                    Option (List Char)

                                    The word's first lexical gloss, where it has one.

                                    Equations
                                    Instances For
                                      def GlossedWord.lexicalMorph? (w : GlossedWord) :
                                      Option (List Char)

                                      The surface morph of the word's first lexical gloss, decapitalized: the form that a lexicon of roots keys.

                                      Equations
                                      Instances For
                                        def GlossedWord.wordform (w : GlossedWord) :
                                        List Char

                                        The word's surface form: its morphs joined, decapitalized.

                                        Equations
                                        Instances For

                                          The row's tokens whose surface and gloss segment alike, each as a GlossedWord, its surface morphs trimmed of surrounding punctuation.

                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For
                                            def Datum.glossStream (e : Datum) :
                                            List (List Char)

                                            The row's gloss-line stream: each glossed word's form, split at its internal spaces, the stream that declared forms are matched against.

                                            Equations
                                            Instances For