« Module:Multilingual » : différence entre les versions

Contenu supprimé Contenu ajouté
ModuleCentralizer function modes.levenshtein_similar_tests OK
ModuleCentralizer function modes.words_to_diffmaxi_limit OK
Ligne 1 :
local p = {} -- The main central module install central libraries and bind the main and its sub-modules
local Central = p -- Save as ModuleCentralizer.lua ModuleCentralizer function modes.levenshtein_similar_tests okOK.lua
-- 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)
Ligne 7 :
-- 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(181014T22181015T12:1844)", versionDate = "2018-10-14T2215T12:1844:00", --MWMW NOWNOW
-- 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 5 907 :
end -- function modes.levenshtein(word1, word2)
 
function modes.levenshtein_similar_tests(t) -- Tests of modes.words_to_diffmaxi_limit(10, t .. "diffmaxi = ")
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* " .. "FormulaA toformula computecomputes the near words limit: Formule de calcul de limite des mots proches : "
local errors, key, argsyn, arglingual, txt = ""
t = t .. "\n* List of diffmaxi = formula( <b>length</b> lengths) : "
end -- local diffmaxi, tlimit = function modes.similar_args_diffmaxiwords_to_diffmaxi_limit(wordword1, tword2) -- FormatReports athe stringdiffmaxi fromand the formulalimit
local diffmaxi, limit
for i = 1, 10 do
for i = 1, 10 do -- function modes.words_to_diffmaxi_limit(
diffmaxi, ttlimit = modes.similar_args_diffmaxiwords_to_diffmaxi_limit( string.sub("azertyuiopqsdfghjklm", 1, i), "azertyuiopqsdfghjklma") -- Format a string from the formula
modes.length_from_i[i] = diffmaxi
t = t .. viewers.ta(tostring(i), diffmaxi)
end
t = t .. "\n* An error appears when the word exceeds the limit of close words: "
-- local diffmaxi, tt = modes.similar_args_diffmaxiwords_to_diffmaxi_limit(10, t .. "diffmaxi = ")
local group_test = { -- events.test_group
{ try = "nom", correct = "nom", },
Ligne 5 943 ⟶ 5 945 :
test_group = group_test,
title_memo = "modes.recursive_normal() Test: Normalize the recursive level and the recursive limit",
headers = "try; try_lengthcorrect; correctdiffmaxi; correct_lengthlimit; 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> ?",
Ligne 5 950 ⟶ 5 952 :
case.try_length = string.len(case.try)
case.correct_length = string.len(case.correct)
case.diffmaxi, case.limit = modes.similar_args_diffmaxiwords_to_diffmaxi_limit( string.len(case.try), case.correct) -- Format a string from the formula
-- case.diffmaxi = modes.levenshtein(word1, word2) -- Compute the Levenshtein distance between 2 ASCII words.
case.diff = modes.similar_args_diffmaxi(case.correct)
-- if case.diff >= casemodes.diffmaxi then words_to_diffmaxi_limit(case.errorstry, = viewers.usual_color(case.correct, "error") end
return {if case.try,diffmaxi > case.try_length,limit then case.correct,error = viewers.usual_color(case.correct_lengthtry, case.errors"error") }end
return { case.try, case.correct, case.diffmaxi, case.limit, case.error }
end,
rowGroup = {},
Ligne 5 975 ⟶ 5 978 :
-- 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_diffmaxilevenshtein(wordword1, tword2) -- FormatCompute athe stringLevenshtein fromdistance thebetween formula2 ASCII words.
function modes.words_to_diffmaxi_limit(word1, word2) -- Reports the diffmaxi and the limit
local word1 = tostring(word1)
local word2 = tostring(word2)
local diffmaxi = modes.levenshtein(word1, word2) -- Compute the Levenshtein distance between 2 ASCII words.
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 wordlength = tostringstring.len(wordword1)
local lengthlimit = stringmath.lenfloor(word coef * length + constant )
if type(tword1) == "string" then tword1 = tword1 .. tostring(coef) .. " * length + " .. tostring(constant) else tword1 = "" end
local diffmaxi = math.floor( coef * length + constant )
return diffmaxi, tlimit
if type(t) == "string" then t = t .. tostring(coef) .. " * length + " .. tostring(constant) else t = "" end
end -- local diffmaxi, limit = function modes.words_to_diffmaxi_limit(word1, word2) -- Reports the diffmaxi and the limit
return diffmaxi, t
end -- local diffmaxi, t = function modes.similar_args_diffmaxi(word, t) -- Format a string from the formula
 
-- For an unknown argument, seeks the name of the closest among the known arguments translated
Ligne 6 480 ⟶ 6 486 :
local min1, min2, min3 = 99, 99, 99
if (type(search) ~= "string") then search = "" end
local diffmaxi = modes.similar_args_diffmaxiwords_to_diffmaxi_limit( string.len(search) )
local t = ", " .. tostring(diffmaxi) .. " / " .. tostring(length) .. " "
for key, arglingual in pairs(list) do
Ligne 6 677 ⟶ 6 683 :
-- "Error: parameter <b>%1</b> is unknown in this template. Check the name or flag this gap.",
-- Look for a known and similar name argument
local diffmaxi = modes.similar_args_diffmaxiwords_to_diffmaxi_limit( string.len(arglingual) )
local trouve1, min1, trouve2, min2 = modes.similar_args_search(arglingual, args_list)
if min1 and (min1 <= diffmaxi) then
Ligne 10 323 ⟶ 10 329 :
-- res = res .. drop_box.new(selector, "versions_bind_arguments_tests_title", versions.bind_arguments_tests)
res = res .. drop_box.new(selector, "modes_options_uses_tests_title", modes.options_from_mode_tests)
-- res = res .. drop_box.new(selector, "modes_options_uses_tests_title", modes.options_from_mode_tests,
-- d.bg1="yellow", d.border_color="red", d.border_radius="10px 10px 10px 10px", image="Sanscrit dha.svg", } ) -- , cssview=true
res = res .. drop_box.new(selector, "modes_recursive_normal_tests_title", modes.recursive_normal_tests) -- only errors
-- arguments list
-- res = res .. drop_box.new(selector, "modes_all_categories_list_title", modes.all_categories_list) -- n = 0
Ligne 10 331 ⟶ 10 334 :
-- arguments support
-- res = res .. drop_box.new(selector, "modes_multiple_selection_tests_title", modes.multiple_selection_tests)
res = res .. drop_box.new("never"selector, "modes_multiple_values_tests_title", modes.multiple_values_tests)
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