More misc work

This commit is contained in:
Greg Shuflin 2023-07-11 01:17:41 -07:00
parent 3c87ec58c8
commit 6fee9d6e4c
2 changed files with 64 additions and 41 deletions

View File

@ -1,31 +1,53 @@
#import "linguistic-abbreviations.typ": * #import "linguistic-abbreviations.typ": *
= A linguistics paper #let custom_abbreviations = (
"FMNT": "Present/Future stem formant",
)
#{
standard_abbreviations.insert("FMNT", [formant])
}
#let fmnt = emit_abbreviation("FMNT") #let fmnt = emit_abbreviation("FMNT")
// An example function that uses `with_used_abbreviations`
#let print_usage_chart = with_used_abbreviations.with(debug: false)(final_used_abbreviations => {
let print_abbrevs(abbrv_list) = {
for abbrv in abbrv_list {
let explanation = if abbrv in standard_abbreviations {
standard_abbreviations.at(abbrv)
} else {
custom_abbreviations.at(abbrv)
}
[#smallcaps(lower(abbrv)) #h(2em) #explanation]
linebreak()
}
}
heading(level: 3)[Abbreviations in order of use]
print_abbrevs(final_used_abbreviations.keys())
heading(level: 3)[Abbreviations in alphabetical order]
let sorted_abbreviations = final_used_abbreviations.keys().sorted()
print_abbrevs(sorted_abbreviations)
})
= Some linguistics paper
== Abbreviations used in this document == Abbreviations used in this document
#print_usage_chart #print_usage_chart
== The meat of the paper == The main body of the paper
The #p1#sg pronoun in Spanish is _yo_. The #p2#sg pronoun in Spanish is _tu_.
The #p1#sg pronoun in Spanish is "yo" The six cases of Latin are:
- Nominative (#nom)
- Genitive (#gen)
- Dative (#dat)
- Accusative (#acc)
- Ablative (#abl)
- Vocative (#voc)
The #p2#sg pronoun in Spanish is "tu" The Present/Future stem formant (#fmnt) in Georgian disappears in perfective screeves.
The #abl case exists in Latin.
#non#abl is cool
I use #acc for breakfast
#all case best casea
#voc best case
Present/future stem #fmnt

View File

@ -86,33 +86,34 @@
"VOC": "vocative", "VOC": "vocative",
) )
// A dictionary used as a set to mark which abbreviations have been used by a call to
// `emit_abbreviation`. Each key in the dictionary is the string symbol of that abbreviation,
// and the value is always `true`.
#let used_abbreviations = state("leipzig-gloss-used-abbreviations", (:))
#let used_abbreviations = state("used-abbreviations", (:)) // Accepts a callback that accepts the state of the `used_abbreviations`
// dictionary at the end of the document. Also an additional debug parameter
#let print_usage_chart = { #let with_used_abbreviations(callback, debug: false) = {
locate(loc => { locate(loc => {
let final_used_abbreviations = used_abbreviations.final(loc) let final_used_abbreviations = used_abbreviations.final(loc)
//TODO this is debugging get rid of soon if debug {
for (key, value) in final_used_abbreviations { for (key, value) in final_used_abbreviations {
[#key was used: #value] [#key was used: #value]
linebreak()
}
linebreak() linebreak()
} }
linebreak() callback(final_used_abbreviations)
//TODO requires standard_abbreviations to be sorted alphabetically, can this be enforced?
for (abbrv, explanation) in standard_abbreviations {
if abbrv in final_used_abbreviations {
[#smallcaps(lower(abbrv)) #h(2em) #explanation]
linebreak()
}
}
}) })
} }
// Public function. Given a symbol that is a string, emits
#let fmnt = smallcaps([fmnt]) // the lowercase version of that string in smallcaps format, and adds
// its use to the `used_abbreviations` table
#let emit_abbreviation(symbol) = { #let emit_abbreviation(symbol) = {
let mark_used(symbol) = { let mark_used(symbol) = {
used_abbreviations.update(cur => { used_abbreviations.update(cur => {
@ -161,7 +162,7 @@
#let dur = emit_abbreviation("DUR") #let dur = emit_abbreviation("DUR")
#let erg = emit_abbreviation("ERG") #let erg = emit_abbreviation("ERG")
#let excl = emit_abbreviation("EXCL") #let excl = emit_abbreviation("EXCL")
#let f = emit_abbreviation("F") #let F = emit_abbreviation("F")
#let foc = emit_abbreviation("FOC") #let foc = emit_abbreviation("FOC")
#let fut = emit_abbreviation("FUT") #let fut = emit_abbreviation("FUT")
#let gen = emit_abbreviation("GEN") #let gen = emit_abbreviation("GEN")
@ -175,8 +176,8 @@
#let ipfv = emit_abbreviation("IPFV") #let ipfv = emit_abbreviation("IPFV")
#let irr = emit_abbreviation("IRR") #let irr = emit_abbreviation("IRR")
#let loc = emit_abbreviation("LOC") #let loc = emit_abbreviation("LOC")
#let m = emit_abbreviation("M") #let M = emit_abbreviation("M")
#let n = emit_abbreviation("N") #let N = emit_abbreviation("N")
#let non = emit_abbreviation("N-") #let non = emit_abbreviation("N-")
#let neg = emit_abbreviation("NEG") #let neg = emit_abbreviation("NEG")
#let nmlz = emit_abbreviation("NMLZ") #let nmlz = emit_abbreviation("NMLZ")
@ -197,13 +198,13 @@
#let pst = emit_abbreviation("PST") #let pst = emit_abbreviation("PST")
#let ptcp = emit_abbreviation("PTCP") #let ptcp = emit_abbreviation("PTCP")
#let purp = emit_abbreviation("PURP") #let purp = emit_abbreviation("PURP")
#let q = emit_abbreviation("Q") #let Q = emit_abbreviation("Q")
#let quot = emit_abbreviation("QUOT") #let quot = emit_abbreviation("QUOT")
#let recp = emit_abbreviation("RECP") #let recp = emit_abbreviation("RECP")
#let refl = emit_abbreviation("REFL") #let refl = emit_abbreviation("REFL")
#let rel = emit_abbreviation("REL") #let rel = emit_abbreviation("REL")
#let res = emit_abbreviation("RES") #let res = emit_abbreviation("RES")
#let s = emit_abbreviation("S") #let S = emit_abbreviation("S")
#let sbj = emit_abbreviation("SBJ") #let sbj = emit_abbreviation("SBJ")
#let sbjv = emit_abbreviation("SBJV") #let sbjv = emit_abbreviation("SBJV")
#let sg = emit_abbreviation("SG") #let sg = emit_abbreviation("SG")