Commit 39b9768d authored by Ludan Stoecklé's avatar Ludan Stoecklé

1.5.8

parent d3271d6b
......@@ -19,7 +19,7 @@ stages:
# variables etc.
variables:
ROSAENLG_VERSION: 1.5.7
ROSAENLG_VERSION: 1.5.8
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.7",
"version": "1.5.8",
"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.7",
"rosaenlg": "1.5.8",
"tinyify": "^2.5.2",
"vue-codemirror": "^4.0.6"
}
......
{
"name": "content-deduplicate",
"version": "0.0.5",
"version": "0.0.6",
"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.7"
"synonym-optimizer": "2.5.8"
}
}
{
"name": "english-determiners",
"version": "2.5.7",
"version": "2.5.8",
"description": "English determiners",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "french-adjectives",
"version": "2.5.7",
"version": "2.5.8",
"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.7"
"french-h-muet-aspire": "2.5.8"
},
"keywords": [
"french",
......
{
"name": "french-determiners",
"version": "2.5.7",
"version": "2.5.8",
"description": "French determiners",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "french-h-muet-aspire",
"version": "2.5.7",
"version": "2.5.8",
"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.7",
"version": "2.5.8",
"description": "Ordinal numbers in French: 12 => douzième",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "french-verbs",
"version": "2.5.7",
"version": "2.5.8",
"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.7"
"french-h-muet-aspire": "2.5.8"
},
"devDependencies": {
"copyfiles": "^2.1.1",
......
{
"name": "french-words-gender",
"version": "2.5.7",
"version": "2.5.8",
"description": "Gender of French words, based on the Lefff",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "german-adjectives",
"version": "2.5.7",
"version": "2.5.8",
"description": "German adjectives, based on german-pos-dict",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "german-determiners",
"version": "2.5.7",
"version": "2.5.8",
"description": "German determiners",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "german-dict-helper",
"version": "2.5.7",
"version": "2.5.8",
"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.7",
"version": "2.5.8",
"description": "Ordinal numbers in German: 12 => zwölfte",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "german-verbs",
"version": "2.5.7",
"version": "2.5.8",
"description": "German verbs, based on german-pos-dict",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "german-words",
"version": "2.5.7",
"version": "2.5.8",
"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.7",
"version": "2.5.8",
"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.7"
"rosaenlg": "1.5.8"
}
}
{
"name": "italian-adjectives",
"version": "2.5.7",
"version": "2.5.8",
"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.7"
"rosaenlg-filter": "2.5.8"
}
}
{
"name": "italian-determiners",
"version": "2.5.7",
"version": "2.5.8",
"description": "Italian determiners",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "italian-ordinals-cardinals",
"version": "2.5.7",
"version": "2.5.8",
"description": "Ordinal and cardinal numbers in Italian",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "italian-verbs",
"version": "2.5.7",
"version": "2.5.8",
"description": "Italian verbs, based on morph-it",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "italian-words",
"version": "2.5.7",
"version": "2.5.8",
"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.7",
"version": "2.5.8",
"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.7",
"version": "2.5.8",
"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.7",
"version": "1.5.8",
"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.7",
"gulp-rosaenlg": "2.5.8",
"mkdirp": "^0.5.1",
"rosaenlg": "1.5.7"
"rosaenlg": "1.5.8"
},
"devDependencies": {
"mocha": "^6.2.2",
......
{
"name": "rosaenlg-filter",
"version": "2.5.7",
"version": "2.5.8",
"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.7",
"french-h-muet-aspire": "2.5.8",
"titlecase-french": "^1.0.1"
},
"keywords": [
......
{
"name": "rosaenlg-node-server",
"version": "1.5.7",
"version": "1.5.8",
"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.7",
"gulp-rosaenlg": "2.5.8",
"json-refs": "^3.0.13",
"mocha": "^6.2.2",
"nyc": "^14.1.1",
......@@ -85,7 +85,7 @@
"body-parser": "^1.19.0",
"express": "^4.17.1",
"node-cache": "5.0.2",
"rosaenlg": "1.5.7",
"rosaenlg": "1.5.8",
"sha1": "^1.1.1",
"swagger-ui-express": "^4.1.2"
}
......
......@@ -94,7 +94,7 @@
"required": true
},
"responses": {
"200": {
"201": {
"description": "template was properly loaded and is available for rendering",
"content": {
"application/json": {
......@@ -121,8 +121,11 @@
}
}
},
"400": {
"description": "template could not be compiled, or invalid template format"
},
"500": {
"description": "template was not created: invalid template for instance"
"description": "template should have been saved on disk but could not be saved"
}
}
}
......@@ -137,11 +140,11 @@
}
],
"responses": {
"200": {
"204": {
"description": "template was deleted and unloaded"
},
"500": {
"description": "template could not be unloaded or deleted"
"404": {
"description": "template does not exist"
}
}
}
......@@ -168,7 +171,7 @@
}
}
},
"500": {
"404": {
"description": "template does not exist"
}
}
......@@ -221,8 +224,11 @@
}
}
},
"500": {
"description": "template does not exist or issue during rendering"
"404": {
"description": "template does not exist"
},
"400": {
"description": "issue during rendering"
}
}
}
......@@ -284,14 +290,14 @@
}
}
},
"500": {
"400": {
"description": "missing template data, or missing data, or issue during template compilation, or issue during template rendering"
}
}
}
},
"/templates/{templateId}/reload": {
"get": {
"put": {
"summary": "Reloads a specific template from the disk.",
"description": "Only works if a permanent storage is set.",
"parameters": [
......@@ -303,22 +309,25 @@
"200": {
"description": "the template was properly reloaded"
},
"500": {
"description": "when a problem happens"
"404": {
"description": "template does not exist"
},
"400": {
"description": "no templates path, or template compilation problem"
}
}
}
},
"/templates/reload": {
"get": {
"put": {
"summary": "Reloads all templates from the disk.",
"description": "Only works if a permanent storage is set.",
"responses": {
"200": {
"description": "the templates were properly reloaded"
},
"500": {
"description": "when a problem happens"
"400": {
"description": "when templates path is not set"
}
}
}
......
......@@ -27,14 +27,15 @@ export default class TemplatesController {
this.templatesPath = templatesPath;
if (this.templatesPath) {
console.log(`templatesPath is ${this.templatesPath}`);
this.loadTemplatesFromDisk();
} else {
console.log(`no templatesPath set`);
}
this.intializeRoutes();
this.initializeRoutes();
}
public intializeRoutes(): void {
initializeRoutes(): void {
this.router.get(this.path, this.listTemplates);
this.router.get(`${this.path}/:templateId/template`, this.getTemplate);
......@@ -46,33 +47,39 @@ export default class TemplatesController {
this.router.delete(`${this.path}/:templateId`, this.deleteTemplate);
this.router.get(`${this.path}/reload`, this.reloadAllTemplates);
this.router.get(`${this.path}/:templateId/reload`, this.reloadTemplate);
this.router.put(`${this.path}/reload`, this.reloadAllTemplates);
this.router.put(`${this.path}/:templateId/reload`, this.reloadTemplate);
}
private loadTemplatesFromDisk = (): void => {
console.info(`startup, reloading all templates from disk...`);
const files = fs.readdirSync(this.templatesPath);
for (let i = 0; i < files.length; i++) {
const file: string = files[i];
if (file.endsWith('.json')) {
// avoid .gitkeep...
try {
const rawContent = fs.readFileSync(`${this.templatesPath}/${file}`, 'utf8');
const rosaeContext: RosaeContext = new RosaeContext(JSON.parse(rawContent));
this.rosaeContexts.set(rosaeContext.getTemplateId(), rosaeContext);
} catch (e) {
console.warn(`could not reload ${file}: ${e.message}`);
}
}
}
};
reloadAllTemplates = (request: express.Request, response: express.Response): void => {
console.info(`reloading all templates...`);
if (!this.templatesPath) {
response.status(500).send(`no templates path, cannot reload!`);
response.status(400).send(`no templates path, cannot reload!`);
return;
} else {
// forget everything that was loaded
this.rosaeContexts = new Map<string, RosaeContext>();
const files = fs.readdirSync(this.templatesPath);
for (let i = 0; i < files.length; i++) {
const file: string = files[i];
if (file.endsWith('.json')) {
// avoid .gitkeep...
try {
const rawContent = fs.readFileSync(`${this.templatesPath}/${file}`, 'utf8');
const rosaeContext: RosaeContext = new RosaeContext(JSON.parse(rawContent));
this.rosaeContexts.set(rosaeContext.getTemplateId(), rosaeContext);
} catch (e) {
console.warn(`could not reload ${file}: ${e.message}`);
}
}
}
this.loadTemplatesFromDisk();
response.sendStatus(200);
}
};
......@@ -83,7 +90,7 @@ export default class TemplatesController {
console.info(`reloading specific template: ${templateId}...`);
if (!this.templatesPath) {
response.status(500).send(`no templates path, cannot reload!`);
response.status(400).send(`no templates path, cannot reload!`);
return;
}
......@@ -91,7 +98,7 @@ export default class TemplatesController {
try {
templateContent = fs.readFileSync(`${this.templatesPath}/${templateId}.json`, 'utf8');
} catch (e) {
response.status(500).send(`could not read file`);
response.status(404).send(`template does not exist on disk`);
return;
}
......@@ -102,7 +109,7 @@ export default class TemplatesController {
response.sendStatus(200);
return;
} catch (e) {
response.status(500).send(`could not load template ${e.message}`);
response.status(400).send(`could not load template ${e.message}`);
return;
}
};
......@@ -121,10 +128,10 @@ export default class TemplatesController {
}
if (!loadedExisted && !fileExisted) {
response.status(500).send(`${templateId} does not exist`);
response.status(404).send(`${templateId} does not exist`);
return;
} else {
response.sendStatus(200);
response.sendStatus(204);
}
};
......@@ -143,7 +150,7 @@ export default class TemplatesController {
const rosaeContext = this.rosaeContexts.get(templateId);
if (!rosaeContext) {
response.status(500).send(`${templateId} does not exist`);
response.status(404).send(`${templateId} does not exist`);
return;
} else {
response.send(rosaeContext.getPackagedTemplate());
......@@ -158,13 +165,13 @@ export default class TemplatesController {
try {
rosaeContext = new RosaeContext(templateContent);
} catch (e) {
response.status(500).send(`error creating template: ${e.message}`);
response.status(400).send(`error creating template: ${e.message}`);
return;
}
const templateId = rosaeContext.getTemplateId();
if (!templateId) {
response.status(500).send(`no templateId!`);
response.status(400).send(`no templateId!`);
return;
} else {
const status = this.rosaeContexts.has(templateId) ? 'UPDATED' : 'CREATED';
......@@ -174,6 +181,7 @@ export default class TemplatesController {
fs.writeFileSync(`${this.templatesPath}/${templateId}.tmp`, JSON.stringify(templateContent), 'utf8');
fs.renameSync(`${this.templatesPath}/${templateId}.tmp`, `${this.templatesPath}/${templateId}.json`);
} catch (e) {
console.log('ERROR could not save to disk');
response.status(500).send(`could not save to disk!`);
return;
}
......@@ -181,7 +189,7 @@ export default class TemplatesController {
this.rosaeContexts.set(templateId, rosaeContext);