Jump to content

Module:Sandbox/Gnosygnu

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 68.192.174.14 (talk) at 05:14, 27 December 2015 (more cyrillic case comparison check). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
--This Module is for Lua experimentation. No other pages refer to it.

local p = {}

function p.gsub_string(frame)
    local arg_1 = frame.args[1]
    local arg_2 = frame.args[2]
    local arg_3 = frame.args[3]
    local rv = ""
    rv = mw.ustring.gsub(arg_1, arg_2, arg_3)
    return rv
end

function p.wikibase_novalue(frame)
  local item = mw.wikibase.getEntityObject();
  local prop = item.claims[frame.args[2]];
  local rv = '';
  for _, statement in pairs( prop ) do
    local dv = statement.mainsnak.datavalue;
    if (dv == nil) then
      rv = rv .. ';nil';
    else
      rv = rv .. ';val';
    end
  end
  return rv
end

function p.wikibase_resolvePropertyId(frame)
  return mw.wikibase.resolvePropertyId(frame.args[1])
end

function p.scrib_lang_ru_s(frame)
  local title = 'Ибн-Яиш, Барух бен-Исаак';
  local list = [[A:01 Alt:02 Ar:03 Be:04 Bu:05 C:09 D:07 E:16 F:15 G:06 I:08 Jude:09
    L:10 Mi:11 O:12 Pro:13 Sc:14 Ste:16 Sti:14 Tr:15 Ty:14 V:15 Veri:05 Z:15
    А:01 Алгар:02 Алгу:01 Алмо:02 Ар:02:03 Арабско:03 Бе:04 Бед:04:05 Бее:04 Беж:04:05 Без:04
    Бел:04:05 Бем:04 Берж:04:05 Берз:04 Беч:04:05 Би:04 Бресс:04:05 Брет:05
    Гад:05:06 Гае:06 Дан:06:07 Дани:06 Данф:07 Иа:08 Иб:07 Ибнэ:07:08 Иссо:16
    Ист:08 Иудан:09 Иудап:08 Иудг:09 Иф:08 К:09 Ладен:09:10 Лади:10 Медн:11 Меж:10
    Мелец:11 Мели:10 Мен:11 Менан:10 Меры:11 Мес:10 Мест:10:11 Мет:10 Мехо:11
    Мехол:10 Мещ:10:11 Миб:10 Миддот:10:11 Миди:11 Обет:12 Обеч:11 Обы:12 Пени:13 Пенин:12
    Песн:13 Песс:12 Преш:13 Прж:12 Прокл:13 Сарае:14 Телес:15 Телех:14 Трани:14:15 Транс:15
    Федо:16 Фей:15 Феод:16 Фер:15 Фесс:16 Фест:15 Фив:16 Фиг:15 Фим:16 Фин:15
    Шем:15:16 Шемо:16 Яя:00]]
  ;
  local m = mw.text.split (list, '%s+')
  for i, v in ipairs (m) do
    v = mw.text.split (v, ':')
    if not v[2] then v[2] = string.format ("%02d", i) end
    m[i] = v
  end
  local rv = 'result:';
  for i = 1, #m do
    if title >= m[i][1] and title < m[i+1][1] then 
      rv = rv .. m[i][1] .. ' ' .. m[i+ 1][1] .. ' ';
      if m[i][3] then
        rv = rv .. '0 ';
        if t then 
          for j, v in ipairs (t) do
            rv = rv .. '1 ';
          end
        end
        rv = rv .. '2 ';
      else
        rv = rv .. '3 ';
      end
    end
  end
  return rv
end

return p