Difference between revisions of "Module:Data/namespaces/videoGames/static/name"
m (That mw.log was for debugging. Align parenthesis.) |
(Restoring revision 4736323 by User:Dinoguy1000 on 2021-07-21 19:56:53. "also rm "Rush Duel"") |
||
(One intermediate revision by one other user not shown) | |||
Line 26: | Line 26: | ||
:gsub( 'arcv', '' ) | :gsub( 'arcv', '' ) | ||
:gsub( 'vrains', '' ) | :gsub( 'vrains', '' ) | ||
+ | :gsub( 'rushduel', '' ) | ||
-- Remove some redundant words: | -- Remove some redundant words: | ||
:gsub( 'the', '' ) | :gsub( 'the', '' ) | ||
:gsub( 'gameboy', '' ) | :gsub( 'gameboy', '' ) | ||
+ | :gsub( '%(videogame%)', '' ) | ||
-- Normalize some titles: | -- Normalize some titles: | ||
:gsub( 'expert', 'ex' ) | :gsub( 'expert', 'ex' ) | ||
:gsub( 'worldchampionshiptournament', 'worldchampionship' ) | :gsub( 'worldchampionshiptournament', 'worldchampionship' ) | ||
− | -- Remove "gx", if it's large enough (preserve "gx01", "gx3", "ygoo", "ygo" ): | + | -- Remove "gx" and "ygo", if it's large enough (preserve "gx01", "gx3", "ygoo", "ygo" ): |
if normalizedV:len() > 4 then | if normalizedV:len() > 4 then | ||
normalizedV = normalizedV | normalizedV = normalizedV | ||
Line 42: | Line 44: | ||
if normalizedV:len() > 13 then | if normalizedV:len() > 13 then | ||
normalizedV = normalizedV:gsub( 'duelmonsters', '' ) | normalizedV = normalizedV:gsub( 'duelmonsters', '' ) | ||
+ | |||
-- Remove "worldchampionship", if it's large enough (preserve cases like /worldchampionship20\d\d/): | -- Remove "worldchampionship", if it's large enough (preserve cases like /worldchampionship20\d\d/): | ||
if normalizedV:len() > 21 then | if normalizedV:len() > 21 then |
Latest revision as of 08:44, 16 March 2023
-- <pre>
local thisData = mw.loadData( 'Module:Data/namespaces/videoGames/static/name/data' )
local function normalize( v )
if type( v ) ~= 'string' then
return nil
end
local normalizedV = table.concat( { v, ' ' } )
:lower()
-- Replace roman numerals:
:gsub( ' viii[!: ]', '8' )
:gsub( ' vii[!: ]', '7' )
:gsub( ' vi[!: ]', '6' )
:gsub( ' v[!: ]', '5' )
:gsub( ' iv[!: ]', '4' )
:gsub( ' iii[!: ]', '3' )
:gsub( ' ii[!: ]', '2' )
:gsub( ' i[!: ]', '1' )
-- Remove a bunch of commonly used characters:
:gsub( "[%s%-_'/:! ]", '' )
-- Remove series names:
:gsub( 'yugioh', '' )
:gsub( '5ds', '' )
:gsub( 'zexal', '' )
:gsub( 'arcv', '' )
:gsub( 'vrains', '' )
:gsub( 'rushduel', '' )
-- Remove some redundant words:
:gsub( 'the', '' )
:gsub( 'gameboy', '' )
:gsub( '%(videogame%)', '' )
-- Normalize some titles:
:gsub( 'expert', 'ex' )
:gsub( 'worldchampionshiptournament', 'worldchampionship' )
-- Remove "gx" and "ygo", if it's large enough (preserve "gx01", "gx3", "ygoo", "ygo" ):
if normalizedV:len() > 4 then
normalizedV = normalizedV
:gsub( 'gx', '' )
:gsub( 'ygo', '' )
-- Remove "duelmonsters", if it's large enough (preserve cases like /duelmonsters\d/):
if normalizedV:len() > 13 then
normalizedV = normalizedV:gsub( 'duelmonsters', '' )
-- Remove "worldchampionship", if it's large enough (preserve cases like /worldchampionship20\d\d/):
if normalizedV:len() > 21 then
normalizedV = normalizedV:gsub( 'worldchampionship', '' )
end
end
end
return normalizedV
end
return function( v )
return thisData.main[
thisData.normalize[
normalize( v )
]
]
end
-- </pre>