Tapa Save
Tapa Save

Reputation: 4857

How generate random word from real languages

How I can generate random word from real language?

Anybody know any API from internet with this functional?

For example I send http-request to 'ht_tp://www.any...api.com/getword?lang=en' and I get responce 'Town'. Or 'Fast'. Or 'Received'... For example I send http-request to 'ht_tp://www.any...api.com/getword?lang=ru' and I get responce 'Ходить'. Or 'Шапка'. Or 'Отправлено'... Any form (noun, adjective, verb etc...) of the words of the any language.

I find resource 'http://www.randomlists.com/random-words'. But this is not JSON format, only English, and don't any warranty work in long time.

Please any ideas.

Upvotes: 3

Views: 2563

Answers (3)

cheffe
cheffe

Reputation: 9500

You can download the OpenOffice dictionaries. They come as extension (oxt), which is nothing different than a ZIP file. You may open them with 7zip or alike. Within you will find lots of files, interesting for you are the *.dic files. They will also contain resolutions or number words.

When you encounter something like abandon/LdS get rid of the /LdS this is used for hunspell.

Take these *.dic files use their name as key, put them into a database and pick a random word from there for a given language code.

Update

Older, but easier to access, the archived hunspell dictionaries from OpenOffice.

Upvotes: 1

Nikola Sivkov
Nikola Sivkov

Reputation: 2852

See this answer : https://stackoverflow.com/questions/824422/can-i-get-an-english-dictionary-word-list-somewhere Download a word dictionary, stick in the databse and fetch a random record or read a random line from the file each time. This way you don't depend on 3rd party API and you can extend it in all the languages you can find words for.

Upvotes: 1

user877329
user877329

Reputation: 6200

This question can be viewed in two ways and therefore I give two answers:

  • To collect words, I would run a spider on websites with known language (Wikipedia is a good starting point) and strip HTML tags.
  • To generate words from a real language is trickier. Using statistics from the collected words, it is possible to use Markow chains that produces statistically real words. I have tried letter by letter generation, and that works poorly. It is probably a better approach to use syllable construction instead.

Upvotes: -1

Related Questions