«P-Zombie» — это лингвистическая программа, написанная мной для Python, которая автоматизирует метафизический процесс: по сути, виртуальный философ без сознательных способностей.
Бесчисленное количество способов, которыми я использовал этот скрипт для учебы, бесконечное количество вариантов использования, которые я мог придумать, и просто общее желание поделиться чем-то полезным с моими друзьями; все это привело меня к публикации кода с открытым исходным кодом для всех, кто заинтересован.
import random import spacy #install spaCy using pip: 'pip install spacy' (in terminal) # Set up the NLP toolkit nlp = spacy.load(en_core_web_sm") # Define a list of quotes QUOTES = [ “”, “”, ] # Define a list of philosophical propositions PROPOSITIONS = [ “”, “”, ] # Define a list of arguments for and against each proposition ARGUMENTS = { “”: [ “For:”, “Against:”, ], } # Define a function to generate a random quote def generate_quote(): return random.choice(QUOTES) random_quote = random.choice(QUOTES) # Define a function to generate a philosophical argument for a random proposition def generate_philosophical_argument(): proposition = random.choice(PROPOSITIONS) arguments = ARGUMENTS.get(proposition, []) if not arguments: # If there are no predefined arguments for the proposition, generate them using NLP *patch* arguments = generate_arguments(proposition) return proposition, random.choice(arguments) print(generate_philosophical_argument()) # Define a function to generate a distilled two-word statement for a random quote def generate_logic(random_quote): doc = nlp(random_quote) for token in doc: if token.dep_ == “ROOT”: subject = token.head.text verb = token obj = “” for child in token.children: if child.dep_ == “dob”: obj = child.text return f”{subject} {verb.lemma_} {obj}” return “” # Generate two-word statement and print w/quote for quote in QUOTES: logic = generate_logic(random_quote) print(random_quote) print(logic)
Вывод консоли должен выглядеть примерно так (в зависимости от ваших входных данных):
(‘Do we have free will?’, ‘Against: Our choices are determined by factors beyond our control, such as genetics and environment, and therefore free will is an illusion.’) The greatest wealth is to live content with a steady stream of memes. is be ...