You can associate filters (programs or routines) with unused function keys by modifying your own copy of the file .textswrc. When a text selection has been made and a function key pressed, the selected text is piped through the filter assigned to that key. The output is then piped back into the text at the caret, replacing the text that was selected.
If you want to specify your own set of bindings of filter keys to function keys, you must copy the file /usr/lib/.textswrc to a file called .textswrc in your home directory. The Text Editor reads the file .textswrc from your home directory, if the file exists.