Search in sources :

Example 6 with ModelLanguage

use of com.sri.ai.praise.core.representation.interfacebased.factor.api.ModelLanguage in project aic-praise by aic-sri-international.

the class PagedModelContainer method getModelPagesFromURI.

public static List<ModelPage> getModelPagesFromURI(URI uri) {
    try {
        List<ModelPage> result = new ArrayList<>();
        AtomicReference<ModelLanguage> containerModelLanguage = new AtomicReference<>();
        List<String> modelSpecifications = new ArrayList<>();
        Map<String, List<String>> fragments = new HashMap<>();
        try (BufferedReader in = new BufferedReader(new InputStreamReader(uri.toURL().openStream(), FILE_CHARSET))) {
            getContent(containerModelLanguage, in.lines(), modelSpecifications, fragments);
        }
        for (String modelSpecification : modelSpecifications) {
            String name = extractField(MODEL_FIELD_NAME, modelSpecification);
            String model = extractModel(MODEL_FIELD_PARTS, modelSpecification, fragments);
            List<String> queries = extractQueries(MODEL_FIELD_QUERIES, modelSpecification, fragments);
            result.add(new ModelPage(containerModelLanguage.get(), name, model, queries));
        }
        return result;
    } catch (IOException ioe) {
        throw new Error(ioe);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AtomicReference(java.util.concurrent.atomic.AtomicReference) ModelLanguage(com.sri.ai.praise.core.representation.interfacebased.factor.api.ModelLanguage) IOException(java.io.IOException) BufferedReader(java.io.BufferedReader) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ModelLanguage (com.sri.ai.praise.core.representation.interfacebased.factor.api.ModelLanguage)6 ModelPage (com.sri.ai.praise.core.representation.classbased.modelscontainer.ModelPage)1 Translator (com.sri.ai.praise.core.representation.translation.ciaranframework.api.Translator)1 UAI_to_HuginDotNet_Translator (com.sri.ai.praise.core.representation.translation.ciaranframework.core.hugin.UAI_to_HuginDotNet_Translator)1 HOGMv1_to_UAI_Translator (com.sri.ai.praise.core.representation.translation.ciaranframework.core.uai.HOGMv1_to_UAI_Translator)1 UAI_to_HOGMv1_Using_Inequalities_Translator (com.sri.ai.praise.core.representation.translation.ciaranframework.core.uai.UAI_to_HOGMv1_Using_Inequalities_Translator)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1