DEV Community

Bruce Axtens
Bruce Axtens

Posted on • Edited on

1

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$"

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

SurveyJS custom survey software

Simplify data collection in your JS app with a fully integrated form management platform. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more. Integrates with any backend system, giving you full control over your data and no user limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay