flang the compiler proves your program cannot hang 0.7.41 GitHub Try in the browserTry it Русский

Parsing a Russian utterance against a concept graph

The module flang/ct/russian/syntax.flang checks an analysis of a Russian utterance. The analysis is a text file. Each line is one claim. The module checks the claim against two sources: it looks the concept up in a slice of the concept graph of the Russian Academy Grammar (1980), and it takes the grammatical tags of word forms from the dictionary of the pregroup grammar.

Line format

A line reads role: content. The role is everything before the first : .

A category is checked only when both word forms carry it. A plural form has no gender, so gender is skipped. When no category could be checked, the pair counts as not agreeing. A word form missing from the dictionary gives «Нет помет» (no tags).

Running

The result of an analysis in one line:

flang run flang/ct/russian/syntax.flang --function '«Итог разбора»' \
  --args "$(jq -Rs '{"текст разбора": .}' flang/ct/russian/syntax-texts/first-sentence.dsl)"
"опор 25, сверок 11, без опоры 4, разрывов 0, нет в графе 0, нет помет 0, не согласовано 0"

That is: 25 concepts found, 11 agreement checks, 4 lines without support, no broken chain, no unknown concept, no word form without tags, no failed agreement.

The function «Разобрать высказывание» takes the same arguments and prints the whole analysis as a JSON list. Three kinds of entries from it:

{"вариант":"Опора","роль":"Уровень","узел":"письменная речь","место":"§ 1890","цитата":"Языковое общение людей (языковая коммуникация), как непосредственное, устное, так и письменное, осуществляется в форме, которую можно назвать потоком речи или просто речью.","путь":"речь → письменная речь"}
{"вариант":"Связь форм","сверка":{"роль":"Согласование в роде, числе и падеже","зависимое":"русский","главное":"язык","проверено":[{"название":"род","общие":["мужской род"]},{"название":"число","общие":["единственное число"]},{"название":"падеж","общие":["именительный падеж","винительный падеж"]}],"согласовано":true}}
{"вариант":"Опоры нет","что":"запятая между частями — Правила 1956 года, § 143; правил знаков в графе нет"}

A broken chain looks like this:

flang run flang/ct/russian/syntax.flang --function '«Итог разбора»' \
  --args '{"текст разбора": "Уровень: речь\nУровень: схема 4. N₁ — N₁"}'
"опор 1, сверок 0, без опоры 0, разрывов 1, нет в графе 0, нет помет 0, не согласовано 0"

No arrow links a sentence pattern to speech.

«Найти пометы» shows the tags of one word form:

flang run flang/ct/russian/syntax.flang --function '«Найти пометы»' --args '{"словоформа":"системой"}'
{"вариант":"Найдены","найденные":[{"разряд":"род","значение":"женский род"},{"разряд":"число","значение":"единственное число"},{"разряд":"падеж","значение":"творительный падеж"},{"разряд":"лицо","значение":"3 лицо"}]}

Examples

The first three sentences of the grammar's Introduction are analysed in flang/ct/russian/syntax-texts/:

FileLinesResult
first-sentence.dsl4125 concepts found, 11 agreement checks, 4 lines without support
second-sentence.dsl2315 concepts found, 6 agreement checks, 1 line without support
third-sentence.dsl2415 concepts found, 7 agreement checks, 1 line without support

In all three files the steps are linked, every concept name is found and every agreement check passes.

Where the data comes from

The concepts live in flang/ct/russian/syntax-graph.flang. It holds a slice of the grammar's concept graph: 97 concepts and 126 arrows. The slice holds the concepts named in the three files and all their parents along the arrows «вид», «входит в», «является», «деление». Each concept carries its paragraph of the grammar and one verbatim quote from it.

The tags — gender, number, case and person — are read from the dictionary flang/ct/russian/lexicon.flang, the same one the pregroup grammar parses sentences with. The module keeps no tag table of its own. The word forms of the three analyses are entered in the dictionary, which now has six cases: the instrumental (тв) was added. The grammar page shows how to enter a new word.

Limits