Inspired by this xkcd comic, I'm trying to write a computer program that can generate random sentences to be used as pass phrases. However, I think that the pass phrases might be easier to remember if I stick to grammatically correct sentences instead of just using random sets of words. My plan so far is to stick to a simple <noun>-<adjective>-<verb>-<noun>-<adjective> format and my back-of-the-napkin calculations suggests that this should provide enough variety to make cracking the passwords by brute force infeasible.

The difficulty I am facing now is that to make sure that the sentences I generate are grammatically correct I need a dictionary that has the singular and plural forms of every noun as well as all all the tenses for every verb. Is there anywhere I can find this kind of database? Bonus points if there is data for many languages!

I first considered using some open-source spellcheck dictionaries (hunspell and aspell) because they are available for many languages and contain all the different inflections of the words. However, these spellchecking dictionaries didn't classify the words as noun/verb/adjective or mark what nouns were singular/plural and what was the tense of each verb.

I also tried downloading some dictionaries out of Project Gutenberg but those dictionaries focus on providing definitions (which I do not need) and don't explicitly list all the variations for every word. I would also have to hunt down a different dictionary for each language and write specialized code to parse each of them, which would be a lot of work.

  • This kind of request is just too broad. Any if you want something useful for such a specific use case, then you should expect to have to put some money towards it. – curiousdannii Jan 1 '16 at 8:56
  • My request is a bit broad but my end goal is very specific. I'm looking for whatever it takes to be able to combine words into simple sentences while knowing that the end result is gramatically correct. It would be a shame if something so simple is not freely available anywhere :( – hugomg Jan 1 '16 at 13:08
  • When language is involved rarely is anything so simple... – curiousdannii Jan 1 '16 at 13:15
  • I thought I could get away with it because I'm not trying to generate every sentence out there. As I said before, a spellcheck dictionary almost gets me there :/ – hugomg Jan 1 '16 at 13:18
  • A spell check dictionary isn't anywhere near "almost there" as soon as you start supporting a language with grammatical gender. – Flimzy Jan 2 '16 at 23:17

(Comm. Wiki because it's not an answer but a wordy comment, sorry)

What you're trying to do is called sentence generator. Googling for this phrase shows up quite a few ready-made services on the Internet. Some of them are open-source, developed on a variety of platforms, programming languages, and libraries; some are using freeware word corpus.

Instead of re-inventing a wheel, I suggest you to review the existing solutions to see what dictionaries, grammar libraries, and tools they are using. Or you maybe even want to join an existing project team. Then you may add a relatively small piece of code to make the existing project do what you need.

In any case, we are unable to suggest a dictionary with unknown characteristics, especially considering that you need not only a dictionary, but also some set of grammar rules of conjugation, verb governance, phrase structures, and this is multiplied by a requirement of supporting different languages. We simply can't develop the entire (!) architecture of your software, hence we can't answer this question.

When you are started with some architecture and come back with more narrow questions, we will be happy to answer.

Not the answer you're looking for? Browse other questions tagged or ask your own question.