6
$\begingroup$

I want to find some single meaningful words in the "ASCII/Unicode" form characters.

For example, I want to get alpha from \[Alpha].

\[Alpha] // FullForm
\[Alpha]

here there are two ways:

method 1


Obtain all FullForm such characters list, and get the words, and check the validity/

{"\[Alpha]", "\[Function]", "\[Beta]"} // FullForm
List["\[Alpha]","\[Function]","\[Beta]"]
wordlist = StringCases[
            ToString[FromCharacterCode[Range[0, 200]], CharacterEncoding -> "ASCII"],  
            Shortest["\\["~~x__~~"]"] /;(Length@DictionaryLookup[x, IgnoreCase -> True]                   
                                         >= 1) -> x
                      ]
{Cent,Sterling,Currency,Yen,Section,Micro,Paragraph}

The above code becomes too slow at Range is 20000, so how to speed up it, and extend the characters(some maybe not in FromCharacterCode[Range[0,65536]) such like "\[Function]" this is the question1 .

method 2


I have a wordlist to check the validity.

For example, alpha, then convert it into the right string form.

we can check by ToExpression, the problem is ToExpression sometimes returns too many errors for some wrong string.

Something like a function SyntaxQ(which failed at such characters \[Function])

SyntaxQ["\\[Function]"]
False
wordlist = "\\["<>StringJoin[MapAt[ToUpperCase, Characters[#], 1]]<>"]" & /@     
           DictionaryLookup["*"];

Select[wordlist, SyntaxQ] // Union
{\[Alpha],\[Andy],\[Angle],\[Angstrom],\[Bet],\[Beta],\[Breve],\[Bullet],\[Cedilla],\[Cent
],\[Chi],\[Continuation],\[Copyright],\[Currency],\[Dagger],\[Dash],\[Degree],\[Delta],\[D
iameter],\[Earth],\[Ellipsis],\[Epsilon],\[Eta],\[Euro],\[Flat],\[Florin],\[Gamma],\[Hyphe
n],\[Infinity],\[Iota],\[Jupiter],\[Kappa],\[Lambda],\[Mars],\[Mercury],\[Micro],\[Moon],\
[Mu],\[Natural],\[Neptune],\[Nu],\[Null],\[Omega],\[Omicron],\[Paragraph],\[Phi],\[Pi],\[P
laceholder],\[Pluto],\[Prime],\[Psi],\[Rho],\[Rupee],\[Saturn],\[Section],\[Sharp],\[Sigma
],\[Spooky],\[Sterling],\[Stigma],\[Sun],\[Tau],\[Theta],\[Thorn],\[Trademark],\[Upsilon],
\[Uranus],\[Venus],\[Villa],\[Wolf],\[Xi],\[Yen],\[Zeta]}
% // Length
73

So, I just found 73 words, that's too little.

I think/hope there is a list(maybe some files) for such "ASCII"/Special characters.

question2 is to set up from a wordlist I wanna to check.

References


Of course we can import such help pages to get all such words, but I'd like some way like Names["*"] to get all such codes, that's much faster.

guide/SpecialCharacters

$\endgroup$
16
  • $\begingroup$ You can consider that I want to count the vocabulary in the SpecialCharacters. Good Night. Hope not so bad to understand. $\endgroup$ Sep 10, 2013 at 15:29
  • $\begingroup$ Sounds like you want the unicode names list: unicode.org/Public/UNIDATA/NamesList.txt Note that Mma doesn't support anything above FFFF. $\endgroup$
    – Szabolcs
    Sep 10, 2013 at 15:30
  • $\begingroup$ @Szabolcs Yes, I think part of special characters are NameList of unicode, I'm not sure whether that's all the same in Mathematica, maybe some special characters are unique in Mathematica? $\endgroup$ Sep 10, 2013 at 15:31
  • $\begingroup$ No, it's not the same. So what you want is precisely their Mathematica names? $\endgroup$
    – Szabolcs
    Sep 10, 2013 at 15:31
  • 1
    $\begingroup$ @Mr.Wizard & m_goldberg: actually that seems to be the case. See here and here $\endgroup$
    – Szabolcs
    Sep 11, 2013 at 17:08

3 Answers 3

5
$\begingroup$

Building on an example from the documentation of FromCharacterCode,

c = Select[ToString[FullForm[FromCharacterCode[#]]] & /@ Range[65535],
    StringMatchQ[#, "\"\\[" ~~ ___] &];
Length[c]
Grid@Sort[
  Partition[Riffle[c, ToExpression[c]], 
    2] /. {a_, b_} :> {StringTake[a, {4, -3}], b}]

923

Partial output, in alphabetical order

special chars


Which of the special characters are English words (in lower case)?

DictionaryLookup /@ (%[[1, All, 1]] // ToLowerCase) // Flatten

{"alpha", "and", "angle", "angstrom", "backslash", "because", "bet", "beta", "breve", "bullet", "cap", "cedilla", "cent", "chi", "cloverleaf", "colon", "conditioned", "congruent", "conjugate", "continuation", "copyright", "cross", "cup", "curl", "currency", "dagger", "dash", "degree", "delta", "diameter", "diamond", "distributed", "divergence", "divide", "divides", "earth", "element", "ellipsis", "epsilon", "equal", "equilibrium", "equivalent", "eta", "euro", "exists", "flat", "florin", "formals", "function", "gamma", "gradient", "hyphen", "implies", "infinity", "integral", "intersection", "iota", "kappa", "lambda", "mars", "mercury", "micro", "minus", "moon", "mu", "natural", "nor", "not", "nu", "null", "omega", "omicron", "or", "paragraph", "perpendicular", "phi", "pi", "piecewise", "placeholder", "precedes", "prime", "product", "proportion", "proportional", "psi", "rho", "rule", "rupee", "scripts", "section", "sharp", "sigma", "spooky", "square", "star", "sterling", "stigma", "subset", "succeeds", "sum", "sun", "tau", "therefore", "theta", "thorn", "tilde", "times", "trademark", "transpose", "union", "upsilon", "villa", "wedge", "wolf", "xi", "yen", "zeta"}

Length[%]

117


Which of the special characters are English words (in upper case)?

DictionaryLookUp recognizes the following special characters in Upper case:

{"Andy", "Angstrom", "Chi", "Colon", "Cross", "Delta", "Jupiter", "Mars", "Mercury", "Moon", "Neptune", "Pluto", "Saturn", "Sharp", "Sterling", "Thorn", "Union", "Uranus", "Venus", "Villa", "Wolf"}

Of those it recognizes the following ONLY in uppercase: the name of a man and the names of the planets in our solar system.

{"Andy", "Jupiter", "Neptune", "Pluto", "Saturn", "Uranus", "Venus"}

$\endgroup$
3
  • 2
    $\begingroup$ I wonder if the \[Andy] character has anything to do with @AndyRoss (easter egg?) $\endgroup$ Sep 10, 2013 at 19:47
  • $\begingroup$ There's also \[Villa], \[Akuz], \[Spooky] $\endgroup$
    – Szabolcs
    Sep 10, 2013 at 23:22
  • $\begingroup$ @Szabolcs I wonder why those characters didn't appear. $\endgroup$
    – DavidC
    Sep 11, 2013 at 0:13
4
$\begingroup$

Why not to open SystemFiles/FrontEnd/TextResources/UnicodeFontMapping.tr and import these characters and their codes?

The list of names can be loaded in the following way

Join @@ StringCases[#, "[" ~~ x__ ~~ "]" :> x] & @
 Flatten @ Import @ 
   FileNameJoin[{$InstallationDirectory, 
     "/SystemFiles/FrontEnd/TextResources/UnicodeFontMapping.tr"}]

931 words

$\endgroup$
2
$\begingroup$

Here is the first part of David's answer in a more concise and efficient form:

StringCases[
  ToString @ FullForm @ FromCharacterCode @ Range @ 65535,
  a : ("\\[" ~~ Shortest[x__] ~~ "]") :> {x, ToExpression["\"" <> a <> "\""]}
] // Sort // Grid
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.