« Module:Multilingual » : différence entre les versions
Contenu supprimé Contenu ajouté
ModuleCentralizer debug datas = mw.clone(datas) |
ModuleCentralizer function modes.levenshtein_similar_tests OK |
||
Ligne 1 :
local
local
-- res = res .. drop_box.new(selector, "modes_recursive_normal_tests_title", modes.recursive_normal_tests, function tab_view.form_one_case) -- only errors
-- res = res .. drop_box.new(selector, "modes_namespaces_page_list_title", tab_view.form_one_case)
-- { "20181014", "20181014", "NOW", "Rical", "S181014uft", "update function tab_view.form_one_case + translate from recursive_normal_test1(...", },
-- See the documentation in: MediaWiki:Scribunto/Central_modules_reference_manual
-- ModuleCentralizer only tests sections titles when renew drop_box.lua From 2018-07-19
p.version = { -- Modules dependencies. Dependencias del módulo. Dépendances du module.
versionName = "Central-s-fr", versionNumber = "1.0.0(
-- UTC version structure : main.fonction.task(yymmddThh:mm)
mainDescription = "Begin to use", functionDescription = "first functional support", taskDescription = "enough advanced to use in CentralSchool OK",
Ligne 940 ⟶ 943 :
-- DUPLICATE NOWNOW, in change. toDoc
{ "---", "---", "---", "---", "---", "DUPLICATE NOW, in change", },
{ "
{ "
{ "
{ "
{ "
{ "
{ "
{ "
{ "
{ "
{ "20181015", "20181016", "NOW", "Rical", "S181015odd", "one_version has a version_default in versions.version_args and a .delete = 'delete' ", },
-- function versioning.antiCrash(options, content_or_func, ...) -- Form the display of a running error. in ModuleCentral 20170902.ModuleCentral 2e no antiCrash ok.lua
{ "20181014", "20181014", "NOW", "Rical", "S181014uft", "update function tab_view.form_one_case + translate from multiple_selection_test1(...", },
{ "20181014", "20181014", "NOW", "Rical", "S181014uft", "update function tab_view.form_one_case + translate from recursive_normal_test1(...", },
{ "20181014", "20181014", "NOW", "Rical", "S181014upt", "update activity.phabricator_tasks_report", },
{ "20181014", "20181014", "NOW", "Rical", "S181014ust", "Module:Centralizer update subtasks list", },
--
-- Automatic shift of below "todo" subtasks.
Ligne 1 013 ⟶ 1 022 :
-- NOWNOW DP, NOW, in change
{ "---", "---", "---", "---", "---", "NOW, in change", },
{ "
{ "
{ "
{ "
{ "
{ "
{ "
{ "
{ "
{ "
{ "20181015", "20181016", "NOW", "Rical", "S181015odd", "one_version has a version_default in versions.version_args and a .delete = 'delete' ", },
-- function versioning.antiCrash(options, content_or_func, ...) -- Form the display of a running error. in ModuleCentral 20170902.ModuleCentral 2e no antiCrash ok.lua
{ "20181014", "20181014", "NOW", "Rical", "S181014uft", "update function tab_view.form_one_case + translate from multiple_selection_test1(...", },
{ "20181014", "20181014", "NOW", "Rical", "S181014uft", "update function tab_view.form_one_case + translate from recursive_normal_test1(...", },
{ "20181014", "20181014", "NOW", "Rical", "S181014upt", "update activity.phabricator_tasks_report", },
{ "20181014", "20181014", "NOW", "Rical", "S181014ust", "Module:Centralizer update subtasks list", },
-- Already done
{ "---", "~sort~", "---", "---", "---", "Already done", },
Ligne 5 892 ⟶ 5 907 :
end -- function modes.levenshtein(word1, word2)
function modes.
local memo = viewers.save_configs("modes.levenshtein_similar_tests") -- Save global configuration before eventual changes.
local t = t or ("\n* " .. viewers.form9user("modes_max_nearest_argument_msg") ) -- "A longer name argument accepts more letter errors."
t = t .. "\n* " .. "Formula to compute the near words limit: Formule de calcul de limite des mots proches : "
local errors, key, argsyn, arglingual, txt = ""
t = t .. "\n* List of diffmaxi / lengths : "
local diffmaxi
for i = 1, 10 do
diffmaxi, tt = modes.similar_args_diffmaxi( string.sub("azertyuiopqsdfghjklm", 1, i), "azertyuiopqsdfghjklm") -- Format a string from the formula
modes.length_from_i[i] = diffmaxi
t = t .. viewers.ta(tostring(i), diffmaxi)
end
local diffmaxi, tt = modes.similar_args_diffmaxi(10, t .. "diffmaxi = ")
local group_test = { -- events.test_group
{ try = "nom", correct = "nom", },
{ try = "top", correct = "pot", },
{ try = "ami", correct = "amis", },
{ try = "nom", correct = "name", },
{ try = "m", correct = "mu", },
{ try = "m", correct = "mur", },
{ try = "mur", correct = "m", },
{ try = "c", correct = "c", },
{ try = "c", correct = "long", },
{ try = "xxx", correct = " ", },
{ try = "", correct = "xyz", },
{ try = "xxx", correct = "xyz", },
{ try = "prénom", correct = "Prenom", },
{ try = "catégorie", correct = "Category", },
{ try = "description", correct = "Description", },
{ try = "anneeDeces", correct = "anneeNaissance", },
{ try = "avant-après", correct = "après-avant", },
}
local tab_view = { -- Group datas and options for a table view with lines and columns.
test_group = group_test,
title_memo = "modes.recursive_normal() Test: Normalize the recursive level and the recursive limit",
headers = "try; try_length; correct; correct_length; error", -- Test Normalize recursiveLevel and recursive_limit
headers_class = "wikitable alternative center sortable",
modes_nearest_argument_err = "Error: Do you need the known argument <b>%1</b> ?",
modes_max_nearest_argument_msg = "A longer name argument accepts more letter errors.",
form_one_case = function(case) -- Convert a case from test_group to rowGroup.
case.try_length = string.len(case.try)
case.correct_length = string.len(case.correct)
case.diffmaxi = modes.similar_args_diffmaxi( string.len(case.try) )
case.diff = modes.similar_args_diffmaxi(case.correct)
if case.diff > case.diffmaxi then case.errors = viewers.usual_color(case.correct, "error") end
return { case.try, case.try_length, case.correct, case.correct_length, case.errors }
end,
rowGroup = {},
-- track_on == "details",
}
t = t .. "<br/>" .. tableview.new(tab_view) -- Form a table view with lines and columns.
t = t .. "\n* <b>levenshtein_test</b> errors = " .. viewers.styles_color_error(errors)
viewers.restore_configs(memo, "modes.levenshtein_similar_tests") -- Restore global configurations after eventual changes.
return t
Ligne 5 986 ⟶ 5 974 :
-- Número máximo de letras diferentes entre 2 nombres de argumento
-- Nombre maximum de lettres différentes entre deux noms d'arguments
modes.length_from_i = {} -- Format a string from the formula
function modes.similar_args_diffmaxi(word, t) -- Format a string from the formula
local coef = modes.constants.near_word_search_diff_coef or 0.30
local constant = modes.constants.near_word_search_diff_const or 0.82
local word = tostring(word)
local length = string.len(word)
local diffmaxi = math.floor( coef * length + constant )
if type(t) == "string" then t = t .. tostring(coef) .. " * length + " .. tostring(constant) else t = "" end
return diffmaxi, t
end -- local diffmaxi, t = function modes.similar_args_diffmaxi(
-- For an unknown argument, seeks the name of the closest among the known arguments translated
Ligne 6 127 ⟶ 6 118 :
local memo = viewers.save_configs("modes.multiple_selection_tests") -- Save global configuration before eventual changes.
local t = (t or "") .. "\n* <b>multiple_selection</b> options: " .. viewers.ta("=", "equal only") .. viewers.ta("t", "not trim before and after") .. viewers.ta("U", "not lowercase and uppercase")
--[[
local function multiple_selection_test1(t, opt, selector, to_select)
local selected_txt, selected_tab, txt = modes.multiple_selection(opt, selector, to_select)
Ligne 6 132 ⟶ 6 124 :
return t, opt, selector, to_select -- , selected_txt, selected_tab
end
--]]
local opt = "; "
t = t .. "\n: selector = <b>nobel,+1,président,3,député,prix</b> signifie : sélectionner le premier, puis 1 de plus parmi les suivants, puis 3 en tout au maximum."
local head = mw.text.split( viewers.form9user("modes_multiple_selection_test_headers") , ';')
t = t .. viewers.table_head() .. viewers.table_col(head[1]) .. viewers.table_col(head[2]) .. viewers.table_col(head[3]) .. viewers.table_col(head[4])
-- recursiveLevel, recursive_limit, recursiveLevel_err == modes.recursive_normal(recursiveLevel, recursive_limit) -- typical use tab_view
local t = t or "\n* modes.recursive_normal_tests: "
local tab_view = { -- Group datas and options for a table view with lines and columns.
test_group = {
{ recursiveLevel_in = nil, recursive_limit_in = nil, },
{ recursiveLevel_in = -12, recursive_limit_in = 5, },
{ recursiveLevel_in = 1, recursive_limit_in = 5, },
{ recursiveLevel_in = 1, recursive_limit_in = 0, },
{ recursiveLevel_in = 2.718, recursive_limit_in = 3.1416, },
{ recursiveLevel_in = 3, recursive_limit_in = nil, },
{ recursiveLevel_in = 5, recursive_limit_in = 5, },
{ recursiveLevel_in = 6, recursive_limit_in = 5, },
{ recursiveLevel_in = 11111, recursive_limit_in = 5, "versions_module_miss_i18n_count_err" },
},
title_memo = "viewers_save_restore_balance_title",
headers = "viewers_save_restore_balance_headers", -- viewers_tableView_default_headers
headers = "select; First alternative; Second alternative; errors",
headers_class = "wikitable alternative center sortable",
form_one_case = function(case) -- Convert a case from test_group to rowGroup.
-- local function recursive_normal_test1(case.recursiveLevel_in, case.recursive_limit_in, case.modes_recursiveLevel_err)
case.recursiveLevel, case.recursive_limit, case.recursiveLevel_err =
modes.recursive_normal( case.recursiveLevel_in or modes.recursive_limit or 1, recursive_limit_in or modes.recursive_limit or 3 )
local t = "\n* " .. viewers.ta("Level_in", case.recursiveLevel_in) .. viewers.ta("Limit_in", recursive_limit_in)
t = t .. viewers.ta("recursiveLevel", recursiveLevel) .. viewers.ta("recursive_limit", recursive_limit) .. viewers.ta("recursiveLevel_err", recursiveLevel_err)
return { case.recursiveLevel_in, case.recursive_limit_in, case.recursiveLevel, case.recursive_limit, case.modes_recursiveLevel_err }
end,
-- headers = "Level_in; Limit_in; recursiveLevel; recursive_limit; recursiveLevel_err", -- viewers_tableView_default_headers
rowGroup = {},
-- track_on == "details",
}
t = t .. "<br/> after convert in form_one_case = function(case)"
t = t .. "<br/>" .. tableview.new(tab_view) -- Form a table view with lines and columns.
viewers.restore_configs(memo, "modes.recursive_normal_tests") -- Restore global configurations after eventual changes.
return t
end -- function modes.multiple_selection_tests(t)
Ligne 6 939 ⟶ 6 952 :
function modes.recursive_normal_tests( t ) -- Test Normalize recursiveLevel and recursive_limit
local memo = viewers.save_configs("modes.recursive_normal_tests") -- Save global configuration before eventual changes.
-- recursiveLevel, recursive_limit, recursiveLevel_err == modes.recursive_normal(recursiveLevel, recursive_limit) -- typical use tab_view
local t = t or "\n* modes.recursive_normal_tests: "
local tab_view = { -- Group datas and options for a table view with lines and columns.
test_group = {
{ recursiveLevel_in = -12, recursive_limit_in = 5, },
{ recursiveLevel_in = 1, recursive_limit_in = 5, },
{ recursiveLevel_in = 1, recursive_limit_in = 0, },
{ recursiveLevel_in = 2.718, recursive_limit_in = 3.1416, },
{ recursiveLevel_in = 3, recursive_limit_in = nil, },
{ recursiveLevel_in = 5, recursive_limit_in = 5, },
{ recursiveLevel_in = 6, recursive_limit_in = 5, },
{ recursiveLevel_in = 11111, recursive_limit_in = 5, "versions_module_miss_i18n_count_err" },
},
title_memo = "modes.recursive_normal() Test: Normalize the recursive level and the recursive limit",
headers = "Level_in; Limit_in; recursiveLevel; recursive_limit; recursiveLevel_err", -- Test Normalize recursiveLevel and recursive_limit
headers_class = "wikitable alternative center sortable",
form_one_case = function(case) -- Convert a case from test_group to rowGroup.
case.recursiveLevel, case.recursive_limit, case.recursiveLevel_err =
modes.recursive_normal( case.recursiveLevel_in or modes.recursive_limit or 1, case.recursive_limit_in or modes.recursive_limit or 3 )
return { case.recursiveLevel_in, case.recursive_limit_in, case.recursiveLevel, case.recursive_limit, case.modes_recursiveLevel_err }
-- headers = "Level_in; Limit_in; recursiveLevel; recursive_limit; recursiveLevel_err", -- viewers_tableView_default_headers
end,
rowGroup = {},
-- track_on == "details",
}
t = t .. "<br/> after convert in form_one_case = function(case)"
t = t .. "<br/>" .. tableview.new(tab_view) -- Form a table view with lines and columns.
viewers.restore_configs(memo, "modes.recursive_normal_tests") -- Restore global configurations after eventual changes.
return t
Ligne 9 537 ⟶ 9 558 :
t = t .. "\n* Test <b>viewers.simple_list(list, sep1, sep2, sep3)</b>: "
t = t .. '\n* Remove repeats in a string list with separators. Can also sort.'
local function
local output = tostring( viewers.simple_list(input, sep1, sep2, sep3, sep4) )
t = t .. viewers.table_row() .. viewers.table_dat(viewers.value(input)) .. viewers.table_dat(viewers.value(sep1)) .. viewers.table_dat(viewers.value(sep2))
Ligne 9 544 ⟶ 9 565 :
end
t = t .. viewers.table_head() .. viewers.table_col("input") .. viewers.table_col("sep1") .. viewers.table_col("sep2") .. viewers.table_col("sep3") .. viewers.table_col("sep4") .. viewers.table_col("output")
t =
t =
t =
t =
t =
t =
t =
t =
t =
t = t .. viewers.table_end()
viewers.restore_configs(memo, "viewers.simple_list_test") -- Restore global configurations after eventual changes.
return t
end -- viewers.simple_list_test(t)
-- for _test1 search also _test1 simpleList_test1 date_to_part_test1
function viewers.form_one_case(case) -- Convert a case from test_group to rowGroup.
case = tests_groups.run_one_case(case) -- Run one case for users and MediaWiki tests cases.getTestProvider_tests
case.res1 = case.result[1] or "res1" -- DEBUG : mathroman.int2roman() can fail without blocking page.
case.err2 = case.result[case.errorsKey] or "err2" -- DEBUG : mathroman.int2roman() can fail without blocking page.
case.errors = case.errors or status.OK
case.errors = viewers.ta("case.res1", case.res1) .. viewers.ta("case.err2", case.err2) .. viewers.ta("case.errors", case.errors)
-- headers = "case.name; args{}; expect{}; result{}; errors in result{} from expect{}", -- OK or error/s
return { case.name, lua_table.rough_view(case.args), lua_table.rough_view(case.expect), lua_table.rough_view(case.result), case.errors }
end -- errors in result
function viewers.day_to_stamp(jj, mm, aaaa)
Ligne 9 575 ⟶ 9 607 :
function viewers.parts_of_date_tests(t)
local memo = viewers.save_configs("viewers.parts_of_date_tests") -- Save global configuration before eventual changes.
local function
local t = t .. viewers.table_row() .. viewers.table_dat(nom) .. viewers.table_dat(date) .. viewers.table_dat(part) .. viewers.table_dat(tostring(viewers.date_to_part(date, part)))
return t
Ligne 9 582 ⟶ 9 614 :
t = t .. "\n* Verify each value of part of date:"
t = t .. viewers.table_head() .. viewers.table_col("Example") .. viewers.table_col("date") .. viewers.table_col("part") .. viewers.table_col("value")
t =
t =
t =
t =
t =
t =
t =
t =
t =
t =
t = t .. viewers.table_end()
-- see https://fr.wikipedia.org/wiki/Discussion:ISO_8601#Av._J.C._:_contradiction_avec_l.27article_anglais
Ligne 10 302 ⟶ 10 334 :
res = res .. drop_box.new(selector, "modes_levenshtein_similar_tests_title", modes.levenshtein_similar_tests)
res = res .. drop_box.new(selector, "modes_namespaces_page_list_title", modes.namespaces_page_list)
res = res .. drop_box.new(selector, "modes_recursive_normal_tests_title", modes.recursive_normal_tests) -- only errors
res = res .. drop_box.new(selector, "modes_namespaces_page_list_title", modes.recursive_normal_tests) -- only errors
-- function tab_view.form_one_case)
-- "enforcerun"
-- res = res .. viewers.doc_section(selector, "Library:tests_groups", "h3") -- S170801rtc todo
|