Modifiers not working / NPM Package probem
tregenza opened this issue · 2 comments
I've cannot get the capitalize and other modifiers to work in node.js.
Running this code:
var tracery = require('tracery-grammar');
var grammar = tracery.createGrammar({
'animal': ['panda','fox','capybara','iguana'],
'emotion': ['sad','happy','angry','jealous'],
'origin':['I am #emotion.a# #animal.capital#.'],
});
console.log(grammar.flatten('#origin#'));
outputs
I am jealous((.a)) capybara((.capital)).
Tracery was installed via npm and don't seem to include any code for modifiers. Looking at the files on here on Github I see there is a separate branch, tracery2, which has a mods-eng-basic.js package.
I tried downloading the tracery2 branch, creating a NPM package for it and installing but it makes no difference. I'm new to node.js, NPM, and Tracery and cannot find a way to load the mods-eng-basic.js / get the modifiers to work.
How do I get the modifiers working in Node.js?
To access the english grammar modifiers in the npm tracery-grammar package, you need to add the following line after you create the grammar:
grammar.addModifiers(tracery.baseEngModifiers);
See the example on the project's repository.
Many thanks Harrison.
I completely missed this, I was working off the Tracery NPM page [ https://www.npmjs.com/package/tracery-grammar ] and the Tracery GitHub Master branch [ https://github.com/galaxykate/tracery/tree/master ] which don't have this line in the example.
Looking the NPM package on GitHub's commit history I see it does include the Tracery2 branch.
Do you (anyone) know if that is up to date with the current Tracery repository?
If I was looking to do some work on the library, which branch / repository / package should I be looking at?