Commit 0702b19e authored by Ludan Stoecklé's avatar Ludan Stoecklé

1.5.5

parent 7d80b030
......@@ -19,7 +19,7 @@ stages:
# variables etc.
variables:
ROSAENLG_VERSION: 1.5.4
ROSAENLG_VERSION: 1.5.5
DOCKER_REGISTRY: registry.gitlab.com/rosaenlg-projects/rosaenlg
DOCKER_CLI_ROOT: ${DOCKER_REGISTRY}/cli
DOCKER_SERVER_ROOT: ${DOCKER_REGISTRY}/server
......
{
"name": "browser-ide-demo",
"version": "1.5.4",
"version": "1.5.5",
"description": "Client side demo of NLG templates compilation and rendering using RosaeNLG",
"main": "index.js",
"scripts": {
......@@ -34,7 +34,7 @@
"gulp-inject-string": "^1.1.2",
"gulp-rename": "^1.4.0",
"merge-stream": "^2.0.0",
"rosaenlg": "1.5.4",
"rosaenlg": "1.5.5",
"tinyify": "^2.5.2",
"vue-codemirror": "^4.0.6"
}
......
......@@ -64,7 +64,7 @@ mixin phone_chunks
| #[+display]
if !hasSaid('BATTERY')
| #{''} along with a battery of #[+value(phone.battery)] mAh
| along with a battery of #[+value(phone.battery)] mAh
recordSaid('BATTERY')
item
if !hasSaid('BATTERY')
......
......@@ -84,7 +84,6 @@ mixin phone_chunks
mixin phone_ref(obj, params)
if !hasFlag(params,'NO_DET')
| le
|
| §#{phone.name}§
- setRefGender(phone, 'M')
......
{
"name": "content-deduplicate",
"version": "0.0.2",
"version": "0.0.3",
"description": "Calculates distances between texts to prevent duplicate content",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -54,6 +54,6 @@
},
"dependencies": {
"k-medoids": "^1.0.6",
"synonym-optimizer": "2.5.4"
"synonym-optimizer": "2.5.5"
}
}
{
"name": "english-determiners",
"version": "2.5.4",
"version": "2.5.5",
"description": "English determiners",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "french-adjectives",
"version": "2.5.4",
"version": "2.5.5",
"description": "Agreement of adjectives in French",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -45,7 +45,7 @@
},
"dependencies": {
"debug": "^4.1.1",
"french-h-muet-aspire": "2.5.4"
"french-h-muet-aspire": "2.5.5"
},
"keywords": [
"french",
......
{
"name": "french-determiners",
"version": "2.5.4",
"version": "2.5.5",
"description": "French determiners",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "french-h-muet-aspire",
"version": "2.5.4",
"version": "2.5.5",
"description": "List of French words that are \"aspiré\" (vs. \"muet\")\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[Dstarting with a h that is \"aspiré\" vs \"muet\"",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "french-ordinals",
"version": "2.5.4",
"version": "2.5.5",
"description": "Ordinal numbers in French: 12 => douzième",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "french-verbs",
"version": "2.5.4",
"version": "2.5.5",
"description": "French verbs: conjugation, based on the Lefff contents, and list of transitive and intransitive verbs",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -50,7 +50,7 @@
},
"dependencies": {
"debug": "^4.1.1",
"french-h-muet-aspire": "2.5.4"
"french-h-muet-aspire": "2.5.5"
},
"devDependencies": {
"copyfiles": "^2.1.1",
......
{
"name": "french-words-gender",
"version": "2.5.4",
"version": "2.5.5",
"description": "Gender of French words, based on the Lefff",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "german-adjectives",
"version": "2.5.4",
"version": "2.5.5",
"description": "German adjectives, based on german-pos-dict",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "german-determiners",
"version": "2.5.4",
"version": "2.5.5",
"description": "German determiners",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "german-dict-helper",
"version": "2.5.4",
"version": "2.5.5",
"description": "Helper functions on an included database derived from german-pos-dict",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "german-ordinals",
"version": "2.5.4",
"version": "2.5.5",
"description": "Ordinal numbers in German: 12 => zwölfte",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "german-verbs",
"version": "2.5.4",
"version": "2.5.5",
"description": "German verbs, based on german-pos-dict",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "german-words",
"version": "2.5.4",
"version": "2.5.5",
"description": "Gender and case of German words, based on german-pos-dict",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "gulp-rosaenlg",
"version": "2.5.4",
"version": "2.5.5",
"description": "RosaeNLG client side packaging helper",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -60,6 +60,6 @@
"browserify": "^16.5.0",
"debug": "^4.1.1",
"minify-stream": "^1.2.1",
"rosaenlg": "1.5.4"
"rosaenlg": "1.5.5"
}
}
{
"name": "italian-adjectives",
"version": "2.5.4",
"version": "2.5.5",
"description": "Italian adjectives, based on morph-it",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -58,6 +58,6 @@
"license": "MIT",
"dependencies": {
"debug": "^4.1.1",
"rosaenlg-filter": "2.5.4"
"rosaenlg-filter": "2.5.5"
}
}
{
"name": "italian-determiners",
"version": "2.5.4",
"version": "2.5.5",
"description": "Italian determiners",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "italian-ordinals-cardinals",
"version": "2.5.4",
"version": "2.5.5",
"description": "Ordinal and cardinal numbers in Italian",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "italian-verbs",
"version": "2.5.4",
"version": "2.5.5",
"description": "Italian verbs, based on morph-it",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "italian-words",
"version": "2.5.4",
"version": "2.5.5",
"description": "Gender and plural of Italian words, based on morph-it",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "lefff-helper",
"version": "2.5.4",
"version": "2.5.5",
"description": "Helper functions on an included database derived from Lefff",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "morph-it-helper",
"version": "2.5.4",
"version": "2.5.5",
"description": "Helper functions on an included database derived from morph-it (Free Morphological Lexicon for the Italian Language)",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "rosaenlg-cli",
"version": "1.5.4",
"version": "1.5.5",
"description": "RosaeNLG's CLI interface",
"bin": {
"rosaenlg": "./index.js",
......@@ -10,9 +10,9 @@
"dependencies": {
"chalk": "^3.0.0",
"commander": "^4.0.1",
"gulp-rosaenlg": "2.5.4",
"gulp-rosaenlg": "2.5.5",
"mkdirp": "^0.5.1",
"rosaenlg": "1.5.4"
"rosaenlg": "1.5.5"
},
"devDependencies": {
"mocha": "^6.2.2",
......
......@@ -34,7 +34,8 @@ export function cleanStruct(input: string /*, lang: string*/): string {
export function cleanStructAfterUnprotect(input: string /*, lang: string*/): string {
let res: string = input;
res = res.replace('<p>.</p>', '');
const emptyParas = new RegExp(`<p>\\.</p>`, 'g');
res = res.replace(emptyParas, '');
return res;
}
{
"name": "rosaenlg-filter",
"version": "2.5.4",
"version": "2.5.5",
"description": "Filtering feature of RosaeNLG",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -43,7 +43,7 @@
"better-title-case": "^1.0.1",
"compromise": "^11.14.3",
"debug": "^4.1.1",
"french-h-muet-aspire": "2.5.4",
"french-h-muet-aspire": "2.5.5",
"titlecase-french": "^1.0.1"
},
"keywords": [
......
......@@ -227,6 +227,7 @@ const testCasesList = [
// résidu d'assembly
['<p>.</p>', ''],
['<p>.</p><p> . </p><p>.</p>', ''],
['</p>.</p>', '</p></p>'],
['</p> . </p>', '</p></p>'],
['bla bla. </p>', 'Bla bla.</p>'],
......
{
"name": "rosaenlg-node-server",
"version": "1.5.4",
"version": "1.5.5",
"description": "Server for RosaeNLG, written in node.js",
"main": "dist/app.js",
"bin": {
......@@ -71,7 +71,7 @@
"eslint-config-prettier": "^6.5.0",
"eslint-plugin-prettier": "^3.1.1",
"gulp": "^4.0.2",
"gulp-rosaenlg": "2.5.4",
"gulp-rosaenlg": "2.5.5",
"json-refs": "^3.0.13",
"mocha": "^6.2.2",
"nyc": "^14.1.1",
......@@ -79,10 +79,14 @@
"typescript": "^3.7.2"
},
"dependencies": {
"@types/node-cache": "^4.2.5",
"@types/sha1": "^1.1.2",
"@types/swagger-ui-express": "^4.1.0",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"rosaenlg": "1.5.4",
"node-cache": "5.0.2",
"rosaenlg": "1.5.5",
"sha1": "^1.1.1",
"swagger-ui-express": "^4.1.2"
}
}
{
"template": {
"entryTemplate": "chanson.pug",
"compileInfo": {
"activate": false,
"compileDebug": false,
"language": "fr_FR"
},
"templates": {
"chanson.pug": "p\n | il #[+verb(getAnonMS(), {verb: 'chanter', tense:'FUTUR'} )]\n | \"#{chanson.nom}\"\n | de #{chanson.auteur}\n"
}
},
"data": {
"language": "fr_FR",
"chanson": {
"auteur": "Édith Piaf",
"nom": "Non, je ne regrette rien"
}
}
}
\ No newline at end of file
{
"templateId": "chanson",
"renderedText": "<p>Il chantera \"Non, je ne regrette rien\" d'Édith Piaf</p>",
"counter": 0,
"renderOptions": {
"language": "fr_FR"
}
......
{
"status": "CREATED",
"renderedText": "<p>Il chantera \"Non, je ne regrette rien\" d'Édith Piaf</p>",
"renderOptions": {
"language": "fr_FR"
}
}
\ No newline at end of file
......@@ -24,6 +24,11 @@
}
],
"components": {
"schemas": {
"JSONPackageSchema": {
"$ref": "./src/swagger/jsonPackage.schema.json"
}
},
"parameters": {
"templateIdInPath": {
"name": "templateId",
......@@ -79,7 +84,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "./src/swagger/jsonPackage.schema.json"
"$ref": "#/components/schemas/JSONPackageSchema"
},
"example": {
"$ref": "./src/swagger/chanson.json"
......@@ -102,6 +107,7 @@
},
"status": {
"type": "string",
"description": "indicates if the template was created, or if it existed before and was updated",
"enum": [
"CREATED",
"UPDATED"
......@@ -170,7 +176,7 @@
},
"/templates/{templateId}/render": {
"post": {
"summary": "Renders a template using data.",
"summary": "Renders an existing template using data.",
"description": "Renders a previously loaded template using data passed in the request.",
"parameters": [
{
......@@ -204,10 +210,6 @@
"type": "string",
"description": "the rendered text (this is the interesting part)"
},
"counter": {
"type": "integer",
"description": "counting the number of times this template was rendered (not persistent)"
},
"renderOptions": {
"$ref": "./src/swagger/renderOptions.schema.json"
}
......@@ -225,6 +227,69 @@
}
}
},
"/templates/render": {
"post": {
"summary": "Renders a template in the request using data also in the request.",
"description": "Both template and data are passed in the request. Template is automatically cached for a while to accelerate the next calls.",
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"template": {
"$ref": "#/components/schemas/JSONPackageSchema"
},
"data": {
"description": "data to render the template",
"type": "object"
}
},
"required": [ "template", "data"]
},
"example": {
"$ref": "./src/swagger/chansonInput_directRender.json"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "rendering went well",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": {
"type": "string",
"description": "indicates if the template was created, or if it existed before and cached version could be used",
"enum": [
"CREATED",
"EXISTED"
]
},
"renderedText": {
"type": "string",
"description": "the rendered text (this is the interesting part)"
},
"renderOptions": {
"$ref": "./src/swagger/renderOptions.schema.json"
}
}
},
"example": {
"$ref": "./src/swagger/chansonOutput_directRender.json"
}
}
}
},
"500": {
"description": "missing template data, or missing data, or issue during template compilation, or issue during template rendering"
}
}
}
},
"/templates/{templateId}/reload": {
"get": {
"summary": "Reloads a specific template from the disk.",
......
......@@ -2,12 +2,22 @@ import * as express from 'express';
import { RosaeContext } from './RosaeContext';
import * as fs from 'fs';
import { RenderedBundle } from './RenderedBundle';
import sha1 = require('sha1');
import NodeCache = require('node-cache');
export default class TemplatesController {
public path = '/templates';
private rosaeContexts = new Map<string, RosaeContext>();
private renderCounter = 0;
CACHE_STDTTL = 600; // 10 minutes
CACHE_CHECKPERIOD = 60; // 1 minute
private rosaeContextsTempCache = new NodeCache({
stdTTL: this.CACHE_STDTTL,
checkperiod: this.CACHE_CHECKPERIOD,
useClones: false,
deleteOnExpire: true,
});
public templatesPath: string | undefined;
// eslint-disable-next-line new-cap
......@@ -31,6 +41,7 @@ export default class TemplatesController {
this.router.post(this.path, this.createTemplate).put(this.path, this.createTemplate);
this.router.post(`${this.path}/render`, this.directRender);
this.router.post(`${this.path}/:templateId/render`, this.renderTemplate);
this.router.delete(`${this.path}/:templateId`, this.deleteTemplate);
......@@ -170,6 +181,51 @@ export default class TemplatesController {
}
};
directRender = (request: express.Request, response: express.Response): void => {
console.info(`direct rendering of a template...`);
const requestContent = request.body;