Last active
June 13, 2021 14:41
-
-
Save igneus/f6fb42bd5c3901c6549569e6b6f51b55 to your computer and use it in GitHub Desktop.
How often does a term appear in individual days of the LOTH Psalter cycle?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# accepts https://github.com/igneus/In-adiutorium/blob/master/antifonar/antifonar_zaltar.ltex | |
# as input, prints psalter distribution as YAML | |
started = false | |
ARGF.each_line do |line| | |
case line | |
when /^\\nadpisTyden\{.+?\}\{(\d.+)\}/ | |
started = true | |
puts "#{$1}:" | |
when /^\\nadpisDen\{(.+)\}/ | |
puts " #{$1}:" | |
when /^\\(modlitbaSeCtenim|ranniChvaly|modlitbaUprostredDne|nespory)/ | |
puts " #{$1}:" | |
when /^\\(zalm|kantikum)\{(.+)\}/ | |
break if $2 == 'nuncdimittis' | |
puts " - '#{$2}'" if started | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# accepts | |
# a YAML file specifying psalter distribution, | |
# a search term for grep | |
# and path to psalms https://github.com/igneus/In-adiutorium/tree/master/antifonar/zalmy | |
# prints how frequently the term occurs in each day of the psalter | |
require 'yaml' | |
PSALTER = ARGV[0] | |
TERM = ARGV[1] | |
PSALMS_DIR = ARGV[2..-1] | |
GrepHit = Struct.new :psalm_code, :verse_part | |
# parse grep output | |
def grep_parse(output) | |
output.each_line.collect do |line| | |
line.match(/(zalm|kantikum_)([\da-z]+?).zalm:(.*)/) do |m| | |
GrepHit.new $2, $3 | |
end || raise("failed to parse '#{line}'") | |
end | |
end | |
def psalter_reverse_map(psalter) | |
r = {} | |
psalter.each_pair do |week_title, week_content| | |
week_content.each_pair do |day_title, day_content| | |
day_content.each_pair do |hour_title, hour_content| | |
hour_content.each do |psalm_code| | |
r[psalm_code] ||= [] | |
r[psalm_code] << "#{week_title} : #{day_title}" | |
end | |
end | |
end | |
end | |
r | |
end | |
def hits_per_day(map, hits) | |
r = {} | |
hits.each do |hit| | |
days_using_psalm = map[hit.psalm_code] | |
if days_using_psalm.nil? | |
STDERR.puts "#{hit.psalm_code} is not used in the Psalter cycle" | |
next | |
end | |
days_using_psalm.each do |day| | |
r[day] ||= [] | |
r[day] << hit | |
end | |
end | |
r | |
end | |
map = psalter_reverse_map YAML.load File.read PSALTER | |
hits = grep_parse `grep -r #{TERM} #{PSALMS_DIR.join(' ')}` | |
hits_per_day(map, hits) | |
.each_pair | |
.sort_by {|title, hits| hits.size } | |
.reverse # descending | |
.each do |title, hits| | |
puts "#{title}:" | |
hits.each do |hit| | |
puts " '#{hit.psalm_code}': '#{hit.verse_part}'" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# paths specific for my workstation | |
PSALTER_PATH=~/In-adiutorium/antifonar/antifonar_zaltar.ltex | |
PSALMS_PATH=~/In-adiutorium/antifonar/zalmy/*.zalm | |
SEARCH_TERM=tvář | |
ruby psalter_latex_to_yaml.rb $PSALTER_PATH > psalter.yaml | |
ruby psalter_term_frequency.rb psalter.yaml $SEARCH_TERM $PSALMS_PATH |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'2. týden žaltáře : Čtvrtek': # Thursday W2 | |
'44iii': 'Proč [skrý]váš [svou] tvář, *' | |
'44ii': 'stud se mi [hr]ne [do] tváře,' # face of the Psalmist | |
'44i': 'tvá jasná tvář, neboť [jsi] je [mi]loval.' | |
'80': 'rozjasni svou tvář, a [bu]deme [spa]seni.' | |
'80': 'rozjasni svou tvář, a [bu]deme [spa]seni.' | |
'80': 'rozjasni svou tvář, a [bu]deme [spa]seni. ' | |
'3. týden žaltáře : Pátek': # Friday W3 | |
'22iii': 'ne/skryl [před] ním [svou] tvář, *' | |
'51': 'Odvrať svou tvář [od] mých [hří]chů *' | |
'69ii': 'Neskrývej svou tvář před svým [slu]žeb[ní]kem; *' | |
'69i': 'pohana [po]kryla [mou] tvář.' # face of the Psalmist | |
'1. týden žaltáře : Středa': # Wednesday W1 | |
'17ii': 'Já však ve spravedlnosti [u]zřím [tvou] tvář, *' | |
'27ii': 'Mé srdce k tobě mluví, má [tvář] tě [hle]dá: *' # face of the Psalmist | |
'27ii': 'Hospodine, [hle]dám [tvou] tvář.' | |
'27ii': 'Neskrývej [svou] tvář [pře]de mnou, *' | |
'4. týden žaltáře : Čtvrtek': # Thursday W4 | |
'143': 'Neskrývej [pře]de mnou [svou] tvář, *' | |
'44iii': 'Proč [skrý]váš [svou] tvář, *' | |
'44ii': 'stud se mi [hr]ne [do] tváře,' # face of the Psalmist | |
'44i': 'tvá jasná tvář, neboť [jsi] je [mi]loval.' | |
'3. týden žaltáře : Čtvrtek': # Thursday W3 | |
'132i': 'neodmítej tvář svého [po]ma[za]ného! ' # face of the Anointed One | |
'80': 'rozjasni svou tvář, a [bu]deme [spa]seni.' | |
'80': 'rozjasni svou tvář, a [bu]deme [spa]seni.' | |
'80': 'rozjasni svou tvář, a [bu]deme [spa]seni. ' | |
'2. týden žaltáře : Pondělí': # Monday W2 | |
'42': 'kdy už smím přijít a [spat]řit [Bo]ží tvář?' | |
'31iii': 'Tvoje tvář je jim [bez]pečnou [o]chranou *' | |
'31ii': 'Svou jasnou tvář ukaž svému [slu]žeb[ní]ku, *' | |
'42': 'kdy už smím přijít a [spat]řit [Bo]ží tvář?' | |
'1. týden žaltáře : Úterý': # Tuesday W1 | |
'tob13i': 'a už před vámi [ne]skryje [svo]ji tvář. | |
'10i': 'odvrátil svou tvář, [vů]bec se [ne]dívá!"' | |
'13': 'jak dlouho budeš přede mnou [skrý]vat [svou] tvář?' | |
'24': 'kdo hledají tvář Jaku[bo]va [Bo]ha. ' | |
'4. týden žaltáře : Úterý': # Tuesday W4 | |
'dan3i': 'bojíme se tě a [hle]dá/me [tvou] tvář. ' | |
'102i': 'Neskrývej [tvář] svou [pře]de mnou *' | |
'138': 'vrhnu se na tvář směrem k tvému [sva]tému [chrá]mu' # face of the Psalmist | |
'88ii': 'a přede mnou [skrý]váš [svou] tvář? ' | |
'1. týden žaltáře : Sobota': # Saturday W1 | |
'105i': 'stále [hle]dejte [je]ho tvář!' | |
'132i': 'neodmítej tvář svého [po]ma[za]ného! ' # face of the Anointed One | |
'34i': 'vaše tvář se nemusí [za]rdívat [han]bou.' # face(s) of Israel | |
'2. týden žaltáře : Neděle': # Sunday W2 | |
'104iii': 'Děsí se, když skryješ [svou] tvář, +' | |
'104iii': 'a obno[vu]ješ tvář [ze]mě.' # face of the Earth | |
'104ii': 'aby olejem [roz]jas[nil] tvář *' # face of any human | |
'1. týden žaltáře : Pátek': # Friday W1 | |
'41': 'navěky mě [po]stavíš [před] svou tvář.' | |
'51': 'Odvrať svou tvář [od] mých [hří]chů *' | |
'1. týden žaltáře : Pondělí': # Monday W1 | |
'11': 'zbožní [u]zří [je]ho tvář.' | |
'5': 'padnu na tvář před tvým [sva]tým [chrá]mem *' # face of the Psalmist | |
'3. týden žaltáře : Pondělí': # Monday W3 | |
'84': 'popatř na tvář svého [po]ma[za]ného!' # face of the Anointed One | |
'3. týden žaltáře : Úterý': # Tuesday W3 | |
'67': 'ukaž [nám] svou [jas]nou tvář, ' | |
'2. týden žaltáře : Středa': # Wednesday W2 | |
'67': 'ukaž [nám] svou [jas]nou tvář, ' | |
'4. týden žaltáře : Pátek': # Friday W4 | |
'51': 'Odvrať svou tvář [od] mých [hří]chů *' | |
'2. týden žaltáře : Pátek': # Friday W2 | |
'51': 'Odvrať svou tvář [od] mých [hří]chů *' | |
'3. týden žaltáře : Sobota': # Saturday W3 | |
'34i': 'vaše tvář se nemusí [za]rdívat [han]bou.' # face(s) of Israel | |
'1. týden žaltáře : Čtvrtek': # Thursday W1 | |
'30': 'sotva jsi skryl svou tvář, [pa]dl jsem [v zma]tek.' | |
'4. týden žaltáře : Neděle': # Sunday W4 | |
'24': 'kdo hledají tvář Jaku[bo]va [Bo]ha. ' | |
'4. týden žaltáře : Pondělí': # Monday W4 | |
'119pe': 'Jasnou tvář ukaž svému [slu]žeb[ní]ku *' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment