Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifiers not working / NPM Package probem #30

Open
tregenza opened this issue Nov 9, 2016 · 2 comments
Open

Modifiers not working / NPM Package probem #30

tregenza opened this issue Nov 9, 2016 · 2 comments

Comments

@tregenza
Copy link

tregenza commented Nov 9, 2016

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?

@Harrison-M
Copy link

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.

@tregenza
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants