Search in sources :

Example 1 with HOGMv1_to_UAI_Translator

use of com.sri.ai.praise.core.representation.translation.ciaranframework.core.uai.HOGMv1_to_UAI_Translator in project aic-praise by aic-sri-international.

the class PRAiSEController method exportUAIModel.

private void exportUAIModel(ActionEvent ae) {
    try {
        callCurrentModelPageEditor(modelPage -> {
            File uaiModelFile = uaiFileChooser.showSaveDialog(mainStage);
            if (uaiModelFile != null) {
                if (!uaiModelFile.getName().endsWith(ModelLanguage.UAI.getDefaultFileExtension())) {
                    uaiModelFile = new File(uaiModelFile.getParent(), uaiModelFile.getName() + ModelLanguage.UAI.getDefaultFileExtension());
                }
                File uaiEvidenceFile = new File(uaiModelFile.getParent(), uaiModelFile.getName() + ModelLanguage.UAI.getDefaultFileExtension() + ".evid");
                try (PrintWriter uaiModelWriter = new PrintWriter(uaiModelFile);
                    PrintWriter uaiEvidenceWriter = new PrintWriter(uaiEvidenceFile)) {
                    HOGMv1_to_UAI_Translator translator = new HOGMv1_to_UAI_Translator();
                    translator.translate(uaiModelFile.getName(), new Reader[] { new StringReader(modelPage.getCurrentPageContents()) }, new PrintWriter[] { uaiModelWriter, uaiEvidenceWriter }, new TranslatorOptions());
                } catch (Throwable th) {
                    FXUtil.exception(th);
                }
            }
        });
    } catch (Throwable th) {
        FXUtil.exception(th);
    }
}
Also used : HOGMv1_to_UAI_Translator(com.sri.ai.praise.core.representation.translation.ciaranframework.core.uai.HOGMv1_to_UAI_Translator) StringReader(java.io.StringReader) TranslatorOptions(com.sri.ai.praise.core.representation.translation.ciaranframework.api.TranslatorOptions) File(java.io.File) PrintWriter(java.io.PrintWriter)

Aggregations

TranslatorOptions (com.sri.ai.praise.core.representation.translation.ciaranframework.api.TranslatorOptions)1 HOGMv1_to_UAI_Translator (com.sri.ai.praise.core.representation.translation.ciaranframework.core.uai.HOGMv1_to_UAI_Translator)1 File (java.io.File)1 PrintWriter (java.io.PrintWriter)1 StringReader (java.io.StringReader)1