Exploring Word Patterns

Written by on September 15, 2019 in Natural Language Processing, Programming, Prolog with 0 Comments

Working with word patterns can be an exciting (and challenging) creative activity. Such patterns come into picture while playing word games, solving word puzzles or even writing poetry. It is precisely to facilitate such tasks that I am building my “iLexicon” system. 

One popular word game goes like this: The first player utters a word, and the next player is expected to say a word that starts with the ending syllable of the previous word. For example, if the first word is “Happy”, an acceptable next word is “Pylon”. And what can follow “Pylon”? The words “Loner”, “Longer”, “Longevity”, etc. are all OK.

Let me show you how such word pairs can be generated using “iLexicon”. Look at the Prolog code below:

Prolog Predicates for Word Pair Generation

Prolog Predicates for Word Pair Generation

There are 4 predicates. The predicate “get_noun_verb(N, V)” succeeds by binding “N” to a random noun and binding “V” to a verb that starts with the ending syllable of “N”. Similarly, the predicate “get_verb_noun(V, N)” succeeds by binding “V” to a random verb and binding “N” to a noun that starts with the ending syllable of “V”. I hope you can guess the functionality of the other two predicates “get_noun_noun(N1, N2)” and “get_verb_verb(V1, V2)”. I chose the categories “verb” and “noun” because they are quite common, but we can do this for other word categories too.

Here is the sample output for <Noun, Verb> pairs:

<Noun, Verb> Pairs

<Noun, Verb> Word Pairs

In the above example, “martyr” follows “grammar”, “sense” follows “nonsense”, “ball” follows “baseball” and “bitters” follows “rabbit”. All valid as per our rule, right?

What follows are <Noun, Noun> pairs:

<Noun, Noun> Word Pairs

<Noun, Noun> Word Pairs

In the above case, both the words are nouns. You can confirm that they are well-formed as per our rules.

Next, some <Verb, Noun> pairs:

<Verb, Noun> Word Pairs

<Verb, Noun> Word Pairs

Finally, <Verb, Verb> pairs:

<Verb, Verb> Word Pairs

<Verb, Verb> Word Pairs

As I mentioned earlier, it is possible to generate such pairs between other word categories too, for example <Noun, Adjective>, <Verb, Adverb> and so on. Fortunately because of the huge collection of words and phrases contained in “iLexicon”, many such challenging problems can be solved.

Hope you liked this discussion. I will take up other interesting patterns in future articles.

Have a nice weekend!

Tags: ,

Subscribe

If you enjoyed this article, subscribe now to receive more just like it.

Subscribe via RSS Feed

Leave a Reply

Your email address will not be published.

Top