Search in sources :

Example 1 with ModelPage

use of com.sri.ai.praise.core.representation.classbased.modelscontainer.ModelPage in project aic-praise by aic-sri-international.

the class PRAiSECommandLineOptions method makeModelPageFromNonContainerFiles.

private ModelPage makeModelPageFromNonContainerFiles(List<File> nonContainerFiles) {
    String unionModel = nonContainerFiles.stream().map(file -> Util.getFileContent(file)).collect(joining("\n"));
    ModelPage modelPage = makeModelPage(unionModel);
    return modelPage;
}
Also used : Arrays(java.util.Arrays) PagedModelContainer.getModelPagesFromURI(com.sri.ai.praise.core.representation.classbased.modelscontainer.PagedModelContainer.getModelPagesFromURI) Function(java.util.function.Function) Util.getFirstSatisfyingPredicateOrNull(com.sri.ai.util.Util.getFirstSatisfyingPredicateOrNull) ArrayList(java.util.ArrayList) ModelLanguage(com.sri.ai.praise.core.representation.interfacebased.factor.api.ModelLanguage) Charset(java.nio.charset.Charset) OptionException(joptsimple.OptionException) PagedModelContainer(com.sri.ai.praise.core.representation.classbased.modelscontainer.PagedModelContainer) OptionParser(joptsimple.OptionParser) Util.thereExists(com.sri.ai.util.Util.thereExists) PRAiSESolver(com.sri.ai.praise.core.inference.externalprocesssolver.core.praise.PRAiSESolver) OptionSet(joptsimple.OptionSet) PrintStream(java.io.PrintStream) OptionSpec(joptsimple.OptionSpec) Charsets(com.google.common.base.Charsets) Util.join(com.sri.ai.util.Util.join) IOException(java.io.IOException) Util.mapIntoList(com.sri.ai.util.Util.mapIntoList) Collectors.joining(java.util.stream.Collectors.joining) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) Util.collect(com.sri.ai.util.Util.collect) Beta(com.google.common.annotations.Beta) Util.getFirstNonNullResultOrNull(com.sri.ai.util.Util.getFirstNonNullResultOrNull) List(java.util.List) Predicate(com.google.common.base.Predicate) Util(com.sri.ai.util.Util) ModelPage(com.sri.ai.praise.core.representation.classbased.modelscontainer.ModelPage) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ModelPage(com.sri.ai.praise.core.representation.classbased.modelscontainer.ModelPage)

Example 2 with ModelPage

use of com.sri.ai.praise.core.representation.classbased.modelscontainer.ModelPage in project aic-praise by aic-sri-international.

the class PRAiSECommandLineOptions method collectModelPageFromNonContainerFilesIfAny.

private void collectModelPageFromNonContainerFilesIfAny() {
    if (nonContainerFiles.size() > 0) {
        ModelPage modelPage = makeModelPageFromNonContainerFiles(nonContainerFiles);
        modelPages.add(modelPage);
    }
}
Also used : ModelPage(com.sri.ai.praise.core.representation.classbased.modelscontainer.ModelPage)

Example 3 with ModelPage

use of com.sri.ai.praise.core.representation.classbased.modelscontainer.ModelPage in project aic-praise by aic-sri-international.

the class PRAiSECommandLineOptions method getLanguageFromPRAiSEFile.

private static ModelLanguage getLanguageFromPRAiSEFile(File praiseFile) {
    List<ModelPage> modelPages = getModelPagesFromURI(praiseFile.toURI());
    ModelLanguage modelLanguage = Util.getFirstNonNullResultOrNull(modelPages, m -> m.getLanguage());
    return modelLanguage;
}
Also used : ModelPage(com.sri.ai.praise.core.representation.classbased.modelscontainer.ModelPage) ModelLanguage(com.sri.ai.praise.core.representation.interfacebased.factor.api.ModelLanguage)

Example 4 with ModelPage

use of com.sri.ai.praise.core.representation.classbased.modelscontainer.ModelPage in project aic-praise by aic-sri-international.

the class Evaluation method makeBurnInProblem.

private Problem makeBurnInProblem() {
    ModelPage burnInModel = evaluationConfiguration.getModelsContainer().getPages().get(0);
    String burnInQuery = burnInModel.getDefaultQueriesToRun().get(0);
    Problem problem = new Problem(evaluationConfiguration.getProblemType(), burnInQuery, burnInModel);
    return problem;
}
Also used : ModelPage(com.sri.ai.praise.core.representation.classbased.modelscontainer.ModelPage)

Example 5 with ModelPage

use of com.sri.ai.praise.core.representation.classbased.modelscontainer.ModelPage in project aic-praise by aic-sri-international.

the class AbstractPerspective method newModel.

@Override
public void newModel(ExamplePages examples) {
    newModel(() -> {
        List<ModelPage> pages = examples.getPages();
        Map<Integer, Supplier<ModelPageEditor>> newModelPageIdxs = new HashMap<>();
        for (int i = 0; i < pages.size(); i++) {
            ModelPage page = pages.get(i);
            newModelPageIdxs.put(i, new ModelPageEditorSupplier(page.getModelString(), page.getDefaultQueriesToRun()));
        }
        return FXCollections.observableMap(newModelPageIdxs);
    });
    modelFile.set(null);
}
Also used : ModelPage(com.sri.ai.praise.core.representation.classbased.modelscontainer.ModelPage) HashMap(java.util.HashMap) Supplier(java.util.function.Supplier)

Aggregations

ModelPage (com.sri.ai.praise.core.representation.classbased.modelscontainer.ModelPage)5 ModelLanguage (com.sri.ai.praise.core.representation.interfacebased.factor.api.ModelLanguage)2 Beta (com.google.common.annotations.Beta)1 Charsets (com.google.common.base.Charsets)1 Predicate (com.google.common.base.Predicate)1 PRAiSESolver (com.sri.ai.praise.core.inference.externalprocesssolver.core.praise.PRAiSESolver)1 PagedModelContainer (com.sri.ai.praise.core.representation.classbased.modelscontainer.PagedModelContainer)1 PagedModelContainer.getModelPagesFromURI (com.sri.ai.praise.core.representation.classbased.modelscontainer.PagedModelContainer.getModelPagesFromURI)1 Util (com.sri.ai.util.Util)1 Util.collect (com.sri.ai.util.Util.collect)1 Util.getFirstNonNullResultOrNull (com.sri.ai.util.Util.getFirstNonNullResultOrNull)1 Util.getFirstSatisfyingPredicateOrNull (com.sri.ai.util.Util.getFirstSatisfyingPredicateOrNull)1 Util.join (com.sri.ai.util.Util.join)1 Util.mapIntoList (com.sri.ai.util.Util.mapIntoList)1 Util.thereExists (com.sri.ai.util.Util.thereExists)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1