This module was written by Joel Gould a few years after the initial release of NatLink. It is in the MacroSystem/Core directory of NatLink.
The purpose is to do formatting of the dictated words in a window/control (VDct) was replaced by a DictGramBase subclass. By this DictGramBase all dictated words are caught, but not formatted.
Nsformat can also be used to format words that are called by the dgndictation imported rule, also called _anything in Vocola.
In NatSpeak versions up to 10 the word properties of each dictated word were extracted and with these word properties the words were formatted.
Starting with Dragon 11 the word properties cannot be extracted by NatLink anymore, but a new mechanism of category is introduced in dictated words. Like:
a\spelling-letter\A (in spell mode)
l\spelling-letter\Lima (in spell mode)
With these categories the formatting properties are constructed in the updated version of nsformat (with release 4.0 of NatLink).
The essential call to nsformat is:
def gotResults_dgndictation(self, words, fullResults):
formattedOutput, outputState = nsformat.formatWords(words, state=-1) # no capping, no spacing
- Note the output is a tuple of length 2, the output text and the output state, the latter can be used in a subsequent call of nsformat.
- This example comes (a bit adapted) from the grammar _brackets.py, see there for more implementation details.
- Do not forget dgndictation imported; in your grammar specification. If you use the DocstringGrammar subclass (like _brackets.py), you can define importedrule_dgndictation instead.
The state to start with can be given as None (default), as integer or as tuple.
no space next, active cap next (like beginning of dictation box)
no properties set, will start with a space and lowercase
no space, starting with lowercase
extract properties according to bit positions
tuple of integers
these are the "extracted properties", examples:
no space at start, capitalize all words
no space at start, uppercase all words
no spacing, all lowercase (eg for dictating email address)
See more details in the source file, nsformat.py, and in the unittest file unittestNsformat.py (in the PyTest directory of NatLink).