FindTextualAnswer[text,"question"]
提供对 question 给出最佳答案的 text 的子字符串.
FindTextualAnswer[text,"question",n]
列出最有可能的 n 个答案.
FindTextualAnswer[text,"question",n,prop]
给出每个答案的指定属性.
FindTextualAnswer
FindTextualAnswer[text,"question"]
提供对 question 给出最佳答案的 text 的子字符串.
FindTextualAnswer[text,"question",n]
列出最有可能的 n 个答案.
FindTextualAnswer[text,"question",n,prop]
给出每个答案的指定属性.
更多信息和选项
- 在 FindTextualAnswer[text,…] 中,text 可以是一个字符串、纯文本文件、一个 ContentObject 表达式或这些文本对象的列表.
- FindTextualAnswer[text,{"question1","question2",…},…] 给出每个 questioni 的答案.
- 属性 prop 可以为以下任意形式:
-
"String" 对应于候选答案的子字符串 "Probability" - 估计的答案正确的概率
"Position" - 答案 text 中的起始位置和结束位置
"Sentence" 含有候选答案的句子 "Line" 含有候选答案的行 "Paragraph" 含有候选答案的段落 "HighlightedSentence" 其中候选答案被突出显示的句子 "HighlightedLine" 其中候选答案被突出显示的行 "HighlightedParagraph" 其中候选答案被突出显示的段落 {prop1,prop2,…} 属性指定列表 - 可以给出下列选项:
-
TargetDevice "CPU" 执行计算的目标设备 PerformanceGoal Automatic 优化的目标 - PerformanceGoal 可能的设置包括 "Speed" 和 "Quality".
- FindTextualAnswer 试图利用统计方法找到答案. 文字和问题的细节可能会影响其性能.
- FindTextualAnswer 可能会下载一些资源,将其保存在 $LocalBase 的本地对象存储,可以用 LocalObjects[] 来显示或用 ResourceRemove 将其移除.
范例
打开所有单元 关闭所有单元基本范例 (2)
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?"]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?"]范围 (6)
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]//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?", 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?"}]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"]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}]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"]]//TableForm查找来自 ContentObject 表达式的问题的答案:
contentObject = First@TextSearch["ExampleData/Text", "Alice", "ContentObject"]FindTextualAnswer[contentObject, "What did Alice take in her hands?", 2, {"Probability", "HighlightedSentence"}]//TableForm选项 (2)
PerformanceGoal (1)
用 PerformanceGoal"Quality" 获取更准确的答案:
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)
question = "Who was the architect of the Sagrada Familia?";articles = WikipediaData /@ WikipediaSearch["Content" -> question];AbsoluteTiming[FindTextualAnswer[articles, question, TargetDevice -> "GPU"]]AbsoluteTiming[FindTextualAnswer[articles, question]]FindTextualAnswer["You need a GPU device with recent drivers.", "What is needed?", TargetDevice -> {"GPU", 999}]应用 (1)
在维基百科搜索一个普通问题的答案 (1)
question = "Who was the architect of the Sagrada Familia?";articles = WikipediaData /@ WikipediaSearch["Content" -> question];FindTextualAnswer[articles, question, 5, {"Probability", "HighlightedSentence"}]namesAndProbabilities = FindTextualAnswer[articles, question, 10, {"String", "Probability"}];groupedInstances = GroupBy[namesAndProbabilities, First -> Last]TakeLargestBy[groupedInstances, Total, 1]可能存在的问题 (1)
FindTextualAnswer 能够在一定程度上理解语义概念,但不能用逻辑来猜测一个数字:
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?"]文本
Wolfram Research (2018),FindTextualAnswer,Wolfram 语言函数,https://reference.wolfram.com/language/ref/FindTextualAnswer.html (更新于 2020 年).
CMS
Wolfram 语言. 2018. "FindTextualAnswer." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2020. https://reference.wolfram.com/language/ref/FindTextualAnswer.html.
APA
Wolfram 语言. (2018). FindTextualAnswer. Wolfram 语言与系统参考资料中心. 追溯自 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: 05-September-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: 05-September-2026]}