-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCopyWriter.js
51 lines (42 loc) · 1.52 KB
/
CopyWriter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
var tracery = require('tracery-grammar'),
// pronouncing = require('pronouncing'),
vocabulary = require('./vocabulary')
var rules =
{
'encouraging': vocabulary.encouraging,
'weather': vocabulary.weather,
'surface': vocabulary.surface,
'verbing': vocabulary.verbing,
'me': ['[sentence:I am][punctuation:.]', '[sentence:I feel][punctuation:.]', '[sentence:am I][punctuation:?]'],
'you': ['[sentence:you seem][punctuation:.]', '[sentence:are you][punctuation:?]', '[sentence:you are][punctuation:.]'],
}
function generate(inputs)
{
var origin =
[
'I feel like #weather# #surface#.', // metaphor
'[#me#]#sentence.capitalize# #weather##punctuation#', // me
'[#you#]#sentence.capitalize# #weather##punctuation#', // you
'[#me#]#sentence.capitalize# #weather##punctuation# [#you#]#sentence.capitalize# #weather##punctuation#', // me and you
'[#you#]#sentence.capitalize# #weather##punctuation# [#me#]#sentence.capitalize# #weather##punctuation#', // you and me
]
if (inputs.place) // if there's a place, let's add an expansion for it
{
origin.push(inputs.place + ' is #encouraging#.')
}
rules.origin = origin
// console.log(rules)
var grammar = tracery.createGrammar(rules)
grammar.addModifiers(tracery.baseEngModifiers)
var text = grammar.flatten('#origin#')/*,
words = text.split(' '),
lastWord = words[words.length - 1],
rhymes = pronouncing.rhymes(lastWord)*/
// console.log(text, rhymes)
// console.log(text)
return text
}
module.exports =
{
generate: generate
}