OpenersNotesSection(Spacer1)Details

OpenersPrimaryExamplesSection(Spacer1)Examples  (7)

OpenersExampleSection0(Spacer1)Basic Examples  (7)

Interpret expressions and avoid evaluation:

Interpreter["InactiveSemanticExpression"]["two plus two"]

Interpreter["InactiveSemanticExpression"]["d sin(x) / dx"]

Find out Wolfram Language expressions corresponding to natural language queries:

Interpreter["InactiveSemanticExpression"]["height of the empire state building"]

No evaluation is attempted when matching the choices:

Interpreter[Restricted["InactiveSemanticExpression",{{1,2,3,4}}]]["two plus one"]

Interpreter[Restricted["InactiveSemanticExpression",{{2, Inactivate[2+1]}}]]["two plus one"]

By default, all symbols are allowed. Restrict to a list of allowed symbols:

Interpreter[Restricted["InactiveSemanticExpression", {Plus,Times,Equal}]]["6*4==16+8"]

Interpreter[Restricted["InactiveSemanticExpression", {Plus,Times,Equal}]]["6/4==16+8"]

By default, new symbols are created in (RefLink[$Context, paclet:ref/$Context]), but a custom context can be specified:

Interpreter[Restricted["InactiveSemanticExpression",All,Automatic,Automatic]]["y + 2"]
Context[y]

Interpreter[Restricted["InactiveSemanticExpression",All,Automatic,"mycontext`"]]["j + 2"]
Context[j]

Specify contexts for the allowed and output symbols:

mycontext`b = 10;
Interpreter[Restricted["InactiveSemanticExpression",Automatic,{"mycontext`","System`"},"mycontext`"]]["a+b"]
Context[a]

Prevent the creation of any new symbol:

Interpreter[Restricted["InactiveSemanticExpression",Automatic,Automatic,None]]["cos(pi)"]

Interpreter[Restricted["InactiveSemanticExpression",Automatic,Automatic,None]]["cos(x)"]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Interpreter, paclet:ref/Interpreter])  ▪  (RefLink[Restricted, paclet:ref/Restricted])  ▪  (RefLink[Failure, paclet:ref/Failure])  ▪  (RefLink[Inactive, paclet:ref/Inactive])  ▪  (RefLink[Inactivate, paclet:ref/Inactivate])}, {Related Interpreter Types:  (RefLink[Expression, paclet:ref/interpreter/Expression])  ▪  (RefLink[HeldExpression, paclet:ref/interpreter/HeldExpression])  ▪  (RefLink[InactiveExpression, paclet:ref/interpreter/InactiveExpression])  ▪  (RefLink[SemanticExpression, paclet:ref/interpreter/SemanticExpression])  ▪  (RefLink[HeldSemanticExpression, paclet:ref/interpreter/HeldSemanticExpression])  ▪  (RefLink[MathExpression, paclet:ref/interpreter/MathExpression])  ▪  (RefLink[MathFormula, paclet:ref/interpreter/MathFormula])  ▪  (RefLink[WolframLanguageSymbol, paclet:ref/interpreter/WolframLanguageSymbol])  ▪  (RefLink[HeldMathExpression, paclet:ref/interpreter/HeldMathExpression])  ▪  (RefLink[InactiveMathExpression, paclet:ref/interpreter/InactiveMathExpression])  ▪  (RefLink[HeldMathFormula, paclet:ref/interpreter/HeldMathFormula])  ▪  (RefLink[InactiveMathFormula, paclet:ref/interpreter/InactiveMathFormula])  ▪  (RefLink[ComputedWolframLanguageSymbol, paclet:ref/interpreter/ComputedWolframLanguageSymbol])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Setting Up Input Interpreters, paclet:guide/InterpretingStrings])}})}})