IranCahtBot
V.I.P
Posts: 27
Joined: Sat Feb 25, 2017 7:36 pm

the SIML Modern files

Tue Oct 03, 2017 3:00 am

Hello Dear Leslie,
I want to use Oscova smalltalk. For this purpose, I want to convert the text files containing the question and answer to the SIML Modern files.
Is there any software that can convert text files to the SIML Modern files?
Thank you in advance for any help you can provide.
Best regards
Ebrahimi

User avatar
Leslie
Lead Software Architect
Posts: 353
Joined: Fri Sep 14, 2012 12:20 pm
Contact: Website

Re: the SIML Modern files

Tue Oct 03, 2017 3:24 pm

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");

IranCahtBot
V.I.P
Posts: 27
Joined: Sat Feb 25, 2017 7:36 pm

Re: the SIML Modern files

Tue Oct 03, 2017 5:04 pm

Hello Dear Leslie,

Thank you very much for your help and prompt response.

Best regards
Ebrahimi

Return to “Feature Request and Suggestions”

Who is online

Users browsing this forum: No registered users and 1 guest