summary refs log tree commit diff
path: root/doc/spell-check.scm
diff options
context:
space:
mode:
authorArun Isaac2021-11-05 23:22:55 +0530
committerArun Isaac2021-11-05 23:25:36 +0530
commite11ce9bdb2b8a54865edb93dc896479dfafba173 (patch)
tree8ccc8f3673dce09e531aa4fd775e7c06b156b3b8 /doc/spell-check.scm
parentc86e1b4276fba6dd110dfb91ffead5707a77421d (diff)
downloadccwl-e11ce9bdb2b8a54865edb93dc896479dfafba173.tar.gz
ccwl-e11ce9bdb2b8a54865edb93dc896479dfafba173.tar.lz
ccwl-e11ce9bdb2b8a54865edb93dc896479dfafba173.zip
doc: Add spell check workflow to tutorial.
* doc/ccwl.skb (Tutorial)[Let's write a spell check workflow]: New
section.
* Makefile.am (doc/spell-check.out): New target.
(EXTRA_DIST): Add doc/spell-check-text.txt and doc/dictionary.
* doc/dictionary, doc/spell-check-text.txt,
doc/spell-check-workflow-1.scm, doc/spell-check-workflow-2.scm,
doc/spell-check.scm: New files.
Diffstat (limited to 'doc/spell-check.scm')
-rw-r--r--doc/spell-check.scm32
1 files changed, 32 insertions, 0 deletions
diff --git a/doc/spell-check.scm b/doc/spell-check.scm
new file mode 100644
index 0000000..1f05154
--- /dev/null
+++ b/doc/spell-check.scm
@@ -0,0 +1,32 @@
+(define split-words
+  (command #:inputs text
+           #:run "tr" "--complement" "--squeeze-repeats" "A-Za-z" "\\n"
+           #:stdin text
+           #:outputs (words #:type stdout)))
+
+(define downcase
+  (command #:inputs words
+           #:run "tr" "A-Z" "a-z"
+           #:stdin words
+           #:outputs (downcased-words #:type stdout)))
+
+(define sort
+  (command #:inputs words
+           #:run "sort" "--unique"
+           #:stdin words
+           #:outputs (sorted #:type stdout)))
+ 
+(define find-misspellings
+  (command #:inputs words dictionary
+           #:run "comm" "-23" words dictionary
+           #:outputs (misspellings #:type stdout)))
+
+(workflow (text-file dictionary)
+  (pipe (tee (pipe (split-words #:text text-file)
+                   (downcase #:words words)
+                   (sort (sort-words) #:words downcased-words)
+                   (rename #:sorted-words sorted))
+             (pipe (sort (sort-dictionary) #:words dictionary)
+                   (rename #:sorted-dictionary sorted)))
+        (find-misspellings #:words sorted-words
+                           #:dictionary sorted-dictionary)))