יחידה:כותרת: הבדלים בין גרסאות בדף
[גרסה לא בדוקה] | [גרסה לא בדוקה] |
תוכן שנמחק תוכן שנוסף
Erel Segal (שיחה | תרומות) אין תקציר עריכה |
Erel Segal (שיחה | תרומות) אין תקציר עריכה |
||
שורה 29: | שורה 29: | ||
-- חלוקה לשלושה חלקים: ספר (עם או בלי רווחים), פרק, וסעיף. |
-- חלוקה לשלושה חלקים: ספר (עם או בלי רווחים), פרק, וסעיף. |
||
local PATTERN_SEIF_BSEFER = '^([ א-ת]+)%s+([א-ת]+)%s+([א-ת]+)$'; |
local PATTERN_SEIF_BSEFER = '^([ א-ת]+)%s+([א-ת]+)%s+([א-ת]+)$'; |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
-- הפוקנציה מקבלת שם של דף, מפרקת אותו לשלושה חלקים (ספר, מסכת ופרק), ומכניסה את החלקים האלה לתבנית הנתונה. |
-- הפוקנציה מקבלת שם של דף, מפרקת אותו לשלושה חלקים (ספר, מסכת ופרק), ומכניסה את החלקים האלה לתבנית הנתונה. |
||
שורה 60: | שורה 42: | ||
p.koteret_lpereq_bsefer = function (title, template) |
p.koteret_lpereq_bsefer = function (title, template) |
||
title = title:gsub(PATTERN_PARENTHESES,'') |
-- title = title:gsub(PATTERN_PARENTHESES,'') |
||
local sefer, mafrid, maseket, mafrid1, pereq = string.match(title, PATTERN_PEREQ) |
local sefer, mafrid, maseket, mafrid1, pereq = string.match(title, PATTERN_PEREQ) |
||
if (sefer==nil) then |
if (sefer==nil) then |
||
שורה 292: | שורה 274: | ||
return p.seif_maqbil(frame.args[1], frame.args[2], frame.args[3]) |
return p.seif_maqbil(frame.args[1], frame.args[2], frame.args[3]) |
||
end |
end |
||
-- Old, unneeded functions: |
|||
-- |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
גרסה מ־21:46, 16 באפריל 2015
היחידה מאפשרת לשלוף את שם הספר, המסכת והפרק.
שם הספר מוגדר כמילה אחת בלי רווחים, וכך גם שם הפרק.
לעומת זאת, בשם המסכת יכולים להיות רווחים.
שימוש ביחידה זו - בתבנית:ניווט משנה, וגם בתבנית:כותרת לפרק במסכת ובתבנית:כותרת לסעיף בפרק.
להדגמה, ראו ירושלמי פסחים א, ירושלמי בבא קמא א, ירושלמי פאה ו ג.
היחידה משתמשת בפונקציות מתוך יחידה:גימטריה.
local gimatria = require('יחידה:גימטריה');
local haqodem = gimatria.haqodem;
local haba = gimatria.haba;
local otiot2mispar = gimatria.gimatria;
local mispar2otiot = gimatria.mispar_lotiot;
local p = {}
local letter = "[א-ת]"
local letterspace = "[א-ת ]"
local letterspaceparen = "[א-ת ()]"
local letters = letter .. '+'
local letterspaces = letterspace .. '+'
local letterspaceparens = letterspaceparen .. '+'
local PATTERN_PARENTHESES = '%('..letterspaces..'%)'
-- חלוקה לשלושה חלקים: ספר (מילה אחת בלי רווחים), מסכת (עם או בלי רווחים), ופרק.
local PATTERN_PEREQ = '^('..letters..')([/ ])('..letterspaces..')([/ ])('..letters..')$';
-- חלוקה לשלושה חלקים: ספר (ומילה אחת בלי רווחים ועוד גירסה בסוגריים), מסכת (עם או בלי רווחים), ופרק.
local PATTERN_PEREQ_GIRSA = '^('..letters..' %('..letterspaces..'%))([/ ])('..letterspaces..')([/ ])('..letters..')$';
-- חלוקה לארבעה חלקים: ספר (מילה אחת בלי רווחים), מסכת (עם או בלי רווחים), פרק, וסעיף.
local PATTERN_SEIF = '^('..letters..')%s+('..letterspaces..')%s+('..letters..')%s+('..letters..')$';
-- חלוקה לשלושה חלקים: ספר (עם או בלי רווחים), פרק, וסעיף.
local PATTERN_SEIF_BSEFER = '^([ א-ת]+)%s+([א-ת]+)%s+([א-ת]+)$';
-- הפוקנציה מקבלת שם של דף, מפרקת אותו לשלושה חלקים (ספר, מסכת ופרק), ומכניסה את החלקים האלה לתבנית הנתונה.
-- למשל: אם שם הדף הוא "ירושלמי בבא קמא א",
-- והתבנית היא: "אאא <ספר> בבב <מסכת> גגג <פרק<"
-- אז הפונקציה תחזיר: "אאא ירושלמי בבב בבא קמא גגג א"
p["כותרת לפרק"] = function (frame)
local title = frame.args[1]
local template = frame.args[2]
return p.koteret_lpereq_bsefer(title, template)
end
p.koteret_lpereq_bsefer = function (title, template)
-- title = title:gsub(PATTERN_PARENTHESES,'')
local sefer, mafrid, maseket, mafrid1, pereq = string.match(title, PATTERN_PEREQ)
if (sefer==nil) then
sefer, mafrid, maseket, mafrid1, pereq = string.match(title, PATTERN_PEREQ_GIRSA)
end
local pereq_qodem = haqodem(pereq);
local pereq_haba = haba(pereq);
template = template:gsub('<ספר>', sefer);
template = template:gsub("<מסכת>", maseket);
template = template:gsub("<פרק>", pereq);
template = template:gsub("<פרק קודם>", pereq_qodem);
template = template:gsub("<פרק הבא>", pereq_haba);
template = template:gsub("<מפריד>", mafrid);
return template
end
-- בטבלה זו, בכל כניסה בטבלה, צריכה להיות רשימה של מספרי המשניות בכל פרק במסכת.
-- למשל, במסכת פאה, בפרק א, יש 5 משניות, וכן הלאה.
local mispar_mishnayot_bepereq = {
['משנה'] = {
['פאה'] =
{5, 5, 7, 7, 7, 8, 7, 8},
['ברכות'] =
{6, 9, 6, 6, 5, 8, 5, 8,5},
['שקלים'] =
{7, 5, 3, 5, 4, 4, 3, 4},
},
['ירושלמי'] = {
['ברכות'] =
{6, 9, 6, 6, 5, 8, 5, 8,5},
['פאה'] =
{5, 5, 7, 7, 7, 8, 7, 8},
['דמאי'] =
{4, 5, 6, 5, 8, 8, 8},
['כלאים'] =
{9, 8, 6, 6, 7, 4, 6, 4, 6},
['שביעית'] =
{6, 7, 7, 8, 4, 4, 2, 8, 6, 4},
['תרומות'] =
{5, 3, 5, 8, 3, 3, 3, 4, 3, 6, 5},
['מעשרות'] =
{5, 4, 4, 4, 3},
['מעשר שני'] =
{3, 4, 6, 6, 5},
['חלה'] =
{6, 3, 5, 5},
['ערלה'] =
{5, 9, 7},
['בכורים'] =
{9, 6, 6},
['שבת'] =
{11, 7, 8, 3, 4, 9, 4, 7, 7, 6, 6, 6, 7, 4, 3, 9, 7, 3, 6, 5},
['ערובין'] =
{10,8,10,10,8,10,10,9,5,14},
['פסחים'] =
{8,7,8,9,10,6,13,8,10,7},
['שקלים'] =
{7, 5, 3, 5, 4, 4, 3, 4},
['יומא'] =
{8,4,9,6,7,7,3,7},
['סוכה']=
{12,10,12,7,8},
['ביצה']=
{12,10,9,7,8},
['ראש השנה']=
{8,8,10,10},
['תענית']=
{8,14,11,7},
['מגילה']=
{12,7,7,12},
['מועד קטן']=
{10,5,9},
['חגיגה']=
{8,7,8},
--נשים
['יבמות'] =
{6,12,12,16,8,6,8,6,8,8,7,6,14,7,10,9},
['כתובות'] =
{10,10,10,14,11,7,9,11,10,6,7,5,11},
['נדרים'] =
{4,5,9,10,6,11,11,9,9,8,12},
['נזיר'] =
{5,10,7,6,4,11,4,2,6},
['סוטה'] =
{10,6,8,5,6,4,8,10,16},
['גיטין'] =
{5,7,8,9,10,7,8,10,11},
['קידושין'] =
{9,9,13,12},
--נזיקין
['בבא קמא'] =
{5,8,11,9,8,8,7,8,10,11},
['בבא מציעא'] =
{8,11,9,7,8,6,7,9,13,6},
['בבא בתרא'] =
{5,11,11,8,5,4,4,9,9,10},
['סנהדרין'] =
{4,6,12,9,5,10,13,9,7,8,6},
['מכות'] =
{8,7},
['שבועות'] =
{7,5,10,10,6,8,8,4},
},
['בבלי'] = {
['פאה'] =
{0, 0, 0, 0, 0, 0, 0, 0},
['דמאי'] =
{0,0,0,0,0,0,0},
['ברכות'] =
{6, 9, 6, 6, 5, 8, 5, 8,5},
['שקלים'] =
{7, 5, 3, 5, 4, 4, 3, 4},
},
}
p.koteret_lseif = function (title, template)
local sefer, maseket, pereq, seif = string.match(title, PATTERN_SEIF)
local pereq_mispar = otiot2mispar(pereq)
local seif_mispar = otiot2mispar(seif)
local pereq_qodem = mispar2otiot(pereq_mispar-1)
local pereq_haba = mispar2otiot(pereq_mispar+1)
local seif_qodem = mispar2otiot(seif_mispar-1)
local seif_haba = mispar2otiot(seif_mispar+1)
local mispar_mishanyot = mispar_mishnayot_bepereq[sefer]
if (mispar_mishanyot~=nil) then
mispar_mishanyot = mispar_mishanyot[maseket]
end
-- חישוב פרק וסעיף קודם
local pereq_wseif_qodem = pereq.." "..seif_qodem
if seif_mispar==1 then
if pereq_mispar==1 then -- תחילת מסכת
pereq_wseif_qodem = ""
elseif mispar_mishanyot~=nil and mispar_mishanyot[pereq_mispar-1]~=nil then
pereq_wseif_qodem = pereq_qodem.." "..mispar2otiot(mispar_mishanyot[pereq_mispar-1])
end
end
-- חישוב פרק וסעיף הבא
local pereq_wseif_haba = pereq.." "..seif_haba
if mispar_mishanyot~=nil and seif_mispar==mispar_mishanyot[pereq_mispar] and mispar_mishanyot[pereq_mispar]~=nil then
if mispar_mishanyot[pereq_mispar+1]==nil then -- סוף מסכת
pereq_wseif_haba = ""
else
pereq_wseif_haba = pereq_haba.." ".."א"
end
end
template = template:gsub('<ספר>', sefer);
template = template:gsub("<מסכת>", maseket);
template = template:gsub("<פרק>", pereq);
template = template:gsub("<פרק קודם>", pereq_qodem);
template = template:gsub("<פרק הבא>", pereq_haba);
template = template:gsub("<סעיף>", seif);
template = template:gsub("<סעיף קודם>", seif_qodem);
template = template:gsub("<סעיף הבא>", seif_haba);
template = template:gsub("<פרק וסעיף קודם>", pereq_wseif_qodem);
template = template:gsub("<פרק וסעיף הבא>", pereq_wseif_haba);
return template
end
-- הפוקנציה מקבלת שם של דף, מפרקת אותו לארבעה חלקים (ספר, מסכת, פרק, וסעיף/הלכה/משנה), ומכניסה את החלקים האלה לתבנית הנתונה.
-- למשל: אם שם הדף הוא "ירושלמי בבא קמא א ב",
-- והתבנית היא: "אאא <ספר> בבב <מסכת> גגג <פרק<"
-- אז הפונקציה תחזיר: "אאא ירושלמי בבב בבא קמא גגג א"
p["כותרת לסעיף"] = function (frame)
local title = frame.args[1]
local template = frame.args[2]
return p.koteret_lseif(title, template)
end
p.koteret_lseif_bsefer = function (title, template)
local sefer, pereq, seif = string.match(title, PATTERN_SEIF_BSEFER)
local seif_qodem = haqodem(seif);
local seif_haba = haba(seif);
template = template:gsub('<ספר>', sefer);
template = template:gsub("<פרק>", pereq);
template = template:gsub("<סעיף>", seif);
template = template:gsub("<סעיף קודם>", seif_qodem);
template = template:gsub("<סעיף הבא>", seif_haba);
return template
end
-- הפוקנציה מקבלת שם של דף, מפרקת אותו לשלושה
-- חלקים (ספר, פרק וסעיף), ומכניסה
-- את החלקים האלה לתבנית הנתונה.
p["כותרת לסעיף בספר"] = function (frame)
local title = frame.args[1]
local template = frame.args[2]
return p.koteret_lseif_bsefer(title, template)
end
-- קלט: כותרת של דף של סעיף, למשל "ירושלמי בבא קמא א ב". וכן ספר אחר, לדוגמה "בבלי".
-- פלט: התבנית הנתונה בקלט, עם הנתונים של סעיף זה בספר המקביל, לדוגמה: "בבלי בבא קמא א ב".
-- אבל רק אם הסעיף המקביל אכן נמצא בספר השני. אם הסעיף לא נמצא - תוחזר מחרוזת ריקה.
p.seif_maqbil = function(title, template, sefer)
local _, maseket, pereq, seif = string.match(title, PATTERN_SEIF)
local pereq_mispar = otiot2mispar(pereq)
local seif_mispar = otiot2mispar(seif)
local mispar_mishanyot = mispar_mishnayot_bepereq[sefer]
if (mispar_mishanyot~=nil) then
mispar_mishanyot = mispar_mishanyot[maseket]
end
if (mispar_mishanyot~=nil) then
mispar_mishnayot = mispar_mishanyot[pereq_mispar]
end
if (mispar_mishnayot~=nil and seif_mispar > mispar_mishnayot) then
return "" -- הסעיף לא קיים בספר השני
else
template = template:gsub('<ספר>', sefer)
template = template:gsub("<מסכת>", maseket)
template = template:gsub("<פרק>", pereq)
template = template:gsub("<סעיף>", seif)
return template
end
end
p["סעיף מקביל"] = function (frame)
return p.seif_maqbil(frame.args[1], frame.args[2], frame.args[3])
end
-- Old, unneeded functions:
--
-- p["ספר"] = function (frame)
-- local title = frame.args[1]
-- local result, _, _, _, _ = string.match(title, PATTERN_PEREQ);
-- return result
-- end
-- p["מסכת"] = function (frame)
-- local title = frame.args[1]
-- local _, _, result, _, _ = string.match(title, PATTERN_PEREQ);
-- return result
-- end
-- p["פרק"] = function (frame)
-- local title = frame.args[1]
-- local _, _, _, _, result = string.match(title, PATTERN_PEREQ);
-- return result
-- end
return p