feat: initial commit
This commit is contained in:
42
pyrpg.py
Normal file
42
pyrpg.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import nltk
|
||||
import sys
|
||||
import random
|
||||
import os
|
||||
|
||||
def main():
|
||||
try:
|
||||
num_pseudonyms = int(sys.argv[1]) if len(sys.argv) == 2 else 100
|
||||
except ValueError:
|
||||
print("The argument must be an integer.")
|
||||
return
|
||||
|
||||
# Load the corpora
|
||||
nltk.download('wordnet')
|
||||
nltk.download('averaged_perceptron_tagger')
|
||||
nltk.download('universal_tagset')
|
||||
|
||||
# Get all the adjectives and nouns
|
||||
adjectives = set()
|
||||
nouns = set()
|
||||
for synset in nltk.corpus.wordnet.all_synsets():
|
||||
for lemma in synset.lemmas():
|
||||
if lemma.name().isalpha():
|
||||
if synset.pos() == 'a':
|
||||
adjectives.add(lemma.name())
|
||||
elif synset.pos() == 'n':
|
||||
nouns.add(lemma.name())
|
||||
|
||||
# Create the output directory if it doesn't exist
|
||||
os.makedirs('out', exist_ok=True)
|
||||
|
||||
# Write the pseudonyms to a file
|
||||
with open('out/pseudonyms.txt', 'w+') as file:
|
||||
for _ in range(num_pseudonyms):
|
||||
adjective = list(adjectives)[random.randint(0, len(adjectives) - 1)].capitalize()
|
||||
noun = list(nouns)[random.randint(0, len(nouns) - 1)].capitalize()
|
||||
number = random.randint(1, 999)
|
||||
pseudonym = f'{adjective}-{noun}-{number}'
|
||||
file.write(pseudonym + '\n')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user