to_pass-algorithm
- algorithm-description for to_pass(1)
An algorithms is a simple list of conversions which are applied to the input
string. The algorithm file is a yaml(3pm) file. yaml
looks like a list of
key-value pairs. Nesting is done by indentation (2 spaces). Consecutive lines
which begin with a -
are considered an array.
The following keys should be supported:
desc
short description of the algorithm
name
name of the algorithm (think: title)
sentence
list of rules which are applied to a string which contains whitespace.
word
list of rules which are applied to everything which is not a sentence.
These keys are highly dependent on the use conversions. In the bundled
algorithms, replace
needs a replacement table. Inside the converter code of
replace
, the replacements-key is required.
It is up to the developer/distributor of the converter to document this.
If a conversion step needs arguments, the argument list is expected to follow the converter name, separated by colon. So far, only simple text arguments are supported. In theory, anything which is valid yaml could follow the name and would be passed into the converter method.
desc: Basic Algorithm with a english usage in mind
name: Basic (english)
sentence:
- replace: words
- first_chars
- replace: symbols
- collapse_chars
word:
- replace: chars
- replace: symbols
replacements:
words:
one: 1
single: 1
two: 2
too: 2
three: 3
four: 4
for: 4
five: 5
six: 6
seven: 7
eight: 8
nine: 9
symbols:
a: '@'
chars:
a: 4
e: 3
i: 1
o: 0
s: 5
The decision wether a string is a word or a sentence is built directly into the gem and not configurable.
The algorithm is not turing-complete. It's not even intended to be. Some more capabilty (like conditions and restart) may be added at some point. The overall design however is intentionally simple and constrained.
Matthias Viehweger
to_pass(1), to_pass-converter(5), yaml(3pm)