beasteers / randomname Goto Github PK
View Code? Open in Web Editor NEWGenerate random names (adj-noun) like docker and github.
License: MIT License
Generate random names (adj-noun) like docker and github.
License: MIT License
I would like to use names to label pattern recognition results, and would like to fit names into a fixed-width numpy recarray field. I can write a wrapper to repick until a name meets the length criteria, but would be nice if the api supported this functionality (and possibly more efficient if the lists themselves allowed drawing by length).
Thanks for this package!
Need to add sphinx rtd setup now that people are actually using it so they know how to use the interface
The command randomname.get_name()
returns a string of the form abcd-efgh
more than 99% of the time.
But, sometimes it returns a string of the form abcd-efgh-ijkl
. This can break some fragile workflows.
There are exactly two offending lines for the adj-noun
recipe:
https://github.com/imsky/wordlists/blob/b26782e929a288d55fae6f507760291b9367418d/nouns/food.txt#L40
https://github.com/imsky/wordlists/blob/cfee5df781890de614e8f634ed49ad853116ed35/adjectives/algorithms.txt#L20
I don't know whether it makes sense to ask for the change in the upstream repo, or to fix it here.
Would be suuuper nice to be able to change between other delimiters...like _ , ; : etc.
So an option flag...
randomname generate adj/ noun/ --delim=_
If you're busy I can probably work up a PR for it :)
Operating System: Windows 11 64 bit
PyInstaller Version: 4.8
Python Version: 3.8.5
Version of randomname:
> pip show randomname
Name: randomname
Version: 0.1.5
Summary: Generate random adj-noun names like docker and github.
Home-page: https://github.com/beasteers/randomname
Author: Bea Steers
Author-email: [email protected]
License: MIT License
Location: c:\users\sebastian\.conda\envs\editor\lib\site-packages
Requires: fire
Required-by:
I have an application which uses randomname
to create random file names.
The application is packaged into a .exe in Windows using PyInstaller.
When I run the application (as exe) I observe an application crash.
I have described the steps to reproduce the issue in this this git repository together with the source code, environment and pyinstaller packaging script.
Using the application I provided in this git repository I would expect the output to be something like this:
The name is natural-kitchen
If I run the file main.py
using python like this
python main.py
I do in fact get the desired output.
When I run the application (as exe) I observe an application crash. The console output is:
File "site-packages\randomname\core.py", line 13, in get_name
File "site-packages\randomname\core.py", line 7, in generate
File "site-packages\randomname\core.py", line 8, in <genexpr>
File "site-packages\randomname\util.py", line 208, in choose
File "random.py", line 290, in choice
I would like to get the same name repeatably for - say - an integer. Could the package accept a seed? Setting a seed globally may also be useful for testing.
Thank you for the package!
Hi @beasteers ,
thanks for putting up this library ๐ฏ
We at Rasa ran into some issues using randomname
in Windows as Windows uses different path separators than Unix based systems. We should probably rather use os.sep.
We ran into this error on Windows. We use the generated name as part of a filename and the generated name basically leads to an error then.
2021-09-22T16:07:05.6385808Z
2021-09-22T16:07:05.6386472Z self = <[AttributeError("'GzipFile' object has no attribute 'fileobj'") raised in repr()] GzipFile object at 0x2949e0733c8>
2021-09-22T16:07:05.6387698Z filename = WindowsPath('C:/Users/runneradmin/AppData/Local/Temp/pytest-of-runneradmin/pytest-0/popen-gw0/test_train_skip_on_model_not_changed0/models/20210922-160500_a')
2021-09-22T16:07:05.6388736Z mode = 'rb', compresslevel = 9, fileobj = None, mtime = None
2021-09-22T16:07:05.6389110Z
2021-09-22T16:07:05.6389511Z def __init__(self, filename=None, mode=None,
2021-09-22T16:07:05.6390122Z compresslevel=9, fileobj=None, mtime=None):
2021-09-22T16:07:05.6390708Z """Constructor for the GzipFile class.
2021-09-22T16:07:05.6391124Z
2021-09-22T16:07:05.6391578Z At least one of fileobj and filename must be given a
2021-09-22T16:07:05.6392098Z non-trivial value.
2021-09-22T16:07:05.6392442Z
2021-09-22T16:07:05.6392938Z The new class instance is based on fileobj, which can be a regular
2021-09-22T16:07:05.6393715Z file, an io.BytesIO object, or any other object which simulates a file.
2021-09-22T16:07:05.6394429Z It defaults to None, in which case filename is opened to provide
2021-09-22T16:07:05.6394961Z a file object.
2021-09-22T16:07:05.6395300Z
2021-09-22T16:07:05.6395772Z When fileobj is not None, the filename argument is only used to be
2021-09-22T16:07:05.6396456Z included in the gzip file header, which may include the original
2021-09-22T16:07:05.6397170Z filename of the uncompressed file. It defaults to the filename of
2021-09-22T16:07:05.6397928Z fileobj, if discernible; otherwise, it defaults to the empty string,
2021-09-22T16:07:05.6398658Z and in this case the original filename is not included in the header.
2021-09-22T16:07:05.6399159Z
2021-09-22T16:07:05.6399603Z The mode argument can be any of 'r', 'rb', 'a', 'ab', 'w', 'wb', 'x', or
2021-09-22T16:07:05.6400256Z 'xb' depending on whether the file will be read or written. The default
2021-09-22T16:07:05.6401190Z is the mode of fileobj if discernible; otherwise, the default is 'rb'.
2021-09-22T16:07:05.6401919Z A mode of 'r' is equivalent to one of 'rb', and similarly for 'w' and
2021-09-22T16:07:05.6402452Z 'wb', 'a' and 'ab', and 'x' and 'xb'.
2021-09-22T16:07:05.6402862Z
2021-09-22T16:07:05.6427124Z The compresslevel argument is an integer from 0 to 9 controlling the
2021-09-22T16:07:05.6428071Z level of compression; 1 is fastest and produces the least compression,
2021-09-22T16:07:05.6428904Z and 9 is slowest and produces the most compression. 0 is no compression
2021-09-22T16:07:05.6434135Z at all. The default is 9.
2021-09-22T16:07:05.6434799Z
2021-09-22T16:07:05.6435322Z The mtime argument is an optional numeric timestamp to be written
2021-09-22T16:07:05.6436097Z to the last modification time field in the stream when compressing.
2021-09-22T16:07:05.6436800Z If omitted or None, the current time is used.
2021-09-22T16:07:05.6437262Z
2021-09-22T16:07:05.6437602Z """
2021-09-22T16:07:05.6437938Z
2021-09-22T16:07:05.6438333Z if mode and ('t' in mode or 'U' in mode):
2021-09-22T16:07:05.6438944Z raise ValueError("Invalid mode: {!r}".format(mode))
2021-09-22T16:07:05.6439569Z if mode and 'b' not in mode:
2021-09-22T16:07:05.6440006Z mode += 'b'
2021-09-22T16:07:05.6440420Z if fileobj is None:
2021-09-22T16:07:05.6441038Z > fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')
2021-09-22T16:07:05.6442494Z E PermissionError: [Errno 13] Permission denied: 'C:\\Users\\runneradmin\\AppData\\Local\\Temp\\pytest-of-runneradmin\\pytest-0\\popen-gw0\\test_train_skip_on_model_not_changed0\\models\\20210922-160500_a'
2021-09-22T16:07:05.6443411Z
Happy to put up a PR and maybe a small GitHub actions (it's free on OpenSource) based CI for Linux / Ubuntu if you want?
It'd be nice, say if someone had a word corpus of their own, to be able do register them
import randomname
# add from file
randomname.register('my/directory/of/lists') # recursively find .txt files
randomname.register('my/directory/of/lists', ext=['.txt', '.list', '.blah']) # add your extensions
randomname.register('my/directory/of/lists', loader=lambda f: open(f, 'r').split(',')) # custom loader? idk
# add literal lists
randomname.register({
'nouns/things': ['something', 'nothing', ...]
})
I think doing this might benefit from some refactoring, but we'll see. I definitely don't want to over-complicate this project.
Specific sources to potentially parse and include:
It would be great to release a version and also show the chance of generating the same combination.
I'm sure there are words that people don't like/don't want to show up. We should allow users to exclude certain words, or patterns. Perhaps even just having filters that allow arbitrary exclusions (no words with more than 9 characters?) idk
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.