Skip to main content

Using Knowledge Interactions

This page describes how to register and execute Knowledge Interactions.

How to instantiate a Knowledge Interaction?

You only need to register your Knowledge Interactions once. They are, however, dynamic and can be added and removed if needed.

// ASK:
AskKnowledgeInteraction askInteraction = new AskKnowledgeInteraction(communicativeAct, graphPattern);
smartConnector.register(askInteraction);

// ANSWER:
AnswerKnowledgeInteraction answerInteraction = new AnswerKnowledgeInteraction(communicativeAct, graphPattern);
smartConnector.register(answerInteraction);

// POST:
PostKnowledgeInteraction postInteraction = new PostKnowledgeInteraction(communicativeAct, argumentGraphPattern, resultGraphPattern);
smartConnector.register(postInteraction);

// REACT:
ReactKnowledgeInteraction reactInteraction = new ReactKnowledgeInteraction(communicativeAct, argumentGraphPattern, resultGraphPattern);
smartConnector.register(reactInteraction);

You can also provide a name for your interaction, for example:

AskKnowledgeInteraction askInteraction = new AskKnowledgeInteraction(communicativeAct, graphPattern, name); 

If you want to use prefixes in your graph pattern, these can be defined in the graphPattern:

GraphPattern graphPattern = new GraphPattern(prefixes, pattern);

How to add a knowledge interaction?

AskKnowledgeInteraction askInteraction = new AskKnowledgeInteraction(graphPattern);
sc.register(askInteraction);

How to execute a Knowledge Interaction?

AskResult interactionResult = sc.ask(askInteraction, queryBindings).get();

How to get the result of a Knowledge Interaction?

After executing a Knowledge Interaction, you can access the bindings from its result. These bindings will provide actual values for the variables in the graph pattern of the interaction.

BindingSet resultBindings = interactionResult.getBindings();

How to remove a knowledge interaction?