@@ -0,0 +1,2186 @@
+package com.sri.ai.praise.model.export;%0D%0A%0D%0Aimport java.io.IOException;%0D%0Aimport java.nio.file.Files;%0D%0Aimport java.nio.file.Paths;%0D%0Aimport java.util.Collections;%0D%0Aimport java.util.LinkedHashMap;%0D%0Aimport java.util.Map;%0D%0Aimport java.util.StringJoiner;%0D%0Aimport java.util.stream.Stream;%0D%0A%0D%0Aimport com.sri.ai.expresso.api.Expression;%0D%0Aimport com.sri.ai.expresso.api.Parser;%0D%0Aimport com.sri.ai.expresso.helper.Expressions;%0D%0Aimport com.sri.ai.grinder.api.RewritingProcess;%0D%0Aimport com.sri.ai.grinder.parser.antlr.AntlrGrinderParserWrapper;%0D%0Aimport com.sri.ai.praise.lbp.LBPFactory;%0D%0Aimport com.sri.ai.praise.model.Model;%0D%0A%0D%0A/**%0D%0A * Exports an LBP Model, which is grounded first, to %3Ca href=%22http://www.hugin.com/%22%3EHugin's%3C/a%3E%0D%0A * Bayesian Network %3Ca href=%22http://download.hugin.com/webdocs/manuals/api-manual.pdf%22%3E.net%3C/a%3E format.%0D%0A * %0D%0A * @author oreilly%0D%0A *%0D%0A */%0D%0Apublic class ExportToHuginDotNetBayesianNetworkFormat %7B%0D%0A%09public static void main(String%5B%5D args) throws IOException %7B%0D%0A%09%09if (args.length %3C 1 %7C%7C args.length %25 2 != 1) %7B%0D%0A%09%09%09throw new IllegalArgumentException(%22Invalid # of arguments, must be 1=model file and the optional 2 to n pairs of sort name followed by size to use when grounding the model%22);%0D%0A%09%09%7D%0D%0A%09%09%0D%0A%09%09Parser parser = new AntlrGrinderParserWrapper();%0D%0A%09%09// Read in the model declaration%0D%0A%09%09StringJoiner modelDeclarationSJ = new StringJoiner(%22%5Cn%22);%0D%0A%09%09try (Stream%3CString%3E declarationLines = Files.lines(Paths.get(args%5B0%5D))) %7B%0D%0A%09%09%09declarationLines.sequential().forEachOrdered(line -%3E modelDeclarationSJ.add(line));%0D%0A%09%09%7D%0D%0A%09%09// Can be called with explicitly assigned sizes to the sorts associated with the model%0D%0A%09%09Map%3CExpression, Expression%3E globalObjects = new LinkedHashMap%3CExpression, Expression%3E();%0D%0A%09%09for (int i = 1; i %3C args.length; i+=2) %7B%0D%0A%09%09%09globalObjects.put(parser.parse(%22%7C %22+args%5Bi%5D+%22 %7C%22), Expressions.makeSymbol(Integer.valueOf(args%5Bi+1%5D)));%0D%0A%09%09%7D%0D%0A%09%09%0D%0A%09%09Expression modelDefinition = parser.parse(modelDeclarationSJ.toString());%0D%0A%09%09Model      modelToExport   = new Model(modelDefinition, Collections.emptySet());%0D%0A%09%09%0D%0A%09%09RewritingProcess process = LBPFactory.newLBPProcess(modelDefinition);%0D%0A%09%09process.getGlobalObjects().putAll(globalObjects);%0D%0A%09%09%0D%0A%09%09%0D%0A%09%7D%0D%0A%09%0D%0A%7D%0D%0A

Add initial code for exporting to hugin .net bayesian network format.