How Could I Randomize A Dictionary?

Gizmo j

Senior member
Nov 9, 2013
911
247
116
I'm trying to make a dictionary that orders the words and definitions in random.

Do I have to make a whole app for this or is there a simpler way?
 

pete6032

Diamond Member
Dec 3, 2010
7,484
3,041
136
What do you mean by trying to make? You can Google search for random English word generators and get random words and then look the definitions up using your web browser dictionary. That would require minimal effort.

Here is a random word generator.
 

Red Squirrel

No Lifer
May 24, 2003
67,403
12,142
126
www.anyf.ca
You should try chat GPT. :p

Code:
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <vector>
#include <algorithm>

int main() {
    // Seed the random number generator
    std::srand(std::time(0));

    // List of words in an array
    std::string words[] = {"apple", "banana", "cherry", "date", "elderberry", "fig", "grape", "kiwi", "lemon", "mango"};

    // Get the size of the array
    int numWords = sizeof(words) / sizeof(words[0]);

    // Convert array to vector for easier randomization
    std::vector<std::string> wordsVec(words, words + numWords);

    // Randomly shuffle the vector
    std::random_shuffle(wordsVec.begin(), wordsVec.end());

    // Print out the randomized list of words
    std::cout << "Randomized list of words: " << std::endl;
    for (const auto& word : wordsVec) {
        std::cout << word << std::endl;
    }

    return 0;
}


For such a large amount of words I would do it differently though. Instead of shuffling the entire array just randomize an index and call the array by index.
 
  • Like
Reactions: igor_kavinski

Captante

Lifer
Oct 20, 2003
30,277
10,783
136
You could just use this website:

It maxes out at 50 words, so just keep generating a new list until you are bored.

But I'm bored NOW! :tearsofjoy:
 

sandorski

No Lifer
Oct 10, 1999
70,101
5,640
126
Google

1 random([first page number]-[last page number])
2 random([1-number of columns/page])
3 Measure page height in millimeters; random(1-[bottom])


1 chooses page; 2 chooses column; 3 chooses definition
 

pete6032

Diamond Member
Dec 3, 2010
7,484
3,041
136
I want a very long list of words and definitions like an actual dictionary, but in random.
You could do this in R. There is probably a free csv somewhere with all English language words and their definitions and then you could just randomize the list.
 

pete6032

Diamond Member
Dec 3, 2010
7,484
3,041
136

I'm too chicken to click the link to the file but it claims to be a dictionary in csv format. If it really is, the rest is easy.
Excel has a max of 1 million rows and there are only 170,000 some words in an unabridged dictionary so you could probably just open it in excel and assign a random number to each word and then sort ascending/descending.
 

BurnItDwn

Lifer
Oct 10, 1999
26,074
1,554
126
Assuming you are running linux, bsd, or some other unix like operating system simply dump the data to a txt file and then in your shell do a "sort -R" on the file.
 

Red Squirrel

No Lifer
May 24, 2003
67,403
12,142
126
www.anyf.ca
That AI is as dumb as bricks. Make an array of words to then...copy it to a vector. Why not just use a vector in the first place? o_O

Yeah it doesn't always put out the most optimized code lol. I also wouldn't be shuffling the entire vector. Just need to randomize the index then access it by index. Vector may not be the best data structure either, but been a while since I played with different data structures so maybe it's fine.

Where I do think Chat GPT is useful is if you just need to know how to do a certain thing since you just need to know the syntax, it's faster than googling it and landing on a bunch of forums that tell you to google it, or that ask in a condescending way why you don't do it another way, or that closed the question as a duplicate.
 

scorpmatt

Diamond Member
Feb 8, 2001
7,040
96
91
are you wanting to randomize the order of the words with the definitions attached or random order the words with random descriptions?
 

Red Squirrel

No Lifer
May 24, 2003
67,403
12,142
126
www.anyf.ca
If it's dead and I get bored enough at work on my weekend shift I might write a C++ program that can do it. I'm legit curious if I can make the entire database self contained into a single binary. I can't see why not, but I can't say I've ever tried to pack that much data into a single binary before. It might actually come in handy for another project I need to do where I have to translate data and there's millions of entries, but the data is static so I kinda don't want to have to use a database for it. This is kind of the same idea.
 

Gizmo j

Senior member
Nov 9, 2013
911
247
116
If it's dead and I get bored enough at work on my weekend shift I might write a C++ program that can do it. I'm legit curious if I can make the entire database self contained into a single binary. I can't see why not, but I can't say I've ever tried to pack that much data into a single binary before. It might actually come in handy for another project I need to do where I have to translate data and there's millions of entries, but the data is static so I kinda don't want to have to use a database for it. This is kind of the same idea.
I would rather it be from a pocket dictionary, those large dictionary's have a bunch of words nobody uses.