「モジュール:Infobox interval」の版間の差分
Dummy index (トーク | 投稿記録) ページの作成:「local p = {} local he = require("Module:Harmonic entropy") local infobox = require("Module:Infobox") local rat = require("Module:Rational") local utils = require("Module:Utils") local yesno = require("Module:Yesno") -- check whether the input is a non-empty string local function value_provided(s) return type(s) == "string" and #s > 0 end function p.infobox_interval(frame) local debug_mode = yesno(frame.args["debug"]) local page_name = frame:preprocess("{{PAGEN…」 |
編集の要約なし |
||
| (同じ利用者による、間の7版が非表示) | |||
| 91行目: | 91行目: | ||
prime_limit = rat.max_prime(ratio) | prime_limit = rat.max_prime(ratio) | ||
end | end | ||
cats = cats .. "[[Category: | cats = cats .. "[[Category:有理数音程]]" .. "[[Category:" .. prime_limit .. "-limit音程]]" | ||
else | else | ||
cats = cats .. "[[Category: | cats = cats .. "[[Category:無理数音程]]" | ||
end | end | ||
end | end | ||
| 101行目: | 101行目: | ||
if small and rat.is_superparticular(ratio) then | if small and rat.is_superparticular(ratio) then | ||
if rat.is_square_superparticular(ratio) then | if rat.is_square_superparticular(ratio) then | ||
table.insert(special_properties, " | table.insert(special_properties, "{{en仮リンク|平方スーパーパーティキュラー|square superparticular}}") | ||
else | else | ||
table.insert(special_properties, "[[ | table.insert(special_properties, "[[スーパーパーティキュラー]]") | ||
end | end | ||
cats = cats .. "[[Category: | cats = cats .. "[[Category:スーパーパーティキュラー]]" | ||
end | end | ||
if rat.is_reduced(ratio, 2, not small) then | if rat.is_reduced(ratio, 2, not small) then | ||
table.insert(special_properties, "[[ | table.insert(special_properties, "[[オクターブ縮約]]") | ||
end | end | ||
if rat.is_harmonic(ratio) then | if rat.is_harmonic(ratio) then | ||
num, den = rat.as_pair (ratio) | num, den = rat.as_pair (ratio) | ||
table.insert(special_properties, "[[ | table.insert(special_properties, "[[倍音]]") | ||
cats = cats .. "[[Category: | cats = cats .. "[[Category:倍音|" .. string.rep("#", string.len(num)) .. "]]" | ||
if rat.is_prime(ratio) then | if rat.is_prime(ratio) then | ||
table.insert(special_properties, "[[ | table.insert(special_properties, "[[素数倍音]]") | ||
cats = cats .. "[[Category: | cats = cats .. "[[Category:素数倍音|" .. string.rep("#", string.len(num)) .. "]]" | ||
end | end | ||
if rat.is_highly_composite(ratio) then | if rat.is_highly_composite(ratio) then | ||
table.insert(special_properties, "[[ | table.insert(special_properties, "[[高度合成数倍音]]") | ||
cats = cats .. "[[Category: | cats = cats .. "[[Category:倍音|" .. string.rep("#", string.len(num)) .. "]]" | ||
end | end | ||
elseif rat.is_harmonic(ratio, true, not small) then | elseif rat.is_harmonic(ratio, true, not small) then | ||
table.insert(special_properties, "[[Harmonic| | table.insert(special_properties, "[[Harmonic|縮約倍音]]") | ||
cats = cats .. "[[Category: | cats = cats .. "[[Category:オクターブ縮約倍音]]" | ||
elseif rat.is_subharmonic(ratio, true, not small) then | elseif rat.is_subharmonic(ratio, true, not small) then | ||
table.insert(special_properties, "[[Subharmonic| | table.insert(special_properties, "[[Subharmonic|縮約下方倍音]]") | ||
cats = cats .. "[[Category: | cats = cats .. "[[Category:オクターブ縮約下方倍音]]" | ||
end | end | ||
elseif regular then | elseif regular then | ||
if cents >= 0 and cents < 1200 then | if cents >= 0 and cents < 1200 then | ||
table.insert(special_properties, "[[ | table.insert(special_properties, "[[オクターブ縮約]]") | ||
end | end | ||
end | end | ||
| 138行目: | 138行目: | ||
if rational then | if rational then | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
" | "比率", | ||
ratio_string, | ratio_string, | ||
}) | }) | ||
else | else | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
" | "式", | ||
"<math>" .. ratio_string .. "</math>", | "<math>" .. ratio_string .. "</math>", | ||
}) | }) | ||
| 157行目: | 157行目: | ||
else | else | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
" | "素因数分解", | ||
rat.factorisation(ratio), | rat.factorisation(ratio), | ||
}) | }) | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
"[[ | "[[モンゾ]]", | ||
ket, | ket, | ||
}) | }) | ||
| 167行目: | 167行目: | ||
elseif rational then | elseif rational then | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
" | "素因数分解", | ||
rat.factorisation(ratio), | rat.factorisation(ratio), | ||
}) | }) | ||
| 173行目: | 173行目: | ||
-- irrational ket is provided: | -- irrational ket is provided: | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
"[[ | "[[モンゾ]]", | ||
frame:expandTemplate({ | frame:expandTemplate({ | ||
title = "Monzo", | title = "Monzo", | ||
| 182行目: | 182行目: | ||
if regular then | if regular then | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
" | "[[セント]]数", | ||
utils._round(cents, 7) .. "¢", | utils._round(cents, 7) .. "¢", | ||
}) | }) | ||
| 189行目: | 189行目: | ||
local name = frame.args["Name"] | local name = frame.args["Name"] | ||
if value_provided(name) then | if value_provided(name) then | ||
local caption = " | local caption = "名前" | ||
if name:match(",") then | if name:match(",") then | ||
-- removing manual line breaks | -- removing manual line breaks | ||
local matches | local matches | ||
| 210行目: | 209行目: | ||
cats = cats .. "[[Category:Todo:add interval name]]" | cats = cats .. "[[Category:Todo:add interval name]]" | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
" | "名前", | ||
"<abbr title=\"missing value for parameter 'Name'\">''missing''</abbr><sup>[[Template:Infobox Interval| ? ]]</sup>", | "<abbr title=\"missing value for parameter 'Name'\">''missing''</abbr><sup>[[Template:Infobox Interval| ? ]]</sup>", | ||
}) | }) | ||
| 218行目: | 217行目: | ||
if value_provided(colour_name) then | if value_provided(colour_name) then | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
" | "{{en仮リンク|カラーネーム|color name}}", | ||
colour_name, | colour_name, | ||
}) | }) | ||
| 249行目: | 248行目: | ||
if #FJS_name <= 200 then | if #FJS_name <= 200 then | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
"[[Functional Just System| | "[[Functional Just System|FJSネーム]]", | ||
"<math>" .. FJS_name .. "</math>", | "<math>" .. FJS_name .. "</math>", | ||
}) | }) | ||
| 257行目: | 256行目: | ||
if #special_properties > 0 then | if #special_properties > 0 then | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
" | "性質", | ||
table.concat(special_properties, ",<br>"), | table.concat(special_properties, ",<br>"), | ||
}) | }) | ||
| 265行目: | 264行目: | ||
if rational and regular then | if rational and regular then | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
"[[ | "[[テニーノルム]] <br />(log<sub>2</sub> ''nd'')", | ||
utils._round(rat.tenney_height(ratio), 6), | utils._round(rat.tenney_height(ratio), 6), | ||
}) | }) | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
"[[ | "[[ワイルノルム]] <br />(log<sub>2</sub> max(''n'', ''d''))", | ||
utils._round(rat.weil_height(ratio), 6), | utils._round(rat.weil_height(ratio), 6), | ||
}) | }) | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
"[[ | "[[ウィルソンノルム]] <br />(sopfr(''nd''))", | ||
utils._round(rat.wilson_height(ratio), 6), | utils._round(rat.wilson_height(ratio), 6), | ||
}) | }) | ||
| 283行目: | 282行目: | ||
if harmonic_entropy_switch then | if harmonic_entropy_switch then | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
"[[ | "[[ハーモニックエントロピー]]<br>(Shannon, <math>\\sqrt{nd}</math>)", | ||
"~" .. utils._round(he.harmonic_entropy(cents), 6) .. " bits", | "~" .. utils._round(he.harmonic_entropy(cents), 6) .. " bits", | ||
}) | }) | ||
| 318行目: | 317行目: | ||
local S_expressions = rat.find_S_expression(ratio) | local S_expressions = rat.find_S_expression(ratio) | ||
if #S_expressions > 0 then | if #S_expressions > 0 then | ||
local caption = "[[ | local caption = "[[S式]]" | ||
if #S_expressions > 1 then | if #S_expressions > 1 then | ||
caption = caption .. "s" | caption = caption .. "s" | ||
| 370行目: | 369行目: | ||
query = mw.uri.encode(query) | query = mw.uri.encode(query) | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
"<span style=\"font-size: 75%;\">[https://www.yacavone.net/xen-calc/?q=" .. query .. " | "<span style=\"font-size: 75%;\">[https://www.yacavone.net/xen-calc/?q=" .. query .. "''xen-calc''で聴く]</span>", | ||
}) | }) | ||
end | end | ||
local result = infobox.build("<u> | local result = infobox.build("<u>音程情報</u>", infobox_data) | ||
if not debug_mode then | if not debug_mode then | ||