Skip to content
Snippets Groups Projects
Commit d9a26616 authored by Ludovic Apvrille's avatar Ludovic Apvrille
Browse files

Improvement on knowledge

parent d9009075
No related branches found
No related tags found
No related merge requests found
......@@ -114,10 +114,12 @@ public class AIBlockConnAttrib extends AIInteract {
boolean done = false;
int cpt = 0;
int cptStage = 0;
// Blocks and attributes
while (!done && cpt < 20) {
cpt++;
cptStage ++;
boolean ok = makeQuestion(questionT);
if (!ok) {
done = true;
......@@ -155,7 +157,7 @@ public class AIBlockConnAttrib extends AIInteract {
"the full specification at once.");
}
if ((errors != null) && (errors.size() > 0)) {
if ((errors != null) && (errors.size() > 0) && (cptStage < 8)) {
questionT = "Your answer was not correct because of the following errors:";
for (String s : errors) {
questionT += "\n- " + s;
......@@ -163,13 +165,14 @@ public class AIBlockConnAttrib extends AIInteract {
} else {
//TraceManager.addDev(" Avatar spec=" + specification);
stage++;
cptStage = 0;
if (stage == KNOWLEDGE_STAGES.length) {
done = true;
} else {
makeKnowledge(stage);
questionT = QUESTION_IDENTIFY_SYSTEM_BLOCKS[stage] + chatData.lastQuestion.trim();
if (namesOfBlocks.length() > 0) {
questionT += "\nThe blocks to be used are: " + namesOfBlocks.trim();
questionT += "\nThe blocks to use are: " + namesOfBlocks.trim();
}
}
}
......
......@@ -92,10 +92,12 @@ public class AIBlockConnAttribWithSlicing extends AIInteract {
public static String[] KNOWLEDGE_STAGES = {KNOWLEDGE_ON_JSON_FOR_BLOCKS, KNOWLEDGE_ON_JSON_FOR_CONNECTIONS, KNOWLEDGE_ON_JSON_FOR_ATTRIBUTES};
AvatarSpecification specification, specification0;
private String[] QUESTION_IDENTIFY_SYSTEM_BLOCKS = {"From the following system specification, using the specified JSON format, identify the " +
private String[] QUESTION_IDENTIFY_SYSTEM_BLOCKS = {"From the provided system specification, using the specified JSON format, identify the " +
"typical system blocks. Do respect the JSON format, and provide only JSON (no explanation before or after).\n",
"From the following system specification, using the specified JSON format, identify the " +
"From the provided system specification, using the specified JSON format, identify the " +
"typical system blocks and their connections. Do respect the JSON format, and provide only JSON (no explanation before or after).\n",
"From the previous JSON and system specification, find the typical attributes of all blocks by imagining all the necessary attributes " +
"that would be needed for the state machine diagram of each block. "};
......@@ -110,9 +112,9 @@ public class AIBlockConnAttribWithSlicing extends AIInteract {
int stage = 0;
String systemSpec = chatData.lastQuestion.trim();
String json = "";
String questionT = QUESTION_IDENTIFY_SYSTEM_BLOCKS[stage] + "\n" + chatData.lastQuestion.trim() + "\n";
String questionT = QUESTION_IDENTIFY_SYSTEM_BLOCKS[stage] ;
initKnowledge();
makeKnowledge(stage);
makeKnowledge(stage, systemSpec);
boolean done = false;
int cpt = 0;
......@@ -174,13 +176,13 @@ public class AIBlockConnAttribWithSlicing extends AIInteract {
done = true;
} else {
initKnowledge();
makeKnowledge(stage);
makeKnowledge(stage, systemSpec);
if (stage == 1) {
questionT =
"The system specification is: " + systemSpec + ".\n" + QUESTION_IDENTIFY_SYSTEM_BLOCKS[stage] + ". Blocks are to " +
"use are" + namesOfBlocks;
QUESTION_IDENTIFY_SYSTEM_BLOCKS[stage] + ". Blocks to " +
"use are: " + namesOfBlocks + "\n";
} else {
questionT = QUESTION_IDENTIFY_SYSTEM_BLOCKS[stage] + chatData.lastQuestion.trim();
questionT = QUESTION_IDENTIFY_SYSTEM_BLOCKS[stage]; // + chatData.lastQuestion.trim();
}
if (namesOfBlocks.length() > 0) {
questionT += "\nThe blocks to be used are: " + namesOfBlocks.trim();
......@@ -223,10 +225,9 @@ public class AIBlockConnAttribWithSlicing extends AIInteract {
}
if (_spec != null) {
for(String s: know) {
TraceManager.addDev("\nKnowledge added: " + s);
chatData.aiinterface.addKnowledge("The system specification is: " + _spec, "ok");
}
TraceManager.addDev("\nKnowledge added: " + _spec);
chatData.aiinterface.addKnowledge("The system specification is: " + _spec, "ok");
}
......
......@@ -1191,7 +1191,8 @@ public class AvatarBlock extends AvatarElement implements AvatarStateMachineOwne
String variableName = action.substring(0, index).trim();
AvatarAttribute aa = getAvatarAttributeWithName(variableName);
if (aa == null) {
TraceManager.addDev("The following action is not valid: " + action + " because it contains an attribute " +
TraceManager.addDev("The following action is not valid: " + action +
" because it contains an attribute " +
variableName + " which is not declared in the block " + getName());
errors.add("The following action is not valid: " + action + " because it contains an attribute " +
variableName + " which is not declared in the block " + getName());
......@@ -1284,10 +1285,11 @@ public class AvatarBlock extends AvatarElement implements AvatarStateMachineOwne
if (forceIfIncorrectExpression) {
at.addAction(action);
} else {
TraceManager.addDev("The following action is not valid: " + action + ". It must contain either the affectation of a " +
"variable or a signal send/receive");
errors.add("The following action is not valid: " + action + ". It must contain either the affectation of a " +
TraceManager.addDev("The following action is not valid: " + action + ". It must contain either the " +
"setting of a " +
"variable or a signal send/receive");
errors.add("The following action is not valid: " + action + ". It must contain either the setting " +
"of a " + "variable or a signal send/receive");
}
}
}
......
......@@ -566,7 +566,7 @@ public class AvatarSpecification extends AvatarElement implements IBSParamSpec {
if (at == AvatarType.UNDEFINED) {
jsonErrors.add("In block " + newBlock.getName() + " attribute " + nameA + " is invalid because " +
"its type is invalid.");
"\"" + typeA + "\"is an invalid type (only int or bool).");
}
if (tryToCorrectErrors) {
......@@ -598,7 +598,7 @@ public class AvatarSpecification extends AvatarElement implements IBSParamSpec {
AvatarType at = AvatarType.getType(typeA);
if (at == AvatarType.UNDEFINED) {
jsonErrors.add("In block " + newBlock.getName() + " attribute " + nameA + " is invalid because " +
"its type is invalid.");
"\"" + typeA + "\"is an invalid type (only int or bool).");
}
AvatarAttribute aa;
......
......@@ -55,7 +55,7 @@ import myutil.Plugin;
import myutil.TraceManager;
/**
* Class AVATAR2CPOSIX
* Class AVATAR2SysMLV2
* Creation: 21/09/2021
*
* @author Ludovic APVRILLE
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment