"SemanticNumber" (Interpreter Type)
Number in a standard format or in natural language.
Details
- "SemanticNumber" can be used in Interpreter and related constructs, including deployed smart form fields.
- Use of "SemanticNumber" requires connectivity to the Wolfram Cloud.
Restriction Specifications
-
Restricted["SemanticNumber",{{choices1,…}}] one among choices Restricted["SemanticNumber",max] a number below max Restricted["SemanticNumber",{min,max}] a number between min and max Restricted["SemanticNumber",{min,max,s}] a number between min and max, with step s Restricted["SemanticNumber",Automatic,n] a number with n-digit precision
Interpretation
- "SemanticNumber" yields a number with head Integer, Rational, or Real.
Examples
Basic Examples (3)
Interpreter["SemanticNumber"]["3"]Interpreter["SemanticNumber"]["6.0098e7"]Interpreter["SemanticNumber"]["6.0098`2"]Interpret numbers in natural language:
Interpreter["SemanticNumber"]["two thirds"]Interpreter["SemanticNumber"]["six"]Interpreter[Restricted["SemanticNumber", {1, 3}]][{"one", "two", "three", "four"}]Restrict to the first five prime numbers:
Interpreter[Restricted["SemanticNumber", {Prime /@ Range[5]}]]["five"]Restrict to odd numbers below 100:
Interpreter[Restricted["SemanticNumber", {1, 100, 2}]]["seventeen"]Interpreter[Restricted["SemanticNumber", Automatic, 10]]["one third"]Otherwise, $MachinePrecision is implied:
Interpreter["SemanticNumber"]["one third"]//PrecisionWhen the number contains a Precision or Accuracy, and a precision restriction is also specified, the lower of the two will be applied:
Interpreter[Restricted["ComputedNumber", Automatic, 3]]["1.23456789`8"]Interpreter[Restricted["ComputedNumber", Automatic, 2]]["1.23456789``10"]Related Guides
History
Introduced in 2014 (10.0)