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
52
|
# File 'lib/shhh/app/nlp/usage.rb', line 12
def usage
out = ''
out << %Q`
#{('Natural Language Processing')}
#{'When '.dark.normal}#{'shhh'.bold.blue} #{'is invoked, and the first argument does not begin with a dash,
then the the NLP (natural language processing) Translator is invoked.
The Translator is based on a very simple algorithm:
* ignore any of the words tagged STRIPPED. These are the ambiguous words,
or words with duplicate meaning.
* map the remaining arguments to regular double-dashed options using the DICTIONARY
* words that are a direct match for a --option are automatically double-dashed
* remaining words are left as is (these would be file names, key names, etc).
* finally, the resulting "new" command line is parsed with regular options.
* When arguments include "verbose", NLP system will print "before" and "after"
of the arguments, so that any issues can be debugged and corrected.
'.dark.normal}
#{('Currently ignored words:')}
#{Constants::STRIPPED.join(', ').red.italic}
#{('Regular Word Mapping')}
#{Constants::DICTIONARY.pretty_inspect.split(/\n/).map do |line|
line.gsub(
/[\:\}\,\[\]]/, ''
).gsub(
/[ {](\w+)=>([^\n]*)/, '\2|\1'
)
end.map { |line| convert_dictionary(*line.split('|')) }.join}
#{('Examples')}
`
out
end
|