use of com.sri.ai.praise.lang.translate.impl.UAI_to_HOGMv1_Using_Equalities_Translator in project aic-praise by aic-sri-international.
the class SGSolverDemoController method importUAIModel.
private void importUAIModel(ActionEvent ae) {
File uaiModelFile = uaiFileChooser.showOpenDialog(mainStage);
if (uaiModelFile != null) {
File uaiEvidenceFile = new File(uaiModelFile.getParent(), uaiModelFile.getName() + ".evid");
StringWriter hogmWriter = new StringWriter();
try (BufferedReader uaiModelReader = new BufferedReader(new FileReader(uaiModelFile));
BufferedReader uaiEvidenceReader = new BufferedReader(new FileReader(uaiEvidenceFile));
PrintWriter hogmPrintWriter = new PrintWriter(hogmWriter)) {
UAI_to_HOGMv1_Using_Equalities_Translator translator = new UAI_to_HOGMv1_Using_Equalities_Translator();
translator.translate(uaiModelFile.getName(), new Reader[] { uaiModelReader, uaiEvidenceReader }, new PrintWriter[] { hogmPrintWriter }, new TranslatorOptions());
String hogmModel = hogmWriter.toString();
// For convenience, pull out all possible queries
HOGMParserWrapper parser = new HOGMParserWrapper();
ParsedHOGModel parsedModel = parser.parseModel(hogmModel);
FactorsAndTypes factorsAndTypes = new ExpressionFactorsAndTypes(parsedModel);
List<String> queries = new ArrayList<>(factorsAndTypes.getMapFromRandomVariableNameToTypeName().keySet());
newModel(hogmModel, queries);
} catch (Throwable th) {
FXUtil.exception(th);
}
}
}
Aggregations