请输入您要查询的百科知识:

 

词条 Module:NVR/data extraction tool
释义

p = {}

--[[-------------------------< N A M E _ C A S E >--------------------------------------------------------------

Make mixed case names from uppercase names: HARRY L GLUCKSMAN to Harry L Glucksman

]]

local function name_case (name)

local s = mw.text.trim (name or ); -- no leading or trailing white space

local words = mw.text.split (s, ' '); -- split the name at the spaces it there are any

for i, s in ipairs (words) do -- for each 'word' of the name

s = string.lower (s) -- make it lowercase

words[i] = mw.getContentLanguage():ucfirst(s); -- then uppercase the the first character

end

s = table.concat (words, ' '); -- put the name back together

words = mw.text.split (s, '\\); -- now handle apostrophes if any (O'Brien, etc)

for i, s in ipairs (words) do

words[i] = mw.getContentLanguage():ucfirst(s);

end

return table.concat (words, '\\\\\\); -- put the name back together and done

end

----------------------------< N V R _ E X T R A C T >----------------------------------------------------------

function p.nvr_extract (frame)

local page = mw.title.getCurrentTitle(); -- get a page object for this page

local content = page:getContent(); -- get unparsed content

local out_table = {}; -- output goes here

local group; -- identify this collection of hull numbers

-- search for nvr links and associated hull numbers

for id, ltr, num, name in mw.ustring.gmatch (content, 'SHIPSDETAIL_([^%.]+)%.HTML\\">([%a%- %(%)]+)%s+(%d+).-_NameLink_%d\\">([^<]+)') do

table.insert (out_table, "[\\'" .. ltr .. "-" .. num .."\\'] = {\\'" .. id .. "\\', \\'" .. name_case (name) .. "\\'}"); -- make table entries in wp hull number format

group = ltr:gsub ('T%-(.+)', '%1'); -- because ltr is local to the for loop; also strip off the 'T-' prefix

end

-- make pretty output

return "

	[\\'" .. group .. "\\'] = <br />		{<br />		" .. table.concat (out_table, ',<br />		') .. "<br />		},<br />
";

end

return p;

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/29 11:28:52