Skip to content

Commit

Permalink
Update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
devicemanager authored May 31, 2022
1 parent 24d87c5 commit 930d2f4
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,48 @@
Generate random names for testing purposes
#Generate random names for testing purposes

I have created a small project from the data that grabs names from wiktionary, there are quite some resources like:

https://github.com/ErikGartner/randy.git
https://github.com/originpath/docker-openldap-rbac.git
https://github.com/roninkelt/rpgx_playing.git

I'm sure you are able to find the original wiktionary scraper better then me right now.

I have created a small project from the data that grabs names from wiktionary (ref).
The result can be parsed in java, bash, sql, etc.

The schema is very simple and can easily be extended:

The output from .schema
```
CREATE TABLE surnames (
surname TEXT not null);
CREATE TABLE males (
male TEXT not null);
CREATE TABLE females (
female TEXT not null);
```

The import of the different tables was also very simple:

```
.mode csv
.import Female_given_names.txt females
.import Male_given_names.txt males
.import Surnames.txt surnames
```

A few examples:

```
sqlite names.db "select male from males order by random() limit 1;"

```
```
sqlite3 names.db "select female from females order by random() limit 1;"

```
```
sqlite3 names.db "select female,surname from (select female from females order by random() limit 1) join (select surname from surnames order by random() limit 1);"
```

A very small standalone java main class has been created to parse the file and output one random record to stdout:
```
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
Expand Down Expand Up @@ -65,12 +79,13 @@ public class Names
}
}
}
```

Also the compilation is simple and has been done in a script together with an example of how you could use it:

```
javac Names.java
while true;do java Names Female_given_names.txt| tr '\n' ' ';java Names ; done

```
Since the command creates a linefeed on stdout, this is simply translated to a space. You could also translate it to a comma by replacing the last argument in the tr command.

I hope you find this project usefull an if you do I would like to get some feedback on how you use this and also if you have extended this, I would like to get a PR for a richer experience.

0 comments on commit 930d2f4

Please sign in to comment.