The advent of Mathematica in the cloud and linguistic input potentially transforms expectations of the Wolfram Language's programming model and its inherent robustness. An example of this comes form trying to bridge what seems to be a disconnect in the language between its Mathematica and WolframAlpha invocations. Consider CountryData
where up until 2008 you can find the GDP of the US in Mathematica :
CountryData["UnitedStates", {"GDP", 2008}]
but surprisingly not thereafter (The great recession was bad - but surely not that catastrophic) :
CountryData["UnitedStates", {"GDP", 2009}]
(* Missing["NotAvailable"] *)
In WolframAlpha however, GDP is available for 2009 (reassuringly, life continued) as can be seen by typing "US GDP in 2009" into its web page before receiving back a raft of other information. This can be accessed within Mathematica where in particular, the GDP information can be zeroed in via the "Result"
argument:
WolframAlpha["US GDP in 2009", "Result"]
Now you can integrate this functionality by doing an apriori check on this data's availability within Mathematica and then redefining CountryData
to grab it from WolframAlpha if necessary.
SetAttributes[CheckCountryData, HoldAll];
CheckCountryData[CountryData["UnitedStates", {"GDP", yr_}]] :=
With[{temp = CountryData["UnitedStates", {"GDP", yr}]},
If[Head@temp === Missing,
Unprotect@CountryData;
CountryData["UnitedStates", {"GDP", yr}] :=
WolframAlpha[yr // StringTemplate["US GDP in `1`"], "Result"];
Protect@CountryData,
temp]
];
CheckCountryData[CountryData["UnitedStates", {"GDP", #}]] & /@Range[2008,2020];
Table[{
yr // StringTemplate["US GDP in `1`"],
With[{yr = yr},
Defer@CountryData["UnitedStates", {"GDP", yr}]],
CountryData["UnitedStates", {"GDP", yr}]},
{yr, 2008, 2020}] // TableForm
Now maybe CountryData
will be updated in Mathematica and/or the two data sources more tightly integrated at some point but the broader point remains; consider how the programming model has been changed along with the language's robustness, reliability and repeatability. The input/output/complexity/programming experience is now more fluid depending, for example, on the constancy/consistency of linguistic interpretations; the speed/availability of cloud connections, the date, W/A compatibility etc.
Note that instead of a WolframAlpha
call, Free-Form input followed by its Entity
interpretation can be used
and while this perhaps improves the interpreting consistency it is also less concise and less amenable for ready parametrization (e.g. used for a range of years instead of only 2009).
One part of Mathematica's programming language morphing into an expanded Wolfram Language seems to incorporate an ether-like presence, an interoperability (including with natural language) but I'm wondering if anyone has successfully/unsuccessfully integrated Free-Form input and/or widespread Entity
/WolframAlpha
calls in any significant way?
CountryData
lagging is probably worth flagging. Unfortunately, though this data curation issue is a much wider challenge since a pretty significant percentage of calls are in factMissing[NotAvailable]
(particularly non-US data) which I suspect reflects current priorities/curation limitations. $\endgroup$