Name the Hadrons

JavaScript (ES6), 456 448 431 420 bytes

This code is using only two small lookup tables:

  • one to identify the quarks: 'CUBDScubds'
  • another one to detect the 'anti' prefix of Mesons: 'SdUcBdBs'

Everything else is deduced from the quarks.

(s,[a,b]=[...s].map(c=>(i='CUBDScubds'.search(c)%5,m|=1<<i,j+=i<2,k+=i&1,p+=i?i-2?'':'bottom ':'charmed ',i),m=j=k=0,p=''))=>s[2]?p.replace(/(\w+) \1( \1)?/,(_,a,b)=>b?'triple'+b:'double '+a)+(s>'Z'?'anti':'')+['omega','xi','sigma','delta'][k]+('-0+'[j]||'++'):(m&16&&m&5?'strange ':'')+(~'SdUcBdBs'.search(s)?'anti':'')+(m&1?m^1?'D mes':'psi':m&4?m^4?'B mes':'upsil':m&16?m^16?'ka':'phi':'pi')+'on'+'-0+'[(a<2)-(b<2)+1]

let f =

(s,[a,b]=[...s].map(c=>(i='CUBDScubds'.search(c)%5,m|=1<<i,j+=i<2,k+=i&1,p+=i?i-2?'':'bottom ':'charmed ',i),m=j=k=0,p=''))=>s[2]?p.replace(/(\w+) \1( \1)?/,(_,a,b)=>b?'triple'+b:'double '+a)+(s>'Z'?'anti':'')+['omega','xi','sigma','delta'][k]+('-0+'[j]||'++'):(m&16&&m&5?'strange ':'')+(~'SdUcBdBs'.search(s)?'anti':'')+(m&1?m^1?'D mes':'psi':m&4?m^4?'B mes':'upsil':m&16?m^16?'ka':'phi':'pi')+'on'+'-0+'[(a<2)-(b<2)+1]

res = [
  "UUU", "uuu", "UUD", "uud", "UDD", "udd", "DDD", "ddd", "UUS", "uus", "UDS", "uds", "DDS", "dds", "USS", "uss",
  "DSS", "dss", "SSS", "sss", "UUC", "uuc", "UDC", "udc", "DDC", "ddc", "UUB", "uub", "UDB", "udb", "DDB", "ddb",
  "USC", "usc", "DSC", "dsc", "UCC", "ucc", "DCC", "dcc", "USB", "usb", "DSB", "dsb", "UBB", "ubb", "DBB", "dbb",
  "UCB", "ucb", "DCB", "dcb", "SSC", "ssc", "SSB", "ssb", "SCC", "scc", "SCB", "scb", "SBB", "sbb", "CCB", "ccb",
  "CBB", "cbb", "CCC", "ccc", "BBB", "bbb", "Ud",  "Uu",  "Dd",  "Du",  "Us",  "Ds",  "Sd",  "Su",  "Ss",  "Cd",
  "Dc",  "Cu",  "Uc",  "Cs",  "Sc",  "Cc",  "Bu",  "Ub",  "Db",  "Bd",  "Sb",  "Bs",  "Bb"
]
.map(s => s + ' - ' + f(s)).join("\n");

console.log(res);


SOGL 0.11, 341 339 333 310 305 305 300 bytes

‘θw±
on”≥
0c{≤
”=?"▒
on0”←"█
c SW?"▲
?ļ0←j ►
?"anti”o}▼
SD”;W¡+}□
=?ļ-←ļ+←■
‘B≤a=+}:?"⁽¬Τk⅜K±l?@+}ob@+o}▓
UCl2-? CA"K¼⁶▓ BA"δ╬▓cd≠▼≤: U=; D=++}"8}↕x╔:⁵F┘¹±o≤"B□"κ§)Ƨ7%s±p←"Ss▒phi█Cc▒psi█Bb▒upsil█SdUcBd”2n{=▼}≤"U□1>?▲ka≥pc DW►S■"pi≥Pcρ►D■▲)»β⁴‘o}ƧBs=▼ Dc BW?X B}" mes≥+p"D═S┐╔¬ν↑FνF⌠V3╗βstA\≈²‘:cW2+Wp

Perl 5, 318 bytes

$_=<>;$h=qw/- ++ + 0/[y/uc//*2*($i=3-map{${lc;}++}/./g)-$u-$c-$i];$a=($i?!$h&&/[dUB]/:/[a-z]/)&&anti;map{/(.)/;$q.=("","$_ ","double $_ ","triple $_ ")[$$1]}charmed,bottom;print(($i?($u+$d>1?pi:$s>1?phi:$c>1?psi:$b>1?upsil:$c+$b?($s?"strange $a":$a).($b?B:D).' mes':$a.ka).on:$q.$a.qw/omega xi sigma delta/[$u+$d]).$h)

Newlines added for readability (slightly):

$_=<>
$h=qw/- ++ + 0/[y/uc//*2*($i=3-map{${lc;}++}/./g)-$u-$c-$i]
$a=($i?!$h&&/[dUB]/:/[a-z]/)&&anti
map{/(.)/;$q.=("","$_ ","double $_ ","triple $_ ")[$$1]}charmed,bottom;
print(($i?($u+$d>1?pi:$s>1?phi:$c>1?psi:$b>1?upsil:$c+$b?($s?"strange $a":$a).($b?B:D).' mes':$a.ka).on:$q.$a.qw/omega xi sigma delta/[$u+$d]).$h)