Interpreter[form]

represents an interpreter object that can be applied to an input to try to interpret it as an object of the specified form.

Interpreter[form,test]

returns the interpreted object only if applying test to it yields True; otherwise it returns a Failure object.

Interpreter[form,test,fail]

returns the result of applying the function fail if the test fails.

Details and Options

Examples

open allclose all

Basic Examples  (8)

Interpret a number in any standard explicit format:

Interpret a number given linguistically:

Flag a failure if the input given is not of the type specified:

Interpret a date, generating a DateObject:

Interpret a city, generating an Entity object:

Interpret a university:

Interpret a location, returning a GeoPosition:

Interpret a list of numbers:

Interpret a File object:

Interpret a URL object:

Interpret a number restricted to be between 1 and 10:

If the number is outside the range, a failure is generated:

Interpret a city restricted to a geographical region:

Run a test on the result:

Use a custom failure mode when the test doesn't pass:

Scope  (3)

Interpret many types of entities:

Enable computations:

Interpret string representations of files:

Options  (9)

AmbiguityFunction  (1)

Return all the possible interpretations:

DateFormat  (2)

Specify a custom date format:

Specify multiple date formats to be tried in order:

DigitBlock  (1)

Change the maximum length of blocks of digits between separators:

GeoLocation  (1)

Set a location to use for semantic interpretations:

By default, the user's $GeoLocation is used:

NumberPoint  (1)

Set a custom decimal point:

NumberSeparator  (1)

Change the separator between blocks of digits:

NumberSigns  (1)

Change the signs for negative and positive numbers:

TimeZone  (1)

Set the time zone to use for semantic interpretations:

Properties & Relations  (4)

Interpreter specifications are used to create FormObject, FormFunction, and APIFunction:

The Interpreter head is optional, but it can be useful to specify options:

Use RepeatingElement and CompoundElement to interpret complicated structures:

Alternatives can also be used to interpret data that can have different shapes:

Possible Issues  (3)

The number and date options are not compatible with semantic interpreters:

If an AmbiguityFunction is set that is not Automatic, the test at the second argument is applied to its result, possibly leading to a failure:

Interpreter["String"] accepts an empty string. This is not true for FormFunction, where the empty string and an empty field are considered equivalent:

Neat Examples  (1)

Obtain the GeoPosition for the White House:

Show it on a map:

Wolfram Research (2014), Interpreter, Wolfram Language function, https://reference.wolfram.com/language/ref/Interpreter.html (updated 2016).

Text

Wolfram Research (2014), Interpreter, Wolfram Language function, https://reference.wolfram.com/language/ref/Interpreter.html (updated 2016).

CMS

Wolfram Language. 2014. "Interpreter." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/Interpreter.html.

APA

Wolfram Language. (2014). Interpreter. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Interpreter.html

BibTeX

@misc{reference.wolfram_2024_interpreter, author="Wolfram Research", title="{Interpreter}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/Interpreter.html}", note=[Accessed: 27-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_interpreter, organization={Wolfram Research}, title={Interpreter}, year={2016}, url={https://reference.wolfram.com/language/ref/Interpreter.html}, note=[Accessed: 27-November-2024 ]}