Skip to content

Commit

Permalink
workaround: extract resource to temp file, pass the absolute path to …
Browse files Browse the repository at this point in the history
…opendial

fixes #88
  • Loading branch information
psibre committed Jun 8, 2016
1 parent 7b4cf2d commit d297242
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/main/java/OpenDialDemo.java
Expand Up @@ -4,14 +4,25 @@
import opendial.plugins.SphinxASR;
import opendial.readers.XMLDomainReader;
import opendial.Settings;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class OpenDialDemo {
public static void main (String[] args) {
public static void main (String[] args) throws IOException {
// creating the dialogue system
DialogueSystem system = new DialogueSystem();

// Extracting the dialogue domain
Domain domain = XMLDomainReader.extractDomain("Domain_Opendial_Ella.xml");
InputStream domainStream = OpenDialDemo.class.getClassLoader().getResourceAsStream("Domain_Opendial_Ella.xml");
List<String> domainLines = IOUtils.readLines(domainStream, "UTF-8");
File domainFile = File.createTempFile("domain", ".xml");
FileUtils.writeLines(domainFile, domainLines);
Domain domain = XMLDomainReader.extractDomain(domainFile.getCanonicalPath());
system.changeDomain(domain);

Settings setting = system.getSettings();
Expand Down

0 comments on commit d297242

Please sign in to comment.