simplify spellchecker words script (#1755)

Found the `tr` command to replace the extra `split-module-names.hs` script.
This commit is contained in:
Karl Ostmo 2024-01-29 11:05:35 -08:00 committed by GitHub
parent 0c45811755
commit 8181cea944
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 31 deletions

View File

@ -1,9 +1,9 @@
#!/bin/bash -e
# This script lives 2 levels deep in the directory structure.
# This script lives 1 level deep in the directory structure.
# Ensure its commands get run at the toplevel.
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd $SCRIPT_DIR/../..
cd $SCRIPT_DIR/..
# First, install hiedb:
@ -27,7 +27,19 @@ sqlite3 $DBNAME "SELECT substr(sym, 3) FROM (SELECT DISTINCT occ AS sym FROM ref
# Next, append the individual "conids" extracted from all "modids" that originate from external packages.
# See definition of "conid" and "monid" here:
# https://www.haskell.org/onlinereport/haskell2010/haskellch5.html
sqlite3 $DBNAME "SELECT DISTINCT mod FROM refs WHERE unit NOT IN (SELECT DISTINCT unit FROM mods)" | scripts/spellcheck/split-module-names.hs >> $WORDS_TMPFILE_UNSORTED
#
# E.g., takes lines of the following form:
#
# Data.Text
# Control.Arrow
#
# and produces a flattened list of words:
#
# Arrow
# Control
# Data
# Text
sqlite3 $DBNAME "SELECT DISTINCT mod FROM refs WHERE unit NOT IN (SELECT DISTINCT unit FROM mods)" | tr '.' '\n' >> $WORDS_TMPFILE_UNSORTED
WORDS_TMPFILE=$(mktemp --suffix .words)
sort -u $WORDS_TMPFILE_UNSORTED > $WORDS_TMPFILE

View File

@ -1,28 +0,0 @@
#!/usr/bin/env stack
{- stack script --resolver lts-21.25
--package data-ordlist
--package split
-}
import Data.List.Ordered (nubSort)
import Data.List.Split (splitOn)
-- |
-- Extracts all "conids" from a list of "modids".
-- (see definitions here: https://www.haskell.org/onlinereport/haskell2010/haskellch5.html )
--
-- E.g., takes lines of the following form:
--
-- Data.Text
-- Control.Arrow
--
-- and produces a flattened list of words:
--
-- Arrow
-- Control
-- Data
-- Text
splitParts = unlines . nubSort . concatMap (splitOn ".") . lines
main :: IO ()
main = interact splitParts