# Using free-form linguistic input in a dynamic input field

I've been playing around with dynamic input fields; here's a basic example, which just consists of an input field where the user can enter a function and then a button that can be clicked to graph the function. What I'm wondering is: is there a way to allow free-form linguistic input to be entered in the input field? Right now, I must enter regular Mathematica syntax like Cos[x] to get a graph, but I'd really like to be able to enter something like "cos x". (Ultimately, I'd like my dynamic module to do more than just graph the function, which is why I don't want to just use Wolfram Alpha directly.)

DynamicModule[{graph, f, button},
graph = Plot[1, {x, 0, 1}, PlotRange -> {0, 0.1}, Axes -> False,
ImageSize -> 480, Background -> White];
f = Cos[x];

button = Button["Graph!",
graph = Plot[f, {x, -3, 3}, ImageSize -> 480, Background -> White];
];

Panel[
Grid[{
{InputField[Dynamic[f]], button},
{Dynamic[graph], SpanFromLeft}},
Spacings -> {2, 1}, Alignment -> {Left, Baseline}
]
]
]


Thanks!

## 1 Answer

I believe that Mathematica feeds the input string in free-form linguistic input to the function WolframAlpha. Try something like

Manipulate[
If[in =!= "", WolframAlpha[in], "Enter input"],
{{in, ""}, InputField[Dynamic[in], String] &}
]


Response to comment

I can't find a definitive statement in the documentation that an internet connection is required for all free-form linguistic input, but the following suggests that it is (just as I thought, too).

• Thanks, this helps. I really just want the input form of the function, and it looks like I can get it by doing something like WolframAlpha[f, {{"Input", 1}, "Input"}] This is a separate question, but does all of the free-form linguistic input require an internet connection? I see that the WolframAlpha command certainly does, and ideally I'd use something that worked offline as well. Commented Oct 10, 2013 at 23:56
• @Janet I believe an internet connection is required. See update. Commented Oct 11, 2013 at 0:20
• Thanks! The same thing happens when I try it offline, so that must just be how it is. Commented Oct 11, 2013 at 1:16