You can apply a context to a question that you send with the Ask
action. The context specifies additional information to limit the scope of the question. In Fact Bank the context is a specific entity used in disambiguation, for example, you might set a context to specify that a user is asking questions about Cambridge UK, rather than Cambridge Massachusetts or Ontario. For Answer Bank or Passage Extractor, the context is a string that could, for example, come from a previous question.
You create a question context by using the ManageResources
action. You do not set a system name in the ManageResources
action, which means that the context applies to questions that you ask of all systems.
Each question context that you create uses a licensed conversation slot (in the same way as conversation sessions). ManageResources
returns an error if you do not have enough capacity. In this case, you must wait until a conversation session or question context expires, or delete one before you can create another. See Configure Context Expiration.
You can define a context in a Fact Bank instance by using an entity code.
action=ManageResources
Data={ "type": "context", "operation": "add", "context": [{ "system_name": "factbank1", "data": [{ "code_type": "entity", "name": "Cambridge", "codes": ["Q350"] }] }] }
In this example, the code Q350
corresponds to Cambridge UK.
You can define a context in an Answer Bank instance by using a context string.
action=ManageResources
Data={ "type": "context", "operation": "add", "context": [{ "system_name": "answerbank1", "data": { "subject": ["MyCompany"] } }] }
In this example, "MyCompany"
could be a context returned from a previous question.
You can define a context in a Passage Extractor instance by using a context string.
action=ManageResources
Data={ "type": "context", "operation": "add", "context": [{ "system_name": "passageextractor1", "data": { "context": ["france"] } }] }
In this example, "france"
could be a context returned from a previous question.
You can retrieve the full schema for the JSON object to use by using the GetResources
action. See Find the JSON Schema for Your Update.
The ManageResources
action fails if you attempt to use request JSON that contains properties that are not contained in the appropriate schema.
The action returns an ID, which you can use in the Ask
action to set the context for a question.
You can also retrieve the question context ID by sending a GetResources
action with the Type
parameter set to context
.
When you have a question context ID, you can send it in the Ask
action Context
parameter. For example:
action=Ask&Text=What is its population?&Context=860028728520387723
If this is the ID for the context created in the Fact Bank example above, this action returns the population of Cambridge UK.
Question contexts use conversation session license slots. To ensure that you do not run out of conversation sessions or question contexts, you can:
ManageResources
action. To configure context expiration, you can set the ExpirationIdleTime and ExpirationInterval configuration parameters in the [AskContext] section of your configuration file. For example:
[AskContext]
ExpirationIdleTime=600
ExpirationInterval=30
For more information about these parameters, refer to the Answer Server Reference.
|