Commit a43d2c19 authored by Ludan Stoecklé's avatar Ludan Stoecklé

1.10.0

parent a4da31ac
......@@ -20,7 +20,7 @@ stages:
# variables etc.
variables:
ROSAENLG_VERSION: 1.9.2
ROSAENLG_VERSION: 1.10.0
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.9.2",
"version": "1.10.0",
"description": "Client side demo of NLG templates compilation and rendering using RosaeNLG",
"main": "index.js",
"scripts": {
......@@ -33,7 +33,7 @@
"gulp-inject-string": "^1.1.2",
"gulp-rename": "^1.4.0",
"merge-stream": "^2.0.0",
"rosaenlg": "1.9.2",
"rosaenlg": "1.10.0",
"vue-codemirror": "^4.0.6"
}
}
......@@ -109,15 +109,17 @@ window.onload = function() {
const packaged = {
templateId: name,
entryTemplate: `${name}.pug`,
compileInfo: {
activate: false,
compileDebug: false,
language: language,
src: {
entryTemplate: `${name}.pug`,
compileInfo: {
activate: false,
compileDebug: false,
language: language,
},
templates: {},
},
templates: {},
};
packaged.templates[`${name}.pug`] = this.code;
packaged.src.templates[`${name}.pug`] = this.code;
const contentAsBlob = new Blob([JSON.stringify(packaged)], { type: 'application/json' });
this.userDownload(`${name}.json`, contentAsBlob);
......
{
"name": "content-deduplicate",
"version": "0.4.2",
"version": "0.5.0",
"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.9.2"
"synonym-optimizer": "2.10.0"
}
}
{
"name": "english-a-an-list",
"version": "0.1.2",
"version": "0.2.0",
"description": "English words and adjectives that are preceded by the indefinite article 'an', based on WordNet",
"main": "dist/aan.json",
"scripts": {
......
{
"name": "english-a-an",
"version": "0.1.2",
"version": "0.2.0",
"description": "English a/an indefinite articles, based on WordNet",
"main": "dist/index.js",
"scripts": {
......@@ -13,7 +13,7 @@
"url": "[email protected]:rosaenlg-projects/rosaenlg.git"
},
"devDependencies": {
"english-a-an-list": "0.1.2",
"english-a-an-list": "0.2.0",
"mocha": "^6.2.2",
"typescript": "^3.7.2"
},
......
{
"name": "english-determiners",
"version": "2.9.2",
"version": "2.10.0",
"description": "English determiners",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "english-plurals-list",
"version": "0.1.2",
"version": "0.2.0",
"description": "English irregular plurals list, based on WordNet",
"main": "dist/plurals.json",
"scripts": {
......
{
"name": "english-plurals",
"version": "0.1.2",
"version": "0.2.0",
"description": "English plural of words",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -45,7 +45,7 @@
}
},
"devDependencies": {
"english-plurals-list": "0.1.2",
"english-plurals-list": "0.2.0",
"mocha": "^6.2.2",
"nyc": "^14.1.1",
"typescript": "^3.7.2"
......
{
"name": "english-verbs-gerunds",
"version": "0.1.2",
"version": "0.2.0",
"description": "English irregular gerunds list (-ing), based on WordNet",
"main": "dist/gerunds.json",
"scripts": {
......
{
"name": "english-verbs-helper",
"version": "0.1.2",
"version": "0.2.0",
"description": "English verbs conjugation",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -45,8 +45,8 @@
}
},
"devDependencies": {
"english-verbs-gerunds": "0.1.2",
"english-verbs-irregular": "0.1.2",
"english-verbs-gerunds": "0.2.0",
"english-verbs-irregular": "0.2.0",
"mocha": "^6.2.2",
"nyc": "^14.1.1",
"typescript": "^3.7.2"
......
{
"name": "english-verbs-irregular",
"version": "0.1.2",
"version": "0.2.0",
"description": "English irregular verbs list (JSON)",
"main": "dist/verbs.json",
"scripts": {
......
{
"name": "french-adjectives",
"version": "2.9.2",
"version": "2.10.0",
"description": "Agreement of adjectives in French",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -46,7 +46,7 @@
},
"dependencies": {
"debug": "^4.1.1",
"french-h-muet-aspire": "2.9.2"
"french-h-muet-aspire": "2.10.0"
},
"keywords": [
"french",
......
{
"name": "french-determiners",
"version": "2.9.2",
"version": "2.10.0",
"description": "French determiners",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "french-h-muet-aspire",
"version": "2.9.2",
"version": "2.10.0",
"description": "List of French words that are 'aspiré' (vs. 'muet')",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "french-ordinals",
"version": "2.9.2",
"version": "2.10.0",
"description": "Ordinal numbers in French: 12 => douzième",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "french-verbs-intransitive",
"version": "0.2.2",
"version": "0.3.0",
"description": "list of intransitive French verbs",
"main": "dist/intransitive.json",
"scripts": {
......
{
"name": "french-verbs-lefff",
"version": "0.2.2",
"version": "0.3.0",
"description": "French verbs conjugation data, based on the Lefff content",
"main": "dist/conjugations.json",
"scripts": {
......
{
"name": "french-verbs-transitive",
"version": "0.2.2",
"version": "0.3.0",
"description": "French transitive verbs, based on Wikipedia",
"main": "dist/transitive.json",
"scripts": {
......
{
"name": "french-verbs",
"version": "2.9.2",
"version": "2.10.0",
"description": "French verbs conjugation",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -46,11 +46,11 @@
},
"dependencies": {
"debug": "^4.1.1",
"french-h-muet-aspire": "2.9.2",
"french-verbs-transitive": "0.2.2"
"french-h-muet-aspire": "2.10.0",
"french-verbs-transitive": "0.3.0"
},
"devDependencies": {
"french-verbs-lefff": "0.2.2",
"french-verbs-lefff": "0.3.0",
"mocha": "^6.2.2",
"nyc": "^14.1.1",
"typescript": "^3.7.2"
......
{
"name": "french-words-gender-lefff",
"version": "0.2.2",
"version": "0.3.0",
"description": "French words gender, based on the Lefff content",
"main": "dist/words.json",
"scripts": {
......
{
"name": "french-words-gender",
"version": "2.9.2",
"version": "2.10.0",
"description": "Gender of French words",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -48,7 +48,7 @@
"debug": "^4.1.1"
},
"devDependencies": {
"french-words-gender-lefff": "0.2.2",
"french-words-gender-lefff": "0.3.0",
"gulp": "^4.0.2",
"mocha": "^6.2.2",
"nyc": "^14.1.1",
......
{
"name": "german-adjectives-dict",
"version": "0.2.2",
"version": "0.3.0",
"description": "German adjectives dictionnary, based on the german-pos-dict content",
"main": "dist/adjectives.json",
"scripts": {
......
{
"name": "german-adjectives",
"version": "2.9.2",
"version": "2.10.0",
"description": "German adjectives agreement",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -45,7 +45,7 @@
}
},
"devDependencies": {
"german-adjectives-dict": "0.2.2",
"german-adjectives-dict": "0.3.0",
"mocha": "^6.2.2",
"nyc": "^14.1.1",
"typescript": "^3.7.2"
......
{
"name": "german-determiners",
"version": "2.9.2",
"version": "2.10.0",
"description": "German determiners",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "german-dict-helper",
"version": "2.9.2",
"version": "2.10.0",
"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.9.2",
"version": "2.10.0",
"description": "Ordinal numbers in German: 12 => zwölfte",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "german-verbs-dict",
"version": "0.2.2",
"version": "0.3.0",
"description": "German verbs dictionnary, based on the german-pos-dict content",
"main": "dist/verbs.json",
"scripts": {
......
{
"name": "german-verbs",
"version": "2.9.2",
"version": "2.10.0",
"description": "German verbs, based on german-pos-dict",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -45,7 +45,7 @@
}
},
"devDependencies": {
"german-verbs-dict": "0.2.2",
"german-verbs-dict": "0.3.0",
"nyc": "^14.1.1",
"typescript": "^3.7.2"
},
......
{
"name": "german-words-dict",
"version": "0.2.2",
"version": "0.3.0",
"description": "German words dictionnary, based on the german-pos-dict content",
"main": "dist/words.json",
"scripts": {
......
{
"name": "german-words",
"version": "2.9.2",
"version": "2.10.0",
"description": "Gender and case of German words",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -48,7 +48,7 @@
}
},
"devDependencies": {
"german-words-dict": "0.2.2",
"german-words-dict": "0.3.0",
"mocha": "^6.2.2",
"nyc": "^14.1.1",
"typescript": "^3.7.2"
......
......@@ -24,10 +24,22 @@ interface TemplatesMap {
[key: string]: string;
}
export interface PackagedTemplate {
format: string;
templateId: string;
src: PackagedTemplateSrc;
comp?: PackagedTemplateComp;
}
export interface PackagedTemplateSrc {
entryTemplate: string;
templates: TemplatesMap;
compileInfo: CompileInfo;
compiled?: string;
autotest?: Autotest;
}
export interface PackagedTemplateComp {
compiled: string;
compiledWithVersion: string;
compiledBy?: string;
compiledWhen?: string;
}
import fs = require('fs');
import path = require('path');
import stream = require('stream');
import rosaenlgPug = require('rosaenlg');
import rosaenlg = require('rosaenlg');
import browserify = require('browserify');
import minify = require('minify-stream');
import { PackagedTemplateParams, PackagedTemplate } from './PackagedTemplate';
export { PackagedTemplate, PackagedTemplateSrc, PackagedTemplateComp } from './PackagedTemplate';
export type Languages = 'en_US' | 'fr_FR' | 'de_DE' | string;
const FORMAT = '1.0.0';
export function renderTemplateInFile(template: string, dest: string, options: any): void {
if (!template) {
const err = new Error();
......@@ -23,7 +27,7 @@ export function renderTemplateInFile(template: string, dest: string, options: an
throw err;
}
const rendered = rosaenlgPug.renderFile(template, options);
const rendered = rosaenlg.renderFile(template, options);
fs.writeFileSync(dest, rendered);
}
......@@ -56,7 +60,7 @@ export function compileTemplates(
sourcesAndNames.forEach(function(sourceAndName: SourceAndName): void {
console.log(`template ${sourceAndName.source} => ${sourceAndName.name}`);
const compiled = rosaenlgPug.compileFileClient(sourceAndName.source, {
const compiled = rosaenlg.compileFileClient(sourceAndName.source, {
language: language,
compileDebug: false,
embedResources: true,
......@@ -109,20 +113,23 @@ function getFilesInDir(dir: string, filelist: string[]): string[] {
export function packageTemplateJson(params: PackagedTemplateParams): PackagedTemplate {
const res: PackagedTemplate = {
format: FORMAT,
templateId: params.templateId,
entryTemplate: params.entryTemplate,
compileInfo: Object.assign({}, params.compileInfo), // as we will modify the object in res
templates: {},
src: {
entryTemplate: params.entryTemplate,
compileInfo: Object.assign({}, params.compileInfo), // as we will modify the object in res
templates: {},
},
};
// as it is not useful in the result
if (res.compileInfo && res.compileInfo.activate != null) {
delete res.compileInfo.activate;
if (res.src.compileInfo && res.src.compileInfo.activate != null) {
delete res.src.compileInfo.activate;
}
// autotest data if present
if (params.autotest) {
res.autotest = params.autotest;
res.src.autotest = params.autotest;
}
// get templates content
const files = getFilesInDir(params.folderWithTemplates, null);
......@@ -138,17 +145,22 @@ export function packageTemplateJson(params: PackagedTemplateParams): PackagedTem
const finalFileName = file
.replace(new RegExp('\\' + path.sep, 'g'), '/') // change to linux paths
.replace(params.folderWithTemplates + '/', ''); // and remove root
res.templates[finalFileName] = fs.readFileSync(file, 'utf-8');
res.src.templates[finalFileName] = fs.readFileSync(file, 'utf-8');
}
// compile if asked
if (params.compileInfo && params.compileInfo.activate) {
const compiled = rosaenlgPug.compileFileClient(path.join(params.folderWithTemplates, params.entryTemplate), {
const compiled = rosaenlg.compileFileClient(path.join(params.folderWithTemplates, params.entryTemplate), {
language: params.compileInfo.language,
compileDebug: params.compileInfo.compileDebug,
embedResources: true,
});
res.compiled = compiled;
res.comp = {
compiled: compiled,
compiledWithVersion: rosaenlg.getRosaeNlgVersion(),
compiledBy: 'gulp-rosaenlg',
compiledWhen: new Date().toISOString(),
};
}
return res;
......
{
"name": "gulp-rosaenlg",
"version": "2.9.2",
"version": "2.10.0",
"description": "RosaeNLG client side packaging helper",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"clean": "rm -rf dist",
"test": "nyc mocha",
"build": "tsc"
},
......@@ -60,6 +61,6 @@
"browserify": "^16.5.0",
"debug": "^4.1.1",
"minify-stream": "^1.2.1",
"rosaenlg": "1.9.2"
"rosaenlg": "1.10.0"
}
}
......@@ -85,13 +85,15 @@ describe('gulp-rosaenlg', function() {
},
});
// console.log(JSON.stringify(packagedObj));
assert.equal(packagedObj.format, '1.0.0');
assert.equal(packagedObj.templateId, 'test_inc');
assert.equal(packagedObj.entryTemplate, 'test.pug');
assert.equal(Object.keys(packagedObj.templates).length, 2);
assert.equal(packagedObj.autotest.input.language, 'en_US');
assert(packagedObj.src != null);
assert.equal(packagedObj.src.entryTemplate, 'test.pug');
assert.equal(Object.keys(packagedObj.src.templates).length, 2);
assert.equal(packagedObj.src.autotest.input.language, 'en_US');
assert(packagedObj.templates['test.pug'].indexOf('bla') > -1);
assert(packagedObj.templates['inc/included.pug'].indexOf('included') > -1);
assert(packagedObj.src.templates['test.pug'].indexOf('bla') > -1);
assert(packagedObj.src.templates['inc/included.pug'].indexOf('included') > -1);
});
it(`with comp`, function() {
const packagedObj = lib.packageTemplateJson({
......@@ -106,9 +108,11 @@ describe('gulp-rosaenlg', function() {
});
// console.log(JSON.stringify(packagedObj));
assert(!packagedObj.activate);
assert(packagedObj.compiled != null);
assert(packagedObj.compiled.indexOf('bla') > -1);
assert(packagedObj.compiled.indexOf('pug_html') > -1);
assert(packagedObj.comp != null && packagedObj.comp.compiled != null);
assert(packagedObj.comp.compiledBy.indexOf('gulp') > -1);
assert(packagedObj.comp.compiledWhen != null);
assert(packagedObj.comp.compiled.indexOf('bla') > -1);
assert(packagedObj.comp.compiled.indexOf('pug_html') > -1);
});
});
......
{
"name": "italian-adjectives-dict",
"version": "0.2.2",
"version": "0.3.0",
"description": "Italian adjectives dictionnary, based on the morph-it linguistic resource",
"main": "dist/adjectives.json",
"scripts": {
......
{
"name": "italian-adjectives",
"version": "2.9.2",
"version": "2.10.0",
"description": "Italian adjectives helper",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -41,7 +41,7 @@
}
},
"devDependencies": {
"italian-adjectives-dict": "0.2.2",
"italian-adjectives-dict": "0.3.0",
"mocha": "^6.2.2",
"nyc": "^14.1.1",
"typescript": "^3.7.2"
......@@ -54,6 +54,6 @@
"license": "MIT",
"dependencies": {
"debug": "^4.1.1",
"rosaenlg-filter": "2.9.2"
"rosaenlg-filter": "2.10.0"