It's actually pretty simple to convert Q/A based files to SIML Modern files. Let me walk you through.
Let us assume that you have a simple text file with questions and answers in the following format:
Code: Select all
How are you?
I am fine
How is life?
Doing pretty great
First create a method that returns a valid SIML Intent element by taking question and answer string:
CSharp Code
public XElement CreateIntentElement(string question, string answer)
{
var intentElement = new XElement("Intent");
var expressionElement = new XElement("Expression", question);
var responseElement = new XElement("Response",answer);
intentElement.Add(expressionElement);
intentElement.Add(responseElement);
return intentElement;
}
Now that you've got your intent element creator ready create a simple file reader that reads through you text file line by line, creates relevant Intent elements and adds them to an SIML Document with a small talk dialog.
The following code may vary in your case but should give you an idea as to how its done.
CSharp Code
var simlDocument = new XDocument(new XElement("Siml"));
var dialogElement = new XElement("Dialog");
dialogElement.Add(new XAttribute("Name","Greetings"));
dialogElement.Add(new XAttribute("IntentAlias","SmallTalk.Greetings"));
//Assuming there's a file with first line being question and second line being answer.
using (var reader = new StreamReader(new FileStream("somefile.txt", FileMode.Open)))
{
var question = reader.ReadLine();
var answer = reader.ReadLine();
var intentElement = CreateIntentElement(question, answer);
dialogElement.Add(intentElement);
}
simlDocument.Root?.Add(dialogElement);
simlDocument.Save("SomeFile.siml");