Making greenlandic a little easier to learn with sprinkles of lua and bash code
Stian Lybech is the author of a text book and learning resource on greenlandic which takes an approach to describing the language in quite a unique way. In his book An Introduction to West Greenlandic he does not introduce the reader to tables upon tables of conjugations and declensions for rote memorisation like the way many latin students are used to, rather he introduces the reader to a dozen or two sound rules which pave the way to understanding how the many conjugations and declensions of verbs and nouns have historically come about. Throughout his book he describes the approach of rote memorizing declension tables with no care for the much fewer constituent parts that gave rise to all the forms, i.e. the logic behind all those forms to learn, as a graphimist approach. The proponents of the approach are themselves graphimists. Greenlandic has a total of 906 unique verbal endings according to An Introduction to West Greenlandic, if you consider the 9 moods, up to 8 persons for intransitive verbal endings, up to 64 person combinations for the transitive verbal endings, and the up to 3 forms those endings can take depending on final phoneme of the stem the verbal ending is attaching to. However, with Lybech's approach, the constituents making up these endings behave in rather predictables ways (there are a couple of peculiarities) such that knowing 9 mood marker constituents for intransitive verbs, 9 more constituents for transitive verbs, a handful of extra mood marker constituents for the few moods that have special markers in e.g. negative vs. positive or near future, 8 person marker constituents that luckily mostly resemble each other in the intransitive as the transitive verb endings, as well as the sound rules that dictate how these constituents come together to form fully fletched verb ending morphemes (units of an utterance that contains meaning as in the 5 in "un-believ-able power-s"), is an approach that lets the learner remember far fewer things than rote memorising would force you to. These constituents, as well as the morphemes of greenlandic are notated in Lybech's learning material with a special notation he has devised himself. The notation of morphemes in this format reveals the given morpheme's sound rule behaviours in a way that dictionaries listing the words and morphemes in their written form cannot reveal. Greenland has two co-official orthographies, an old orthography and a new orthography, with the former revealing a little more about sound rule behaviours than the latter, and the latter being phonemic (written as spoken) first and foremost. Stian Lybech's morphemic format is sound rule revelation preserving first and foremost. He has dubbed this format his "Morphemic Format" or MOFO for short (pun entirely intentional) and he hosts and maintains a dictionary of his own at https://mofo.oqa.dk/ with morphemes notated using this notation system.
Stian Lybech also maintains a corpus of greenlandic texts from the text book Kalaallisut sungiusaatit by Christian Berthelsen which contains simple texts to practise greenlandic on. This corpus has sentences from the texts written out morpheme by morpheme in his notation system with hyperlinks to his dictionary entries describing not just meaning, but also sound rule behaviours that may not come across in the format itself. Stian Lybech uses his dictionary, text book, and corpus for his teaching of greenlandic to his handful of students that he teaches every Thursday. However, Lybech shared in a chat forum for inuit language learners (which he administrates) how he transcribes these sentences from the greenlandic practise text book, and how long it took to type out.
"Helikopteri Maniitsumut aallalerpoq" toml file
[[line]] source = "»Helikopteri Maniitsumut aallalerpoq, ilaasussat ikiartoqquneqarput,« angut højttalerikkut oqarpoq." translation = "»The helicopter is leaving for Maniitsoq, to-be passengers are requested to board,« says a man over the loudspeaker." words = [ "helikopteri", "Maniitsumut", "aallalerpoq", "ilaasussat", "ikiartoqquneqarput", "angut", "højttalerikkut", "oqarpoq" ] morphemes = [ ["?", "kl/ending/n/ABS.sg"], ["kl/base/n/maniitcuq", "kl/ending/n/ALL.sg"], ["kl/base/v/aullaq", "kl/affix/vv/-liq", "kl/ending/v/IND.3sg"], ["kl/base/n/ilauðuq", "kl/affix/nn/kcaq", "kl/ending/n/ABS.pl"], ["kl/base/v/əkə/1", "kl/affix/vv/(gi)jaqtuq", "kl/affix/vv/ðqu", "kl/affix/vv/nəqaq", "kl/ending/v/IND.3pl"], ["kl/base/n/aŋutə", "kl/ending/n/ABS.sg"], ["?", "kl/ending/n/VIA.sg"], ["kl/base/v/uqaq", "kl/ending/v/IND.3sg"] ] --[[ EMPTY LINE ]]--
This is how much he had to type to transcribe the greenlandic sentence
"'Helikopteri Maniitsumut aallalerpoq, ilaasussat ikiartoqquneqarput,'
angut højttalerikkut oqarpoq." havig to type
out ["kl/base/v/aullaq", "kl/affix/vv/-liq",
"kl/ending/v/IND.3sg"], just to transcribe "aallarlerpoq"
is a lot of work.
The morphemic format itself is actually only the parts
aullaq + -liq + vuq but because he needs to hyperlink it to
his dictionary this longer more verbose form is used in the
behind-the-scenes of his website.
This is where I realised I could be of help. I know Stian Lybech uses
neovim for his text editing, and spending some time making a macro to aid
in typing this out should be worthwhile as he is far far far from done
transcribing all texts in the Kalaallisut sungiusaatit text book. So
that's what I set out to do. I'd make him a little piece of lua code
that he could plop into his neovim configuration in order to open a menu
that would let him "fuzzy find" across any of the forms the morpheme
can appear as in writing (either old or new orthography) as well as the
morphemic format as he notates the morphemes.
Selecting a morpheme in this menu should print out the format used in
this document (the full kl/baffix/vv/-liq not
just -liq). To populate the menu with menu items to fuzzy
find across and select from, I needed the entire morphemic dictionary
stored in a file in a format that made sense for a menu select. I wanted
every menu item to begin with the long formats like
kl/baffix/vv/-liq and then followed by all the new
orthography forms and then old orthography forms that the given morpheme
is able to take. These would all be separated by a space in the menu item,
and selecting the menu item would paste only the line up until the first
space into the document being typed in neovim at the cursor's position.
The file the menu reads from to make menu items could be populated in this
exact format with a little bit of toml querying via the CLI-program
tomlq on the correct directory within the source of the data
for his dictionary website. Said data is available on
gitlab
and Lybech probably has that repo on his machine that he uses to
write the sentence transcriptions on, so all Lybech would have to do to
use the lua code I am sending him would be to provide the lua code a
location to a file that has to be created by a bash script that needs
to be provided a location to the languages/kl directory in
his dictionary data repository.
Here is the code I ended up providing him:
scraper.sh
#!/usr/bin/env bash --[[ EMPTY LINE ]]-- # using the yq tool. Please install that # # Save me as e.g. scraper.sh and make me executable with # `chmod +x scraper.sh` # # the find command below expects the path to mofodata's # language/kl directory. If you place this shell script in # the same dir that mofodata is cloned into, you should be # able to leave this as is, otherwise, adjust to your # correct language/kl locataion on your system. for tomlfile in $(find mofodata/languages/kl/ -type f); do cat $tomlfile | tomlq '"\(.morpheme.language)/\(.morpheme.type)/\(.morpheme.form)", .morpheme.inflection?, .orthographies.new[], .orthographies.old[]' | tr '\n' ' ' | tr -d '"' echo done --[[ EMPTY LINE ]]--
the .morpheme.inflection? query term behaves a little different from how I expect. It inserts the text "null" instead of just not inserting anything like I'd want. There is a very easy fix however, I just have to open the file I saved the menu items to in neovim and delete every instance of null with :%s/null //g.
lua-snippet.lua
local morphemes = (function() local file_exists = function(file) local f = io.open(file, "rb") if f then f:close() end return f ~= nil end -- The path to the special file, which I put in ~/morphemes.txt -- Although, lua didn't deal well with ~, so I had to qualify -- The whole path lol local kl_path = '' -- NOTE: remember to give it a value if not file_exists(kl_path) then return {} end local lines = {} for line in io.lines(kl_path) do lines[#lines+1] = line end return lines end)() --[[ EMPTY LINE ]]-- --[[ EMPTY LINE ]]-- local morpheme_pick = function(opts) local pickers = require "telescope.pickers" local finders = require "telescope.finders" local conf = require("telescope.config").values local actions = require "telescope.actions" local action_state = require "telescope.actions.state" --[[ EMPTY LINE ]]-- opts = opts or {} pickers.new(opts, { prompt_title = "morphemes", finder = finders.new_table { results = morphemes }, sorter = conf.generic_sorter(opts), ---@diagnostic disable-next-line: unused-local attach_mappings = function(prompt_bufnr, map) actions.select_default:replace(function() actions.close(prompt_bufnr) local selection = action_state.get_selected_entry() local to_put = string.match(selection[1], [[%S*]]) -- print(vim.inspect(selection)) vim.api.nvim_put({ to_put }, "", false, true) -- re-enter insert mode vim.api.nvim_feedkeys([[a]], [[n]], false) end) return true end, }):find() end --[[ EMPTY LINE ]]-- --[[ EMPTY LINE ]]-- vim.keymap.set('i', '', function() local dropdown = require("telescope.themes").get_dropdown{} morpheme_pick(dropdown) end) --[[ EMPTY LINE ]]--
It was greatly appreciated. A heart emoji react from Lybech to my message sharing the code in the forum, and a reply that reads "Wow, this is amazing! Thanks for that, I'll play around with it when I get home :D".