Use a dictionary to help create a mnemonic

I was using a program that was yet another TLA and I wanted to create a mnemonic to help me remember what it was. One of the letters was “k”, so I wanted to find a word that starts with “k”

Simple: load a dictionary, search for words starting with “k” and browse through them: “Killer” sounded fine!

The Dictionary dll (that you can download from the link below) actually contains 2 separate dictionaries in 679k bytes! The big one (Dictnum=1) has 171,201 words. The smaller (DictNum=2) has 53,869. These dictionaries are spelling dictionaries from the last century.

The samples below also demonstrate a simple LINQ query on the data:

I wanted to use common words, so I used the smaller one.

Fox code:

x=CREATEOBJECT("dictionary.dict")

x.Dictnum=2 && small dictionary

?x.FindMatches("k*")

cnt=x.words.count

CREATE CURSOR words (word c(20))

FOR i = 0 TO cnt-1

      ?x.Words.Item(i)

      INSERT INTO words (word) VALUES (x.words.item(i))

ENDFOR

SELECT * FROM words WHERE AT("ill",word)>0

For VB code, Start VS, File->New->Project->VB->WindowsApplication->Console Application

We don’t have to reference the DLL (unless you want intellisense or use queries directly on the word collection) because late binding works.

(Since the DLL is 32 bit, if you’re using a 64 bit OS, make sure you make Project->Properties->Compile->Advanced Compiler Settings->Target CPU x86)

Module Module1

    Sub Main()

        Dim x = CreateObject("dictionary.dict")

        'Dim x = New Dictionary.CDict ' use early binding: add a ref to Dictionary 1.0 Type Library

        x.DictNum = 2 ' small dictionary

        x.FindMatches("k*")

        Dim col As New List(Of String) ' for late bindinq queries, we'll add to a list

        For Each word In x.words

            Debug.WriteLine(word)

            col.Add(word)

        Next

        For Each word In From a In col Where a.Contains("ill")

            Debug.WriteLine(word)

        Next

    End Sub

End Module

For C#, add a reference to “Dictionary 1.0 Type Library” in the COM tab.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            var x = new Dictionary.CDictClass();

            x.DictNum = 2;

            x.FindMatches("k*");

            foreach (var word in x.Words)

            {

                System.Diagnostics.Debug.WriteLine(word);

            }

            var q = from string a in x.Words where a.Contains("ill") select a;

            foreach (var w in q)

            {

                System.Diagnostics.Debug.WriteLine(w);

            }

        }

    }

}

Download the dictionary from here: A Discounter Introduces Reductions: Multiple Anagrams

You can create many word related games.

More word games:

Write your own hangman game

The Nametag Game

Create your own typing tutor!

Carburetor is a car part, but prosecutable is not

What mnemonic can you create from your phone number? See Phone Number Challenge update