Compare commits

...

3 Commits

Author SHA1 Message Date
Greg Shuflin
2b5cad038d Use-order and alphabetical used symbols 2023-07-11 01:33:29 -07:00
Greg Shuflin
6fee9d6e4c More misc work 2023-07-11 01:17:41 -07:00
Greg Shuflin
3c87ec58c8 Hide helper function in closure 2023-07-11 00:42:45 -07:00
2 changed files with 76 additions and 51 deletions

View File

@ -1,31 +1,58 @@
#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")
// An example function that uses `with_used_abbreviations`
#let print_usage_chart = with_used_abbreviations.with(debug: false)(final_used_abbreviations => {
show terms: t => {
for t in t.children [
#t.term #h(2cm) #t.description\
]
}
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)
}
terms((smallcaps(lower(abbrv)), explanation))
}
}
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
#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,44 +86,42 @@
"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", (:))
#let print_usage_chart = {
locate(loc => {
// Accepts a callback that accepts the state of the `used_abbreviations`
// dictionary at the end of the document. Also an additional debug parameter
#let with_used_abbreviations(callback, debug: false) = {
locate(loc => {
let final_used_abbreviations = used_abbreviations.final(loc)
//TODO this is debugging get rid of soon
for (key, value) in final_used_abbreviations {
[#key was used: #value]
if debug {
for (key, value) in final_used_abbreviations {
[#key was used: #value]
linebreak()
}
linebreak()
}
linebreak()
//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()
}
}
})
}
#let fmnt = smallcaps([fmnt])
//Appendix: List of Standard Abbreviations
#let mark_used(symbol) = {
used_abbreviations.update(cur => {
cur.insert(symbol, true)
cur
callback(final_used_abbreviations)
})
}
// Public function. Given a symbol that is a string, emits
// the lowercase version of that string in smallcaps format, and adds
// its use to the `used_abbreviations` table
#let emit_abbreviation(symbol) = {
let mark_used(symbol) = {
used_abbreviations.update(cur => {
cur.insert(symbol, true)
cur
})
}
mark_used(symbol)
smallcaps(lower(symbol))
}
@ -164,7 +162,7 @@
#let dur = emit_abbreviation("DUR")
#let erg = emit_abbreviation("ERG")
#let excl = emit_abbreviation("EXCL")
#let f = emit_abbreviation("F")
#let F = emit_abbreviation("F")
#let foc = emit_abbreviation("FOC")
#let fut = emit_abbreviation("FUT")
#let gen = emit_abbreviation("GEN")
@ -178,8 +176,8 @@
#let ipfv = emit_abbreviation("IPFV")
#let irr = emit_abbreviation("IRR")
#let loc = emit_abbreviation("LOC")
#let m = emit_abbreviation("M")
#let n = emit_abbreviation("N")
#let M = emit_abbreviation("M")
#let N = emit_abbreviation("N")
#let non = emit_abbreviation("N-")
#let neg = emit_abbreviation("NEG")
#let nmlz = emit_abbreviation("NMLZ")
@ -200,13 +198,13 @@
#let pst = emit_abbreviation("PST")
#let ptcp = emit_abbreviation("PTCP")
#let purp = emit_abbreviation("PURP")
#let q = emit_abbreviation("Q")
#let Q = emit_abbreviation("Q")
#let quot = emit_abbreviation("QUOT")
#let recp = emit_abbreviation("RECP")
#let refl = emit_abbreviation("REFL")
#let rel = emit_abbreviation("REL")
#let res = emit_abbreviation("RES")
#let s = emit_abbreviation("S")
#let S = emit_abbreviation("S")
#let sbj = emit_abbreviation("SBJ")
#let sbjv = emit_abbreviation("SBJV")
#let sg = emit_abbreviation("SG")