All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.rosaenlg.lib.JsonPackageSrc Maven / Gradle / Ivy

Go to download

Java wrapper around RosaeNLG (JavaScript Natural Language Generation library), using GraalVM

There is a newer version: 3.2.2
Show newest version
package org.rosaenlg.lib;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/*-
 * #%L
 * RosaeNLG for Java
 * %%
 * Copyright (C) 2019 RosaeNLG.org, Ludan Stoecklé
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import org.json.JSONObject;

/**
 * Will contain a deserialized JSON package of a template, "src" part.
 * 

* To generate a JSON package from plain templates using gulp, see RosaeNLG Packager *

* * @author Ludan Stoecklé [email protected] */ public class JsonPackageSrc { private String entryTemplate; private CompileInfo compileInfo; private Map templates = new HashMap<>(); private Autotest autotest; /** Constructor using a JSON object. * * @param src the JSON object containing the src part of the JSON package */ public JsonPackageSrc(JSONObject src) { this.entryTemplate = src.getString("entryTemplate"); JSONObject compileInfoJson = src.getJSONObject("compileInfo"); this.compileInfo = new CompileInfo(compileInfoJson); JSONObject templatesJson = src.getJSONObject("templates"); Iterator keys = templatesJson.keys(); while (keys.hasNext()) { String key = keys.next(); templates.put(key, templatesJson.getString(key)); } if (src.has("autotest")) { this.autotest = new Autotest(src.getJSONObject("autotest")); } } /** Returns the entry template. * *

The entry template is the one that is indicated when compiling, and which can include other * templates (in the same JSON package). *

* * @return String the name of the entry template */ public String getEntryTemplate() { return this.entryTemplate; } /** Getter on the compile options. * @return CompileInfo */ public CompileInfo getCompileInfo() { return this.compileInfo; } /** Getter on the template content. * *

* Key value where the key is the template name, and the value the content of the template. *

* * @return template name and template content map */ public Map getTemplates() { return this.templates; } /** Getter on the auto test part of the package. * @return Autotest the auto test, if exists */ public Autotest getAutotest() { return this.autotest; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy