FindTextualAnswer[text,"question"]
gives the substring of text that best appears to answer question.
FindTextualAnswer[text,"question",n]
gives a list of up to n answers that appear most probable.
FindTextualAnswer[text,"question",n,prop]
gives the specified property for each answer.
FindTextualAnswer
FindTextualAnswer[text,"question"]
gives the substring of text that best appears to answer question.
FindTextualAnswer[text,"question",n]
gives a list of up to n answers that appear most probable.
FindTextualAnswer[text,"question",n,prop]
gives the specified property for each answer.
Details and Options
- In FindTextualAnswer[text,…], text can be a string, a file with plain text, a ContentObject expression or a list of these text objects.
- FindTextualAnswer[text,{"question1","question2",…},…] gives answers for each of the questioni.
- The property prop can be one of the following:
-
"String" substring corresponding to candidate answer "Probability" estimated probability that the answer is correct "Position" start and end positions in text of the answer "Sentence" sentence containing the candidate answer "Line" line containing the candidate answer "Paragraph" paragraph containing the candidate answer "HighlightedSentence" sentence with candidate answer highlighted "HighlightedLine" line with candidate answer highlighted "HighlightedParagraph" paragraph with candidate answer highlighted {prop1,prop2,…} a list of property specifications - The following option can be given:
-
TargetDevice "CPU" target device on which to perform the computation PerformanceGoal Automatic which aspects of performance to optimize - Possible settings for PerformanceGoal include "Speed" and "Quality".
- FindTextualAnswer uses statistical methods to try to find answers. Details of the text and question can affect its performance.
- FindTextualAnswer may download resources that will be stored in your local object store at $LocalBase, and that can be listed using LocalObjects[] and removed using ResourceRemove.
Examples
open all close allBasic Examples (2)
Answer a question from a sentence:
FindTextualAnswer["Paris is the capital and most populous city of France, with a 2015 population of 2,229,621.", "How many people live in Paris?"]Answer a question from a paragraph:
FindTextualAnswer["The dodo (Raphus cucullatus) is an extinct flightless bird that was endemic to the island of Mauritius, east of Madagascar in the Indian Ocean. The dodo's closest genetic relative was the also extinct Rodrigues solitaire, the two forming the subfamily Raphinae of the family of pigeons and doves. The closest living relative of the dodo is the Nicobar pigeon. A white dodo was once thought to have existed on the nearby island of Réunion, but this is now thought to have been confusion based on the Réunion ibis and paintings of white dodos.
Subfossil remains show the dodo was about 1 metre (3 ft 3 in) tall and may have weighed 10.6–17.5 kg (23–39 lb) in the wild. The dodo's appearance in life is evidenced only by drawings, paintings, and written accounts from the 17th century.", "How big was the dodo?"]Scope (6)
Find multiple possible answers from a text:
FindTextualAnswer["Paris is the capital and most populous city of France, with a 2015 population of 2,229,621.", "How many people live in Paris?", 2]//TableFormFind multiple possible answers along with their probability:
FindTextualAnswer["Paris is the capital and most populous city of France, with a 2015 population of 2,229,621.", "How many people live in Paris?", 2, {"Probability", "String"}]//TableFormFindTextualAnswer["Paris is the capital and most populous city of France, with a 2015 population of 2,229,621.", {"How many people live in Paris?", "In which country is Paris?"}]Find the sentence containing the answer:
FindTextualAnswer["John Smith is co-founder (with cognitive psychologist Abigail Housen) of Visual Understanding in Education, a nonprofit educational research organization that develops and studies programs that train teachers to use art to teach thinking. He is the author of several children's books about art and is co-author with Abigail Housen of an art-based elementary curriculum, Visual Thinking Strategies",
"What did John write?", 1, "Sentence"]Get the position of the answer in the question:
text = "Paris is the capital and most populous city of France, with a 2015 population of 2,229,621.";FindTextualAnswer[text, {"How many people live in Paris?", "In which country is Paris?"}, 1, {"String", "Position"}]StringTake[text, {82, 90}]StringTake[text, {48, 53}]Answer several questions and display the answers in context:
context = "The population of Paris in its administrative city limits was 2,241,346 in January 2014. Paris is the capital and most populous city of France, with a 2015 population of 2,229,621. By the 17th century, Paris had become one of Europe's major centres of finance, commerce, fashion, science, and the arts, a position that it retains still today";
questions = {"What is Paris?", "When did Paris have a population of 2.24 million?", "Why is Paris famous in Europe?"};Thread[questions -> FindTextualAnswer[context, questions, 1, "HighlightedSentence"]]//TableFormLook for the answer to a question from a ContentObject expression:
contentObject = First@TextSearch["ExampleData/Text", "Alice", "ContentObject"]FindTextualAnswer[contentObject, "What did Alice take in her hands?", 2, {"Probability", "HighlightedSentence"}]//TableFormOptions (2)
PerformanceGoal (1)
Use PerformanceGoal"Quality" to get a more accurate answer:
text = "The dodo (Raphus cucullatus) is an extinct flightless bird that was endemic to the island of Mauritius, east of Madagascar in the Indian Ocean. The dodo's closest genetic relative was the also extinct Rodrigues solitaire, the two forming the subfamily Raphinae of the family of pigeons and doves. The closest living relative of the dodo is the Nicobar pigeon. A white dodo was once thought to have existed on the nearby island of Réunion, but this is now thought to have been confusion based on the Réunion ibis and paintings of white dodos.
Subfossil remains show the dodo was about 1 metre (3 ft 3 in) tall and may have weighed 10.6–17.5 kg (23–39 lb) in the wild. The dodo's appearance in life is evidenced only by drawings, paintings, and written accounts from the 17th century.";FindTextualAnswer[text, "Where did the dodo live?", 1, "HighlightedSentence", PerformanceGoal -> "Quality"]FindTextualAnswer[text, "Where did the dodo live?", 1, "HighlightedSentence", PerformanceGoal -> "Speed"]TargetDevice (1)
Answer questions using the default system GPU, if available:
question = "Who was the architect of the Sagrada Familia?";articles = WikipediaData /@ WikipediaSearch["Content" -> question];AbsoluteTiming[FindTextualAnswer[articles, question, TargetDevice -> "GPU"]]The computation is typically faster than with CPU:
AbsoluteTiming[FindTextualAnswer[articles, question]]If a compatible GPU is not available, a message is issued:
FindTextualAnswer["You need a GPU device with recent drivers.", "What is needed?", TargetDevice -> {"GPU", 999}]Applications (1)
Search an Answer to a General Question in Wikipedia (1)
Display in context the possible answers from a Wikipedia search:
question = "Who was the architect of the Sagrada Familia?";articles = WikipediaData /@ WikipediaSearch["Content" -> question];FindTextualAnswer[articles, question, 5, {"Probability", "HighlightedSentence"}]The instances of the same names can be grouped along with their probabilities:
namesAndProbabilities = FindTextualAnswer[articles, question, 10, {"String", "Probability"}];groupedInstances = GroupBy[namesAndProbabilities, First -> Last]Then the one with the largest total sum of probability is probably the good answer:
TakeLargestBy[groupedInstances, Total, 1]Possible Issues (1)
FindTextualAnswer is able to understand semantic concepts to some extent but is not able to use logic to guess a number:
FindTextualAnswer["I have either 1, 2, 3, 4, or 5 eggs. I had 5 eggs, but lost 3 and then bought 2 new ones.", "How many eggs do I have?"]See Also
WolframAlpha TextCases TextSearch WikipediaSearch WebSearch EntityValue
Function Repository: GenerateQuestionsFromSentence
Related Guides
Text
Wolfram Research (2018), FindTextualAnswer, Wolfram Language function, https://reference.wolfram.com/language/ref/FindTextualAnswer.html (updated 2020).
CMS
Wolfram Language. 2018. "FindTextualAnswer." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/FindTextualAnswer.html.
APA
Wolfram Language. (2018). FindTextualAnswer. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FindTextualAnswer.html
BibTeX
@misc{reference.wolfram_2026_findtextualanswer, author="Wolfram Research", title="{FindTextualAnswer}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/FindTextualAnswer.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_findtextualanswer, organization={Wolfram Research}, title={FindTextualAnswer}, year={2020}, url={https://reference.wolfram.com/language/ref/FindTextualAnswer.html}, note=[Accessed: 12-June-2026]}