I have the following program at home, which draws on a batch of pre-processed files (that are word frequency text files, compiled using ToLowerCase
, Tally
and Sort
. Here is an example of the file that it draws on:
{{"i", 3073}, {"you", 2860}, {"the", 1741}, {"and", 1518}, {"a", 1218}, {"me", 1209}, {"to", 1153}, {"my", 913}, {"t", 855}, {"that", 843}...
and so on. Each file is about ~ 50KB, and it's been generated using Put
and is thus grabbed using Get
.
I use them for the following program, which essentially plots word frequency for a given year (each year has its own file). It's along a similar lines as the Google ngram viewer, but on a very specific historical dataset.
Manipulate[viewerCount1 = {};
viewerCount2 = {};
SetDirectory["/users/myNAME/desktop/DB/Put/"];
filenames = FileNames["*.txt"];
Do[
input = Get[file];
yearLength = Length[input];
AppendTo[viewerCount1,
If[Length[Flatten[Cases[input, {word1, _}]]] == 0, 0,
Flatten[Cases[input, {word1, _}]][[2]]]/yearLength];
AppendTo[viewerCount2,
If[Length[Flatten[Cases[input, {word2, _}]]] == 0, 0,
Flatten[Cases[input, {word2, _}]][[2]]]/yearLength];
, {file, filenames}];
DateListPlot[{Tooltip[viewerCount1, word1],
Tooltip[viewerCount2, word2]}, {1964}, Joined -> True,
PlotLabel -> "Number of Total Word Appearances by % of All Words",
PlotStyle -> {{Red}, {Blue}}], {{word1, "war",
"First Word (Red)"}}, {{word2, "peace", "Second Word (Blue)"}}]
Here's the crux of the question, however. Is there a good way to deploy this online so other people can access it? I assume this is too big for the CDF format? Alternatively, WebMathematica sounds promising, but before I upgrade my Mathematica purchase I would love to hear if the community thinks that would be useful.
I know that there have been discussions elsewhere about sharing dynamic content with non-Mathematica users, but these seem to not rely on specific external files.
Or, am I using the wrong language to deploy the final version of this?
Answer
You cannot use CDF for this because you have textual import fields and these are not supported when you embed online. You will just get a big grey box. InputField
cannot accept strings (non-numeric) for online CDFs unless you are Wolfram Research and can override it. (I'm guessing you don't want to pay many thousands for CDF Pro.)
You also cannot import and export into an online embedded CDF, not even a Pro CDF (got that first hand from Wolfram). This is for security reasons.
So to create something like you have described using Mathematica and have online, the only possible way to do it, it would seem, is to use webMathematica.
Comments
Post a Comment