通过免费的 Wolfram Engine for Developers,您可以使用Wolfram 语言。如果您使用的是 Python,则使用 Python 的Wolfram 客户端库来访问 Python 中的引擎。
您可以使用FindTextualAnswer.
FindTextualAnswer["The value is 45.1 hz.", "What is the value?",
TargetDevice -> "GPU"]
"45.1 hz"
FindTextualAnswer["45.1 hz was selected as nearest to the true value.", "What is the value?",
TargetDevice -> "GPU"]
"45.1 hz"
FindTextualAnswer["The color is blue.", "What is the color?",
TargetDevice -> "GPU"]
"blue"
FindTextualAnswer["We think that the color is closest to teal.", "What is the color?",
TargetDevice -> "GPU"]
"teal"
需要对主题进行选择。查看TextStructure名词短语是一个很好的起点。
TextStructure["The color is blue."]

TextCases可以用来提取这个"NounPhrase"。
TextCases["The color is blue.", "NounPhrase",
TargetDevice -> "GPU"]
{"The color"}
或者"Noun"
TextCases["The color is blue.", "Noun",
TargetDevice -> "GPU"]
{"color"}
与其他功能相结合。
str = "The color is blue.";
{
#,
FindTextualAnswer[
str,
StringTemplate["What is the `1`?"]@#,
TargetDevice -> "GPU"
]
} & /@ TextCases[str, "Noun", TargetDevice -> "GPU"]
{{"color", "blue"}}
希望这可以帮助。