Spaces:
Build error
Build error
File size: 2,857 Bytes
8c2f469 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
import json
import random
conditions = [
"Hypertension", "Diabetes", "Asthma", "Arthritis", "Depression",
"Anxiety", "Obesity", "Migraine", "Allergies", "Influenza"
]
medications = [
"Lisinopril", "Metformin", "Albuterol", "Ibuprofen", "Sertraline",
"Alprazolam", "Orlistat", "Sumatriptan", "Cetirizine", "Oseltamivir"
]
def generate_question(condition):
questions = [
f"What are the symptoms of {condition}?",
f"How is {condition} typically diagnosed?",
f"What are the common treatments for {condition}?",
f"Can you explain the causes of {condition}?",
f"What lifestyle changes can help manage {condition}?",
f"Are there any complications associated with {condition}?",
f"How can {condition} be prevented?",
f"What's the long-term outlook for someone with {condition}?",
f"Are there any new treatments being developed for {condition}?",
f"How does {condition} affect daily life?"
]
return random.choice(questions)
# Function to generate an answer (simplified for this example)
def generate_answer(condition, question):
return f"Here's some information about {condition} related to your question: '{question}' [Detailed medical explanation would go here.]"
# Function to generate a medication question
def generate_medication_question(medication):
questions = [
f"What is {medication} used for?",
f"What are the common side effects of {medication}?",
f"How should {medication} be taken?",
f"Are there any drug interactions with {medication}?",
f"What should I know before starting {medication}?",
f"How long does it take for {medication} to start working?",
f"Can {medication} be taken during pregnancy?",
f"What should I do if I miss a dose of {medication}?",
f"Is {medication} habit-forming?",
f"Are there any alternatives to {medication}?"
]
return random.choice(questions)
def generate_medication_answer(medication, question):
return f"Regarding {medication} and your question: '{question}' [Detailed medication information would go here.]"
dataset = []
for _ in range(5000):
if random.choice([True, False]):
condition = random.choice(conditions)
question = generate_question(condition)
answer = generate_answer(condition, question)
else:
medication = random.choice(medications)
question = generate_medication_question(medication)
answer = generate_medication_answer(medication, question)
dataset.append({
"question": question,
"answer": answer,
"text": f"Question: {question}\nAnswer: {answer}"
})
with open("medical_dataset.json", "w") as f:
json.dump(dataset, f, indent=2)
print("Dataset generated and saved to medical_dataset.json") |