Search in sources :

Example 1 with ModelLanguage

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

the class PRAiSECommandLineOptions method getLanguageFromInputFilesWithDefaultPRAiSEFileExtension.

private ModelLanguage getLanguageFromInputFilesWithDefaultPRAiSEFileExtension() {
    ModelLanguage result;
    result = inputFiles.stream().filter(fileHasPRAiSEFileDefaultExtension).map(fromPRAiSEFileToLanguage).findFirst().orElse(null);
    return result;
}
Also used : ModelLanguage(com.sri.ai.praise.core.representation.interfacebased.factor.api.ModelLanguage)

Example 2 with ModelLanguage

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

the class PRAiSECommandLineOptions method findLanguageModel.

private static ModelLanguage findLanguageModel(String languageCode) {
    List<ModelLanguage> modelLanguages = Arrays.asList(ModelLanguage.values());
    ModelLanguage result = getFirstSatisfyingPredicateOrNull(modelLanguages, hasLanguageCode(languageCode));
    return result;
}
Also used : ModelLanguage(com.sri.ai.praise.core.representation.interfacebased.factor.api.ModelLanguage)

Example 3 with ModelLanguage

use of com.sri.ai.praise.core.representation.interfacebased.factor.api.ModelLanguage 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 ModelLanguage

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

the class TranslatorFactory method newTranslator.

/**
 * Instantiate a new Translator based on the given source->target mapping.
 * @param source
 *        the source modeling language to translate from.
 * @param target
 *        the target modeling language to translate to.
 * @return a new Translator instance capable of translating source->target
 * @throws RuntimeException if unable to instantiate a translator for the given source and target.
 */
public static Translator newTranslator(ModelLanguage source, ModelLanguage target) {
    Translator result = null;
    Class<?> translatorClass = _translators.get(new Pair<ModelLanguage, ModelLanguage>(source, target));
    try {
        result = (Translator) translatorClass.newInstance();
    } catch (Exception ex) {
        throw new RuntimeException("Unable to create a new translator for " + source + "->" + target, ex);
    }
    return result;
}
Also used : UAI_to_HuginDotNet_Translator(com.sri.ai.praise.core.representation.translation.ciaranframework.core.hugin.UAI_to_HuginDotNet_Translator) HOGMv1_to_UAI_Translator(com.sri.ai.praise.core.representation.translation.ciaranframework.core.uai.HOGMv1_to_UAI_Translator) UAI_to_HOGMv1_Using_Inequalities_Translator(com.sri.ai.praise.core.representation.translation.ciaranframework.core.uai.UAI_to_HOGMv1_Using_Inequalities_Translator) Translator(com.sri.ai.praise.core.representation.translation.ciaranframework.api.Translator) ModelLanguage(com.sri.ai.praise.core.representation.interfacebased.factor.api.ModelLanguage)

Example 5 with ModelLanguage

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

the class PRAiSECommandLineOptions method getLanguageMatchingExtensionOfSomeInputFile.

private ModelLanguage getLanguageMatchingExtensionOfSomeInputFile() {
    List<ModelLanguage> modelLanguages = Arrays.asList(ModelLanguage.values());
    ModelLanguage result = getFirstSatisfyingPredicateOrNull(modelLanguages, isExtensionForSomeOfTheInputFiles());
    return result;
}
Also used : ModelLanguage(com.sri.ai.praise.core.representation.interfacebased.factor.api.ModelLanguage)

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