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

org.rosaenlg.lib.Cli 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;

/*-
 * #%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;

/**
 * Command line, for development and tests purposes only.
 *
 * @author Ludan Stoecklé [email protected]
 */
public class Cli {

  /**
   * Self test, no params.
   * 

* Renders a simple included template in French. Should print Il chantera * "Non, je ne regrette rien" d'Édith Piaf *

* * @param args not used as of today * @throws Exception if a problem occurs */ public static void main(String[] args) throws Exception { String template = "p\n" + " | il #[+verb(getAnonMS(), {verb: 'chanter', tense:'FUTUR'} )]\n" + " | \"#{chanson.nom}\"\n" + " | de #{chanson.auteur}\n"; CompileInfo compileInfo = new CompileInfo(); compileInfo.setLanguage("fr_FR"); final RosaeContext rosaeContext = new RosaeContext(template, compileInfo); JSONObject opts = new JSONObject(); opts.put("language", "fr_FR"); JSONObject chanson = new JSONObject(); chanson.put("nom", "Non, je ne regrette rien"); chanson.put("auteur", "Édith Piaf"); opts.put("chanson", chanson); String rendered = rosaeContext.render(opts.toString()).getRenderedText(); System.out.println(rendered); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy