Sefaria / Sefaria-Project

New Interfaces for Jewish Texts
https://www.sefaria.org
654 stars 268 forks source link

Get Bavli perek number from Ref #502

Closed dimidd closed 4 years ago

dimidd commented 4 years ago

Hi,

Given a Ref such as Ref('Berakhot 2a:6') how can I get its chapter number using the python api? I.e. as in here: https://he.wikisource.org/wiki/%D7%91%D7%91%D7%9C%D7%99_%D7%91%D7%A8%D7%9B%D7%95%D7%AA

JonMosenkis commented 4 years ago

The Ref object does not contain that information. You need to retrieve that from the alt_struct on the index.

r = Ref('Berakhot 2a:6')
berakhot_index = r.index
for node in berakhot_index.alt_structs['Chapters']['nodes']:
    if Ref(node['wholeRef']).contains(r):
        break
dimidd commented 4 years ago

Thanks!

I did

r = Ref('Berakhot 2a:6')
berakhot_index = r.index
for node in berakhot_index.alt_structs['Chapters']['nodes']:
    if Ref(node['wholeRef']).contains(r):
        print node['titles'][0]['text'].split()[1]
BoazDavid23 commented 4 years ago

No was referring to this Composed in Talmudic Babylon (c.450 - c.550 CE). Temurah (Substitution) belongs to the fifth order, Nezikin (The Order of Damages) and discusses the laws of what happens if an animal is substituted for an animal dedicated for a sacrifice. It has seven chapters On Monday, 2 December 2019, 05:24:51 GMT-7, Dimid Duchovny notifications@github.com wrote:

Thanks!

I did r = Ref('Berakhot 2a:6') berakhot_index = r.index for node in berakhot_index.alt_structs['Chapters']['nodes']: if Ref(node['wholeRef']).contains(r): print node['titles'][0]['text'].split()[1]

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.