DEV Community

Bruce Axtens
Bruce Axtens

Posted on • Updated on

Words that end with -ism (another Quora question)

So now there's another long list of words polluting the Quora database. This is a list of words ending with "-ism" as requested at Quora.

It uses a very large collection of words, the 2019 Collins Scrabble word list. The code reads the entire file from Google Drive, turns it into an array, filters out the header and then filters on a regular expression.

The code is there on Quora but I've reproduced it below. It also uses the Deno.args property to access the command line so that a regular expression can be handed in to the script.

// wref.ts
const rawWords = await fetch(
  "https://drive.google.com/uc?export=download&id=1oGDf1wjWp5RF_X9C7HoedhIWMh5uJs8s",
);

const rex = (Deno.args.length) ? new RegExp(Deno.args[0], "gi") : /.*/gi;

const body = new Uint8Array(await rawWords.arrayBuffer());

const list = new TextDecoder("utf-8").decode(body).split(/\r\n|\r|\n/g);

console.log(
  list
    .filter((line: string, index: number) => index > 1)
    .filter((word: string) => null !== word.match(rex))
    .join(", "),
);
Enter fullscreen mode Exit fullscreen mode

Invocation is

deno run --allow-net wref.ts "ism$"

Top comments (0)