Skip to content

Instantly share code, notes, and snippets.

@inariksit
Last active June 19, 2024 10:09
Show Gist options
  • Save inariksit/28e182bd4f6881cd69eb96121f048829 to your computer and use it in GitHub Desktop.
Save inariksit/28e182bd4f6881cd69eb96121f048829 to your computer and use it in GitHub Desktop.
Simple GF grammar that demonstrates abstracting over inflection forms (not using RGL)
abstract Startups = {
flags startcat = S ;
cat
S ;
Kind ;
Item ;
Action ;
fun
-- Lexicon of Kinds
Capital : Kind ;
Company : Kind ;
EquityFinancing : Kind ;
Transaction : Kind ;
-- Modify with an Action
WithPurpose : Action -> Kind -> Kind ; -- transaction with the purpose of raising capital
-- Quantify Kinds into Items
IndefItem : Kind -> Item ; -- a company (count noun), capital (mass noun)
DefItem : Kind -> Item ; -- the company, the capital
-- Actions
Raise : Item -> Action ; -- raise capital
-- Sentences
DefinitionSentence : Kind -> Item -> S ;
ActionSentence : Item -> Action -> S ;
}
concrete StartupsEng of Startups = {
lincat
S = {s : Str} ;
Kind = {s : Str ; c : MassOrCount} ; -- mass or count noun
Item = {s : Str} ;
Action = {pred, mod : Str} ;
param
MassOrCount = Mass | Count ;
lin
-- : Kind
Capital = {s = "capital" ; c = Mass} ;
Company = {s = "company" ; c = Count} ;
EquityFinancing = {s = "equity financing" ; c = Mass} ;
Transaction = {s = "transaction" ; c = Count} ;
-- Modify with an Action
-- : Action -> Kind -> Kind ;
WithPurpose action kind = kind ** {
s = kind.s ++ "with the purpose of" ++ action.mod -- choose the modifier form, "raising capital"
} ;
-- Quantify Kinds into Items
-- : Kind -> Item ;
IndefItem kind = {s = article ++ kind.s}
where {
article : Str = case kind.c of {
Count => "a" ; -- simplification—the RGL has rules for a/an
Mass => [] } -- no indefinite article for mass nouns
} ;
DefItem kind = {s = "the" ++ kind.s} ;
-- Actions
-- : Item -> Action ;
Raise item = {
pred = "raises" ++ item.s ; -- raises capital
mod = "raising" ++ item.s ; -- raising capital
} ;
-- Sentences
-- : Kind -> Item -> S ;
DefinitionSentence kind item = {
s = kind.s ++ "means" ++ item.s
} ;
-- : Item -> Action -> S ;
ActionSentence item action = {
s = item.s ++ action.pred -- choose the predicative form, "raises capital" instead of "raising capital"
} ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment