# How to extract assignment from natural language text?

I'm a bit new to NLP/IE. I'm looking for the task within NLP/IE that would be concerned with extracting a value that has been assigned.

For instance, given the text "The value is 45.1hz" or "The color is blue", I would like to be able to extract the fact that 45.1hz has been assigned to the value, or that the color has been set as blue.

I have tried to find the right name for this task - It seems somewhat related to relation extraction, however it doesn't seem to have two or more entities, and the relation unclear to me.

It may also be related to triplet extraction, but once again I'm a bit loss on what the values would be, i.e. (color, be, blue) ?

I'm looking for the name for this type of task, where you extract the value of an assignment, for a specific pre-defined value.

It's indeed a very specific type of relation extraction. Generally relation extraction is much more complex because it's not only about simple sentences Subject Verb Object and not only with the verb is.

It's not clear to me if your examples are representative of the real cases you're dealing with: if yes, you probably don't need full blown relation extraction, basic pattern matching rules will do the trick.

• Thanks for the answer.I found an example of such a relation extraction in link, i.e. where "Obama is president" is extracted as (Obama; is; president). – James2000 Sep 29 '19 at 16:22

With the Free Wolfram Engine for Developers you may use Wolfram Language. If you are using Python then use the Wolfram Client Library for Python to access the engine in Python.

You may use 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"


There would need to be a selection of the subject. Looking at TextStructure the Noun Phrase is a good place to start.

TextStructure["The color is blue."]


TextCases could be used to extract this with "NounPhrase".

TextCases["The color is blue.", "NounPhrase",
TargetDevice -> "GPU"]

{"The color"}


or "Noun"

TextCases["The color is blue.", "Noun",
TargetDevice -> "GPU"]

{"color"}


Combining with the other functions.

str = "The color is blue.";
{
#,
StringTemplate["What is the 1?"]@#,

{{"color", "blue"}}