Frequency of punctuation characters used in Mathematica languages
Like belisarius said in a comment, it's going to be a lot more accurate if you check the frequency on your own codebase. This is how to check the frequency of special characters in the 100 most popular answers on this site.
Needs["jSoupLink`"] (* Package: http://mathematica.stackexchange.com/questions/71914/extract-information-from-html-using-css-selectors *)
url = "https://api.stackexchange.com/2.2/answers?pagesize=100&order=desc&sort=votes&site=mathematica&filter=!1zSk*x-JSjj*nMuua98Vm";
data = Import[url, "JSON"];
data = "body" /. ("items" /. data);
answers = ParseHTMLFragment[#, "code", {"text"}] & /@ data;
counts = Tally@Characters[StringJoin @@ Flatten@answers];
counts = Reverse@SortBy[counts, Last];
notSpecial = Join[
CharacterRange["A", "Z"],
CharacterRange["a", "z"],
CharacterRange["0", "9"],
{" "}
];
DeleteCases[counts, {Alternatives @@ notSpecial, _}] // TableForm
If any user here wants to check their own character frequency, you can generate a URL that collects your answers by providing your user ID like this:
url[id_] := "https://api.stackexchange.com/2.2/users/" <> ToString@id <> "/answers?pagesize=100&order=desc&sort=activity&site=mathematica&filter=!4)7xaKyZCTSLfUVAL";
data = Import[url[yourUserId], "JSON"];
(* select your codebase files *)
SetDirectory[$InstallationDirectory];
fns = FileNames["*.nb", {"*"}, Infinity][[1 ;; 10]]
(* Read files and tally the chars *)
pp = SortBy[Tally@Flatten@(Characters[Import[#, "Text"]] & /@ fns), -#[[2]] &]
(* discard the letters & digits *)
pp1 = Select[pp, ! StringMatchQ[#[[1]], WordCharacter] &]
(* Plot *)
BarChart[pp1[[All, 2]], ChartLabels -> pp1[[All, 1]]]
Note: the first two are "space" and "newline"
Applying belisarius's code to look at all included package files with the modification of:
fns = FileNames["*.m", {"*"}, Infinity];
I get:
Not much love for Slot
-based functions it seems.