You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-1Lines changed: 18 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -312,7 +312,7 @@ t.expand("There once was a man named #city.reverse.title#, who came from the cit
312
312
> The original implementation at Tracery.io a couple of has modifiers that allows prefixing a/an to words, pluralization, caps etc. This library replicates all the original modifiers and adds two important new ones: the modifier ".n" can be used to add a newline to the document and the modifier ".k(formula)" can be used for making calculations. Currently calculations always return float numbers and the following operations are supported:
Due to how the parsing consumes brackets only bracket-less operations can be performed directly. Otherwise the syntax is as follows:
318
318
@@ -446,6 +446,23 @@ t.expand("#letter#")
446
446
447
447
****
448
448
449
+
## Advanced Usage: Deterministic Execution
450
+
451
+
In order to allow for replicable results, a deterministic random generator can be chosen. This is achieved by setting the option `isDeterministic` to true and supplying a random seed with the option `seed`. Both can be found in `TraceryOptions`. Here is an example:
452
+
453
+
```swift
454
+
455
+
let options = TraceryOptions.defaultSet
456
+
options.seed=15
457
+
options.isDeterministic=true
458
+
459
+
Tracery.init(options, lines: strings)
460
+
461
+
```
462
+
463
+
The above example would expand a grammar similarly over multiple executions.
464
+
465
+
449
466
## Advanced Usage: Custom Content Selectors
450
467
451
468
We know that a rule can have multiple candidates. By default, Tracery chooses a candidate option randomly, but the selection process is guaranteed to be strictly uniform.
0 commit comments