Documentation

Linglib.Data.Examples.Schema

Data from examples #

This file defines the data a study reads off a paper's examples, and the lookups it makes on them. An example is what the paper prints under a number; a Datum is one piece of data the paper reports with it in the sense of Tonhauser and Matthewson: an expression (the example, or one alternant of it), the context it is judged in, and the judgment, less the information about the speakers that papers seldom give. A datum is a row of the Examples component of the Cross-Linguistic Data Formats of Forkel et al., in version 1.3, and the sentence-level counterpart of Data/Forms/.

Main definitions #

Main statements #

Implementation notes #

TODO #

References #

@[reducible, inline]

A Glottolog language identifier, such as "stan1293" for Standard English.

Equations
Instances For
    structure SourceRef :

    A SourceRef is a CLDF source reference bibkey[locator] with its two parts kept apart.

    • bibkey : String

      The key of the paper's entry in references.bib.

    • paperLabel : String

      The locator in the paper: its example number, table or page.

    Instances For
      def instDecidableEqSourceRef.decEq (x✝ x✝¹ : SourceRef) :
      Decidable (x✝ = x✝¹)
      Equations
      • instDecidableEqSourceRef.decEq { bibkey := a, paperLabel := a_1 } { bibkey := b, paperLabel := b_1 } = if h : a = b then h ▸ if h : a_1 = b_1 then h ▸ isTrue ⋯ else isFalse ⋯ else isFalse ⋯
      Instances For
        def instReprSourceRef.repr :
        SourceRef → ℕ → Std.Format
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          @[instance_reducible]
          Equations
          structure Datum :

          A Datum is a piece of data a paper reports with one of its examples [TM16]: an expression of a language with its gloss, the context it is judged in, the judgment, the forms and readings the paper judges with it, and the paper's own classifications of it. It is the part of a row of a CLDF ExampleTable that theorems read.

          • id : String

            The ID column holds a stable identifier keyed to the paper, {authoryear}_{label}.

          • source : SourceRef

            The paper that introduced the example.

          • reportedIn : Option SourceRef

            The paper whose data file holds the row, when it only reports an example from source.

          • language : Glottocode

            The Language_ID column holds the Glottocode of the language of the expression; empty for a constructed string of no language.

          • primaryText : String

            The Primary_Text column holds the expression without judgment marks.

          • glossedTokens : List (String × String)

            The Analyzed_Word and Gloss columns paired, each word with its gloss; empty when the source gives no gloss.

          • context : String

            The scenario the source gives for the judgment; empty when it gives none.

          • judgment : Judgment

            The judgment the source reports for the expression in the context.

          • alternatives : List (String × Judgment)

            The other forms the source judges in the same frame, each a whole sentence, with their judgments.

          • readings : List (String × Judgment)

            The readings the source distinguishes for the expression, each with its judgment.

          • paperFeatures : List (String × String)

            The paper's own columns, as key-value pairs.

          Instances For
            def instDecidableEqDatum.decEq (x✝ x✝¹ : Datum) :
            Decidable (x✝ = x✝¹)
            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              @[instance_reducible]
              instance instDecidableEqDatum :
              DecidableEq Datum
              Equations
              @[instance_reducible]
              instance instReprDatum :
              Repr Datum
              Equations
              def instReprDatum.repr :
              Datum → ℕ → Std.Format
              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                def Datum.digits? (cs : List Char) :
                Option ℕ

                digits? cs is the number that the nonempty string of decimal digits cs denotes.

                Equations
                • Datum.digits? cs = if cs ≠ [] ∧ cs.all Char.isDigit = true then some (List.foldl (fun (n : ℕ) (c : Char) => 10 * n + (c.toNat - '0'.toNat)) 0 cs) else none
                Instances For
                  def Datum.surfaceTokens (e : Datum) :
                  List String

                  e.surfaceTokens is the Analyzed_Word column, the words of e.glossedTokens.

                  Equations
                  Instances For
                    def Datum.glossLine (e : Datum) :
                    List String

                    e.glossLine is the Gloss column, the glosses of e.glossedTokens.

                    Equations
                    Instances For
                      def Datum.feature? (e : Datum) (key : String) :
                      Option String

                      e.feature? key is the first value of key in e.paperFeatures, if there is one.

                      Equations
                      Instances For
                        def Datum.features (e : Datum) (key : String) :
                        List String

                        e.features key is the list of values of key in e.paperFeatures, in order.

                        Equations
                        • e.features key = List.filterMap (fun (kv : String × String) => if kv.1 = key then some kv.2 else none) e.paperFeatures
                        Instances For
                          def Datum.parse? (e : Datum) (key : String) {α : Type u_1} (table : List (String × α)) :
                          Option α

                          e.parse? key table is the entry of table under the first value of key in e, if e has the key and table lists its value.

                          Equations
                          • e.parse? key table = (e.feature? key).bind fun (x : String) => List.lookup x table
                          Instances For
                            def Datum.nat? (e : Datum) (key : String) :
                            Option ℕ

                            e.nat? key is the first value of key in e read as a decimal numeral.

                            Equations
                            Instances For
                              def Datum.int? (e : Datum) (key : String) :
                              Option ℤ

                              e.int? key is the first value of key in e read as a decimal integer, an optional - followed by digits.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                def Datum.decimal? (e : Datum) (key : String) :
                                Option Rat

                                e.decimal? key is the first value of key in e read as an unsigned decimal numeral, digits with an optional fractional part after a point.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For

                                  e.judgments is every mark the paper prints on e: its judgment, then the further marks of a split mark such as ??/*, recorded as alsoJudged.

                                  Equations
                                  Instances For

                                    The paper judges e felicitous: it prints no mark on e, and its prose does not call e infelicitous, which the row records as felicity: infelicitous.

                                    Equations
                                    Instances For
                                      @[instance_reducible]
                                      Equations
                                      @[simp]
                                      theorem Datum.mem_features {e : Datum} {key v : String} :
                                      v ∈ e.features key ↔ (key, v) ∈ e.paperFeatures
                                      theorem Datum.features_eq_nil {e : Datum} {key : String} :
                                      e.features key = [] ↔ ∀ (v : String), (key, v) ∉ e.paperFeatures
                                      @[simp]
                                      theorem Datum.head?_features {e : Datum} {key : String} :
                                      (e.features key).head? = e.feature? key
                                      theorem Datum.feature?_eq_none {e : Datum} {key : String} :
                                      e.feature? key = none ↔ ∀ (v : String), (key, v) ∉ e.paperFeatures