local export = {}
local chart = {
='a^', ='a_',
='a', ='a/', ='a\\', ='a=', ='a)', ='a(',
='a)\\', ='a(\\', ='a)/', ='a(/', ='a)=', ='a(=',
='a|', ='a/|', ='a\\|', ='a=|', ='a)|', ='a(|',
='a)\\|', ='a(\\|', ='a)/|', ='a(/|', ='a)=|', ='a(=|',
='*a^', ='*a_',
='*a', ='*/a', ='*a\\', ='*a=', ='*)a', ='*(a',
='*)a\\', ='*(a\\', ='*)/a', ='*(/a', ='*)a=', ='*(a=',
='*a|', ='*)a|', ='*(a|',
='*)a\\|', ='*(a\\|', ='*)/a|', ='*(/a|', ='*)a=|', ='*(a=|',
='b', ='*b', ='g', ='*g', ='d', ='*d',
='e', ='e/', ='e\\', ='e)', ='e(',
='e)\\', ='e(\\', ='e)/', ='e(/',
='*e', ='*/e', ='*\\e', ='*)e', ='*(e',
='*)\\e', ='*(\\e', ='*)/e', ='*(/e',
='z', ='*z',
='h', ='h/', ='h\\', ='h=', ='h)', ='h(',
='h)\\', ='h(\\', ='h)/', ='h(/', ='h)=', ='h(=',
='h|', ='h/|', ='h\\|', ='h=|', ='h)|', ='h(|',
='h)\\|', ='h(\\|', ='h)/|', ='h(/|', ='h)=|', ='h(=|',
='*h', ='*h/', ='*h\\', ='*)h', ='*(h',
='*)h\\', ='*(h\\', ='*)/h', ='*(/h', ='*)h=', ='*(h=',
='*h|', ='*)h|', ='*(h|',
='*)h\\|', ='*(h\\|', ='*)/h|', ='*(/h|', ='*)h=|', ='*(h=|',
='q', ='*q',
='i^', ='i_', ='i%252B', ='i\\%252B', ='i/%252B', ='i=', ='i=%252B',
='i', ='i/', ='i\\', ='i)', ='i(',
='i)\\', ='i(\\', ='i)/', ='i(/', ='i)=', ='i(=',
='*i^', ='*i_', ='*i%252B',
='*i', ='*i/', ='*i\\', ='*)i', ='*(i',
='*)i\\', ='*(i\\', ='*)/i', ='*(/i', ='*)i=', ='*(i=',
='k', ='*k', ='l', ='*l',
='m', ='*m', ='n', ='*n', ='c', ='*c',
='o', ='o/', ='o\\', ='o)', ='o(',
='o)\\', ='o(\\', ='o)/', ='o(/',
='*o', ='*/o', ='*o\\', ='*)o', ='*(o',
='*)o\\', ='*(o\\', ='*)/o', ='*(/o',
='p', ='*p', ='r', ='r)',
='r(', ='*r', ='*(r', ='s', ='*s', ='s',
='t', ='*t',
='u^', ='u_', ='u%252B', ='u/%252B', ='u\\%252B', ='u=%252B',
='u', ='u/', ='u\\', ='u=', ='u)', ='u(',
='u)\\', ='u(\\', ='u)/', ='u(/', ='u)=', ='u(=',
='*u^', ='*u_', ='*u%252B',
='*u', ='*/u', ='*u\\', ='*(u',
='*(u\\', ='*(u/', ='*(u=',
='f', ='y', ='*y', ='*f', ='x', ='*x',
='w', ='w/', ='w\\', ='w=', ='w)', ='w(',
='w)\\', ='w(\\', ='w)/', ='w(/', ='w)=', ='w(=',
='w|', ='w/|', ='w\\|', ='w=|', ='w)|', ='w(|',
='w)\\|', ='w(\\|', ='w)/|', ='w(/|', ='w)=|', ='w(=|',
='*w', ='*/w', ='*w\\', ='*)w', ='*(w',
='*)w\\', ='*(w\\', ='*)w/', ='*(/w', ='*)w=', ='*(w=',
='*w|', ='*)w|', ='*(w|',
='*)w\\|', ='*(w\\|', ='*)/w|', ='*(/w|', ='*)w=|', ='*(w=|',
='v', ='*v'}
local collisions_lsj = require("Module:R:LSJ/collision-data")
function is_collision(x)
if collisions_lsj == Nil then return false else return true end
end
function polytonic_to_perseus_beta(polytonic)
local length = mw.ustring.len(polytonic)
local x = 1
local letter = ''
local betaTable = {}
while x <= length do
letter = mw.ustring.sub(polytonic, x, x)
if chart then
table.insert(betaTable, chart)
end
x = x + 1
end
return table.concat(betaTable, '')
end
function format_perseus_url(title, beta, redirect)
local url_redirect_lhs = 'http://www.perseus.tufts.edu/hopper/resolveform?type=exact&lookup='
local url_entry_lhs = 'http://www.perseus.tufts.edu/hopper/text?doc=Perseus:text:1999.04.0057:entry='
local url_rhs = redirect and '&lang=greek' or ''
return (redirect and url_redirect_lhs or url_entry_lhs)..beta..url_rhs
end
function format_perseus_wikilink(title, beta, redirect)
local lsj_biblio = "'']'' by Liddell & Scott, Clarendon Press, Oxford, 1940"
local url = format_perseus_url(title, beta, redirect)
local w_link = ' in '
return (beta == '' and '' or w_link)..lsj_biblio
end
function export.create(frame)
local args = frame:getParent().args
local title = args or mw.title.getCurrentTitle().text
local beta = args or polytonic_to_perseus_beta(title)
local redirect = args or (is_collision(title) and not args and not args)
return format_perseus_wikilink(title, beta, redirect)
end
return export