Documentation[voir] [modifier] [historique] [purger]

Ce module contient des fonctions pour la catégorisation automatique de différents contenus.

categorisation_lexique_interlangue( frame )
voir {{catégorisation_lexique_interlangue}}
categorisation_lexique( frame )
voir {{catégorisation_lexique}}
lexique_nocat( frame )
voir {{info lex}}
lexique( frame, nocat )
voir {{lexique}}. Le paramètre nocat est uniquement destiné à usage interne, notamment par lexique_nocat.
rimes( frame )
voir {{catégorisation rimes}}
tags( frame )
voir {{catégorisation mots-clés}}
tags_banner( frame )
{{mots-clés}}

b = require('Module:bases')
rimes = require('Module:rimes')
m_lang = require('Module:langues')

local p = {}

function p.rimes(frame)
  local title = mw.ustring.match(tostring(mw.title.getCurrentTitle()), "Catégorie:(.+)")
  local lang, pron = mw.ustring.gmatch(title, "Rimes en (.*) en \\(.*)\\")()
  
  local cat = "=== Voir aussi ===\n"
  cat = cat .. "* [[:Catégorie:Phonétique en français|Dictionnaire phonétique en français]]\n"
  cat = cat .. "* [[:Catégorie:Rimes en français|Dictionnaire de rimes en français]]\n"
  cat = cat .. "** [[Annexe:Rimes en français en \\" .. pron .. "\\]]\n"
  cat = cat .. "** [[Annexe:Rimes en français]]\n"

  if rimes.est_vocalique(pron) then
     local last = mw.ustring.sub(pron, -1)

    if last == mw.ustring.char(0x303) then
      last = mw.ustring.sub(pron, -2)
    end
    
    if pron == last then
      cat = cat .. "[[Catégorie:Rimes vocaliques en " .. lang .. "|" .. pron .. "]]" 
    else
      cat = cat .. "[[Catégorie:Rimes en " .. lang .. " en \\" .. last .. "\\|" .. pron .. "]]"
    end
  else
    cat = cat .. "[[Catégorie:Rimes consonantiques en " .. lang .. "|" .. pron .. "]]"   
  end
  
  return cat
  
end

function p.tags(frame)
    local tag = string.match(tostring(mw.title.getCurrentTitle()), "Catégorie:Mots[-]clés/(.+)")

    local text = "Cette catégorie liste toutes les pages traitant du thème «  " .. tag .. "  ».\n\n"
    text = text .. "Pour accéder à plus de thèmes, consultez [[:Catégorie:Mots-clés|cette catégorie]].\n"
    text = text .. "[[Catégorie:Mots-clés|" .. tag .. "]]\n"
    text = text .. "[[Catégorie:Catégories cachées|+ Mots cles " .. tag .. "]]\n"
    text = text .. "__HIDDENCAT__"
    
    return text
end

function p.tags_banner(frame)
  local text = "<div class=\"bandeau-niveau-detail\" style=\"display: block; font-size: 0.85em; border: 1px gray solid; border-width: 1px 0; padding: 2px 4px; margin-top: -5px;\">Mots-clés : "
  
  local args = frame:getParent().args
  local tags = {}
  for i, tag in ipairs(args) do
    local nom = b.lc(tag)
    tags[i] = "[[:Catégorie:Mots-clés/" .. nom .. "|" .. nom .. "]][[Catégorie:Mots-clés/"..nom.."]]"
  end
  
  text = text .. table.concat(tags, "<span style=\"white-space:nowrap\"> '''·'''</span> ")
  text = text .. "</div>"
  
  return text
end

return p