"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 7
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "output_path = \"/content/AHD_english_cleaned.xlsx\"\n",
+ "\n",
+ "df.to_excel(\n",
+ " output_path,\n",
+ " index=False,\n",
+ " engine=\"openpyxl\"\n",
+ ")\n",
+ "\n",
+ "print(f\"Saved successfully: {output_path}\")"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "A1fpPvP15YjW",
+ "outputId": "2f001e15-e77e-4a0b-f612-3b3c6e402fa9"
+ },
+ "execution_count": 8,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Saved successfully: /content/AHD_english_cleaned.xlsx\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "df"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 424
+ },
+ "id": "15Sce7j7mMFg",
+ "outputId": "700cdae7-2d8d-4f2c-ca18-6736bcff5a04"
+ },
+ "execution_count": 9,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ " Question \\\n",
+ "6629 If the patient enters a diabetic coma and we d... \n",
+ "12015 I suffer from dizziness and my blood sugar lev... \n",
+ "14653 I am diabetic 2. I take Amaryl 2 ml before foo... \n",
+ "15283 Age 54, normal blood pressure, weight 74, heig... \n",
+ "20096 When I test my blood sugar after fasting for 7... \n",
+ "... ... \n",
+ "808249 Can hirsutism be an obstacle to pregnancy sinc... \n",
+ "808332 In the name of God, the most gracious, the mos... \n",
+ "808335 I have a sister who suffers from hyperthyroidi... \n",
+ "808336 I was on duty at the hospital when a woman cam... \n",
+ "808350 Does a mild deficiency in the hormone thyroxin... \n",
+ "\n",
+ " Answer Category \n",
+ "6629 Hyperglycemic coma does not occur suddenly, bu... diabetes \n",
+ "12015 Your safety, God willing. It may be normal due... diabetes \n",
+ "14653 Glycosylated hemoglobin analysis is very impor... diabetes \n",
+ "15283 Who told you that taking B12 is not according ... diabetes \n",
+ "20096 Monitor your blood sugar in a laboratory, not ... diabetes \n",
+ "... ... ... \n",
+ "808249 Hirsutism can be a cause of contraception, but... Endocrine diseases \n",
+ "808332 What you mentioned in your question constitute... Endocrine diseases \n",
+ "808335 This medicine should not be used during pregna... Endocrine diseases \n",
+ "808336 The condition goes away with the use of birth ... Endocrine diseases \n",
+ "808350 This is easy to find out by giving the infant ... Endocrine diseases \n",
+ "\n",
+ "[16384 rows x 3 columns]"
+ ],
+ "text/html": [
+ "\n",
+ "
\n"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "dataframe",
+ "variable_name": "df",
+ "summary": "{\n \"name\": \"df\",\n \"rows\": 16384,\n \"fields\": [\n {\n \"column\": \"Question\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 16269,\n \"samples\": [\n \"I have been suffering from diabetes for five years. The test while fasting was 110, and two hours after eating, it was 170. I use Dawinil medication, half a pill in the morning, 2.5 mg, and half a pill in the evening. Is my condition satisfactory or do I need...\",\n \"What is the recommended percentage of thyroxine for a pregnant woman in the fifth month, noting that the current dose is 75, and the test included a TSH of 4.79?\",\n \"Girl, I am 23 years old, my weight is 64, and my height is 158\\nI feel dizzy and unfocused. Blood tests are fine. Sugar tests after eating and throughout the day are less than 100 and may reach 90.\\nAnd in case...\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Answer\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 15419,\n \"samples\": [\n \"It does not require treatment if it is not accompanied by symptoms, a\",\n \"Of course, one of the reasons is pregnancy hormones, which require raising the insulin dose from time to time. The rest of the reasons: insufficient dose or failure to adhere to the diet. In any case, the evening dose must be increased by two units.\",\n \"The treatment for high parathyroid hormone is surgery if the cause is in the glands themselves. Tests can be sent. See my article about the parathyroid glands\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Category\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"Endocrine diseases\",\n \"diabetes\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
+ }
+ },
+ "metadata": {},
+ "execution_count": 9
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "df.info()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "gDCn391gv0NS",
+ "outputId": "9e144699-0f8b-4a72-b6a7-8b564d80a318"
+ },
+ "execution_count": 10,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "\n",
+ "Index: 16384 entries, 6629 to 808350\n",
+ "Data columns (total 3 columns):\n",
+ " # Column Non-Null Count Dtype \n",
+ "--- ------ -------------- ----- \n",
+ " 0 Question 16384 non-null object\n",
+ " 1 Answer 16384 non-null object\n",
+ " 2 Category 16384 non-null object\n",
+ "dtypes: object(3)\n",
+ "memory usage: 512.0+ KB\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "df.isnull().sum()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 178
+ },
+ "id": "cKTQzpX7v_Yk",
+ "outputId": "64fc484a-2086-4c5b-8d6a-6a429157b9cf"
+ },
+ "execution_count": 11,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "Question 0\n",
+ "Answer 0\n",
+ "Category 0\n",
+ "dtype: int64"
+ ],
+ "text/html": [
+ "
"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 13
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "question_counts = df[\"Question\"].value_counts()\n",
+ "\n",
+ "print(question_counts.head(30))"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "XQZ_I7HYxNYV",
+ "outputId": "030ff975-0711-46f4-b693-0167353e81a6"
+ },
+ "execution_count": 14,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Question\n",
+ "What are the symptoms of diabetes? 19\n",
+ "What is the treatment for diabetes? 10\n",
+ "Is there a cure for diabetes? 7\n",
+ "Symptoms of diabetes 5\n",
+ "What is the normal blood sugar level? 5\n",
+ "What is the best treatment for diabetes? 3\n",
+ "What is the treatment for low blood sugar? 3\n",
+ "What are the causes of diabetes? 3\n",
+ "The best treatment for diabetes 3\n",
+ "Thyroid symptoms 3\n",
+ "What are the symptoms of thyroid disease? 3\n",
+ "Is there a definitive cure for diabetes? 3\n",
+ "I suffer from an underactive thyroid gland 3\n",
+ "What is the treatment for hypothyroidism? 3\n",
+ "What are the symptoms of thyroid gland? 3\n",
+ "The latest treatment for diabetes 3\n",
+ "What is the treatment for thyroid gland? 3\n",
+ "What is diabetic foot? 2\n",
+ "I have been suffering from cancer for a while and recently a diabetic patient. Is there a relationship between the two? What I read is that blood sugar is high in a cancer patient, but the opposite happens and blood sugar is low and... 2\n",
+ "A cumulative blood sugar test 3 months ago was 6.3, and my weight at the time was 117, and today the result of the test is 5.3, and I have lost 20 kilograms. Does this mean that I have passed the pre-diabetic stage and have become a normal person? 2\n",
+ "How do I know that I have diabetes? 2\n",
+ "What foods are beneficial for diabetics? 2\n",
+ "What are the most important causes of diabetes? 2\n",
+ "Causes of diabetes 2\n",
+ "What is the treatment for parotitis? 2\n",
+ "Symptoms of high blood sugar 2\n",
+ "What are the symptoms of gestational diabetes? 2\n",
+ "What are normal blood sugar levels? 2\n",
+ "What are the most important risk factors for developing type 1 diabetes? 2\n",
+ "Peace be upon you. When I was 19 years old, I was treated for hypothyroidism. I took the medication leyvotirox50. Now my TSH is moderate. Now I am pregnant. I follow up with the endocrinologist. My questions... 2\n",
+ "Name: count, dtype: int64\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "question = \"What are the symptoms of diabetes?\"\n",
+ "\n",
+ "result = df[df[\"Question\"] == question]\n",
+ "result = pd.DataFrame(result)\n",
+ "print(result[[\"Question\", \"Answer\", \"Category\"]].to_string(index=False))"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "eK5XFQBhyHFK",
+ "outputId": "f8ebf0b5-95c1-4dca-97e4-e2bdfbda22d9"
+ },
+ "execution_count": 15,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ " Question Answer Category\n",
+ "What are the symptoms of diabetes? The most important symptoms are frequent urination and excessive thirst. For more information, see diabetes in the dictionary. diabetes\n",
+ "What are the symptoms of diabetes? Weight loss, laziness, lethargy, frequent urination, thirst, dullness in the eyes, and pain in the body diabetes\n",
+ "What are the symptoms of diabetes? Diabetes in adults is usually non-specific and insidious, and its most important symptoms are: fatigue, fatigue, weight loss, frequent urination, especially at night, thirst, and difficulty healing boils. Sometimes it is not accidental.\\nBut in children and young adults, it comes on quickly over several days to a few weeks: day and night polyuria. Polydipsia and dry mouth. Good appetite . weight loss . Fatigue and exhaustion. The injured person may experience an emergency condition and be admitted to the hospital immediately diabetes\n",
+ "What are the symptoms of diabetes? Drink plenty of water\\nFrequent urination\\nFeeling hungry diabetes\n",
+ "What are the symptoms of diabetes? It is not necessary to have symptoms to diagnose the disease, and if they do exist, the most important of them is increased thirst and urination diabetes\n",
+ "What are the symptoms of diabetes? Symptoms of diabetes include frequent urination at night, increased thirst, and a sudden decrease in body weight diabetes\n",
+ "What are the symptoms of diabetes? There are not necessarily symptoms, the most important of which, if present, is an increase in thirst and urination diabetes\n",
+ "What are the symptoms of diabetes? A lot of urine\\nFrequent thirst\\nweight loss\\nIt may be asymptomatic diabetes\n",
+ "What are the symptoms of diabetes? There are many symptoms of diabetes, the most important of which are thirst, frequent urination, increased appetite for food, sometimes hunger, itchy skin, general weakness. diabetes\n",
+ "What are the symptoms of diabetes? The most common symptoms of diabetes are excessive diarrhea, frequent urination, and feeling hungry\\nThere are other less prominent symptoms, such as blurred vision, a feeling of weakness, leg pain, delayed wound healing, and itching.\\nHere it must be noted that there is a large difference in the appearance and severity of these symptoms between patients and according to the type of diabetes. Some symptoms may be completely absent, or they may be minor and do not attract the attention of the affected person, and thus diagnosis is delayed.\\nDue to the widespread spread of diabetes, a group of factors called risk factors have been identified, such as obesity, lack of physical activity, and a history of diabetes in the family. When these factors are present, blood sugar is analyzed even in the absence of the symptoms mentioned. See Diabetes in the dictionary.\\nmy regards diabetes\n",
+ "What are the symptoms of diabetes? Symptoms do not necessarily exist, but if they do, they include thirst and increased urination diabetes\n",
+ "What are the symptoms of diabetes? Symptoms do not necessarily exist, and if they do exist, the most important of them is an increase in thirst and urination diabetes\n",
+ "What are the symptoms of diabetes? There may be no symptoms, but weight loss, frequent urination, teeth loss, and recurring infections may be symptoms. diabetes\n",
+ "What are the symptoms of diabetes? Increased thirst and urination diabetes\n",
+ "What are the symptoms of diabetes? Signs and symptoms of type 1 diabetes (insulin-dependent) appear gradually or suddenly, as follows: - Frequent urination. - Excessive thirst. - Weight loss . - Fatigue. - Excessive appetite. - Nausea. - Blurred vision.\\nAs for type 2 diabetes (non-insulin dependent), signs and symptoms of type 2 diabetes do not appear in its early stages, but they may appear in some people as follows: - Frequent urination. - Excessive thirst. - Excessive appetite. - Weight loss . - Blurred vision. - Paresthesias and tingling of the lower extremities. - Fungal infection. - Fatigue and general weakness. diabetes\n",
+ "What are the symptoms of diabetes? A person may develop diabetes and remain for a long period of time, which may extend to years, without paying attention to any symptoms, because these symptoms may be attributed to other causes. At the beginning of type 2 diabetes, the patient feels non-specific weakness and may suffer from pain of nerve origin in the extremities, and Wound healing may be delayed, and his appetite may remain normal or increase slightly\\nWhen the infection worsens, specific symptoms appear, which are frequent hunger, lack of feeling of fullness, extreme thirst, and frequent urination. In addition, the feeling of weakness, lethargy, nerve pain, delayed wound healing, and common infections such as the common cold increase.\\nStudies have shown that vascular damage that leads to chronic cardiovascular disease begins before any symptoms of diabetes appear and even before there is a sufficient rise in blood sugar to diagnose the disease, that is, the damage begins in the pre-diabetic stage.\\nFor this reason, the risk factors that may be followed by diabetes have been identified, and these factors include a history of diabetes in the family, especially among first-degree relatives, weight gain, age over 40 years, high blood pressure, multiple births, and other factors.\\nTherefore, the best way to detect diabetes is to test your blood sugar periodically and not rely on symptoms\\nmy regards\\n, diabetes\n",
+ "What are the symptoms of diabetes? Classic symptoms include feeling tired and sick, frequent urination, excessive thirst, excessive hunger, and weight loss.\\nKetoacidosis, a condition caused by starvation or uncontrolled diabetes, is common in type 1 diabetes. Ketones are acidic compounds that form in the blood when the body breaks down fats, lipids, and proteins. Symptoms include abdominal pain, vomiting, rapid breathing, extreme lethargy, and drowsiness. Patients with ketoacidosis have a sweet-smelling breath. If this is not treated, it can lead to coma and death.\\nWith type 2 diabetes, the condition may not become clear until the patient is offered medical treatment for another disease. The patient may complain of heart disease, chronic infection of the gums and urinary tract, and blurred vision. Women may complain of itching in the genitals.\\nSee diabetes in the dictionary. diabetes\n",
+ "What are the symptoms of diabetes? Classic symptoms include feeling tired and sick, frequent urination, excessive thirst, excessive hunger, and weight loss.\\nKetoacidosis, a condition caused by starvation or uncontrolled diabetes, is common in type 1 diabetes. Ketones are acidic compounds that form in the blood when the body breaks down fats, lipids, and proteins. Symptoms include abdominal pain, vomiting, rapid breathing, extreme lethargy, and drowsiness. Patients with ketoacidosis have a sweet-smelling breath. If this is not treated, it can lead to coma and death.\\nSee sugar in the dictionary.\\nWith type 2 diabetes, the condition may not become clear until the patient is offered medical treatment for another disease. The patient may complain of heart disease, chronic infection of the gums and urinary tract, and blurred vision. Women may complain of itching in the genitals. diabetes\n",
+ "What are the symptoms of diabetes? Classic symptoms include feeling tired and sick, frequent urination, excessive thirst, excessive hunger, and weight loss.\\nKetoacidosis, a condition caused by starvation or uncontrolled diabetes, is common in type 1 diabetes. Ketones are acidic compounds that form in the blood when the body breaks down fats, lipids, and proteins. Symptoms include abdominal pain, vomiting, rapid breathing, extreme lethargy, and drowsiness. Patients with ketoacidosis have a sweet-smelling breath. If this is not treated, it can lead to coma and death.\\nWith type 2 diabetes, the condition may not become clear until the patient is offered medical treatment for another disease. The patient may complain of heart disease, chronic infection of the gums and urinary tract, and blurred vision. Women may complain of itching in the genitals. See diabetes in the dictionary. diabetes\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "df = df.dropna(subset=[\"Question\", \"Answer\"])"
+ ],
+ "metadata": {
+ "id": "aRN4g2Au1Wav"
+ },
+ "execution_count": 16,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "df[\"Question\"] = df[\"Question\"].astype(str).str.strip()\n",
+ "df[\"Answer\"] = df[\"Answer\"].astype(str).str.strip()\n",
+ "df[\"Category\"] = df[\"Category\"].astype(str).str.strip()"
+ ],
+ "metadata": {
+ "id": "_ahuAy-O2GUw"
+ },
+ "execution_count": 17,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "df"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 424
+ },
+ "id": "unFePQgr2P0m",
+ "outputId": "50ad1cdf-1cbe-4e44-9825-c90572fa3cd4"
+ },
+ "execution_count": 18,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ " Question \\\n",
+ "6629 If the patient enters a diabetic coma and we d... \n",
+ "12015 I suffer from dizziness and my blood sugar lev... \n",
+ "14653 I am diabetic 2. I take Amaryl 2 ml before foo... \n",
+ "15283 Age 54, normal blood pressure, weight 74, heig... \n",
+ "20096 When I test my blood sugar after fasting for 7... \n",
+ "... ... \n",
+ "808249 Can hirsutism be an obstacle to pregnancy sinc... \n",
+ "808332 In the name of God, the most gracious, the mos... \n",
+ "808335 I have a sister who suffers from hyperthyroidi... \n",
+ "808336 I was on duty at the hospital when a woman cam... \n",
+ "808350 Does a mild deficiency in the hormone thyroxin... \n",
+ "\n",
+ " Answer Category \n",
+ "6629 Hyperglycemic coma does not occur suddenly, bu... diabetes \n",
+ "12015 Your safety, God willing. It may be normal due... diabetes \n",
+ "14653 Glycosylated hemoglobin analysis is very impor... diabetes \n",
+ "15283 Who told you that taking B12 is not according ... diabetes \n",
+ "20096 Monitor your blood sugar in a laboratory, not ... diabetes \n",
+ "... ... ... \n",
+ "808249 Hirsutism can be a cause of contraception, but... Endocrine diseases \n",
+ "808332 What you mentioned in your question constitute... Endocrine diseases \n",
+ "808335 This medicine should not be used during pregna... Endocrine diseases \n",
+ "808336 The condition goes away with the use of birth ... Endocrine diseases \n",
+ "808350 This is easy to find out by giving the infant ... Endocrine diseases \n",
+ "\n",
+ "[16384 rows x 3 columns]"
+ ],
+ "text/html": [
+ "\n",
+ "
\n"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "dataframe",
+ "variable_name": "df",
+ "summary": "{\n \"name\": \"df\",\n \"rows\": 16384,\n \"fields\": [\n {\n \"column\": \"Question\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 16269,\n \"samples\": [\n \"I have been suffering from diabetes for five years. The test while fasting was 110, and two hours after eating, it was 170. I use Dawinil medication, half a pill in the morning, 2.5 mg, and half a pill in the evening. Is my condition satisfactory or do I need...\",\n \"What is the recommended percentage of thyroxine for a pregnant woman in the fifth month, noting that the current dose is 75, and the test included a TSH of 4.79?\",\n \"Girl, I am 23 years old, my weight is 64, and my height is 158\\nI feel dizzy and unfocused. Blood tests are fine. Sugar tests after eating and throughout the day are less than 100 and may reach 90.\\nAnd in case...\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Answer\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 15419,\n \"samples\": [\n \"It does not require treatment if it is not accompanied by symptoms, a\",\n \"Of course, one of the reasons is pregnancy hormones, which require raising the insulin dose from time to time. The rest of the reasons: insufficient dose or failure to adhere to the diet. In any case, the evening dose must be increased by two units.\",\n \"The treatment for high parathyroid hormone is surgery if the cause is in the glands themselves. Tests can be sent. See my article about the parathyroid glands\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Category\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"Endocrine diseases\",\n \"diabetes\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
+ }
+ },
+ "metadata": {},
+ "execution_count": 18
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "df.duplicated().sum()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "h4ZXp9i-2RuG",
+ "outputId": "cef14668-b12d-4569-dc08-0fbf2d69afef"
+ },
+ "execution_count": 19,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "np.int64(8)"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 19
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "duplicates = df[df.duplicated(keep=False)]\n",
+ "\n",
+ "print(duplicates.to_string(index=False))"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "KJlgQddugd2w",
+ "outputId": "c06fbd6f-d51d-45df-a8b8-72e423cf5193"
+ },
+ "execution_count": 20,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ " Question Answer Category\n",
+ " Diabetes treatment This requires an integrated nutritional and therapeutic system under the supervision of the treating physician diabetes\n",
+ " Diabetes treatment This requires an integrated nutritional and therapeutic system under the supervision of the treating physician diabetes\n",
+ " The best treatment for diabetes This requires an integrated nutritional and therapeutic system under the supervision of the treating physician diabetes\n",
+ " Useful fruit for diabetics Moderation in food is the basis of treatment diabetes\n",
+ " Useful fruit for diabetics Moderation in food is the basis of treatment diabetes\n",
+ " What is the treatment for high blood sugar? This requires an integrated nutritional and therapeutic system under the supervision of the treating physician diabetes\n",
+ " The best treatment for diabetes This requires an integrated nutritional and therapeutic system under the supervision of the treating physician diabetes\n",
+ " What is the treatment for high blood sugar? This requires an integrated nutritional and therapeutic system under the supervision of the treating physician diabetes\n",
+ " What is the normal blood sugar level? Fasting, less than 100 and two hours after eating, less than 140 diabetes\n",
+ " What is the normal blood sugar level? Fasting, less than 100 and two hours after eating, less than 140 diabetes\n",
+ " I used metformin to lose weight for four months. I was eating normally and I lost weight. I was increasing the dose up to 2000, but I feel that its effect is decreasing and the body has become resistant to it. What is the explanation for that? Basically, you should reduce the amount of food you eat diabetes\n",
+ " I used metformin to lose weight for four months. I was eating normally and I lost weight. I was increasing the dose up to 2000, but I feel that its effect is decreasing and the body has become resistant to it. What is the explanation for that? Basically, you should reduce the amount of food you eat diabetes\n",
+ " My wife got pregnant after 9 months, knowing that I have been diabetic for 15 years and I am 35. I was treated with vitamin E for a period of time for my disease to affect pregnancy, and it took place after giving birth. The better your blood sugar control is, the more you will maintain the functions of your body’s organs, including sexual function\\nA person with diabetes can marry and have children. Statistics may indicate lower chances of childbearing, but statistics are worthless when each case is evaluated individually.\\nmy regards diabetes\n",
+ " My wife got pregnant after 9 months, knowing that I have been diabetic for 15 years and I am 35. I was treated with vitamin E for a period of time for my disease to affect pregnancy, and it took place after giving birth. The better your blood sugar control is, the more you will maintain the functions of your body’s organs, including sexual function\\nA person with diabetes can marry and have children. Statistics may indicate lower chances of childbearing, but statistics are worthless when each case is evaluated individually.\\nmy regards diabetes\n",
+ "A cumulative blood sugar test 3 months ago was 6.3, and my weight at the time was 117, and today the result of the test is 5.3, and I have lost 20 kilograms. Does this mean that I have passed the pre-diabetic stage and have become a normal person? Yes, I have passed the pre-diabetic stage. Persevere in losing weight Endocrine diseases\n",
+ "A cumulative blood sugar test 3 months ago was 6.3, and my weight at the time was 117, and today the result of the test is 5.3, and I have lost 20 kilograms. Does this mean that I have passed the pre-diabetic stage and have become a normal person? Yes, I have passed the pre-diabetic stage. Persevere in losing weight Endocrine diseases\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "df.drop_duplicates(inplace=True)"
+ ],
+ "metadata": {
+ "id": "3H3OtR-Jgpjy"
+ },
+ "execution_count": 21,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "def clean_text(text):\n",
+ " if pd.isna(text):\n",
+ " return \"\"\n",
+ "\n",
+ " text = str(text)\n",
+ "\n",
+ " # Normalize Unicode\n",
+ " text = unicodedata.normalize(\"NFKC\", text)\n",
+ "\n",
+ " # Replace escaped newlines/tabs\n",
+ " text = text.replace(\"\\\\n\", \" \")\n",
+ " text = text.replace(\"\\\\t\", \" \")\n",
+ "\n",
+ " # Replace real newlines and tabs with spaces\n",
+ " text = re.sub(r\"[\\r\\n\\t]+\", \" \", text)\n",
+ "\n",
+ " # Remove control characters\n",
+ " text = \"\".join(\n",
+ " char for char in text\n",
+ " if unicodedata.category(char) not in [\"Cc\", \"Cf\"]\n",
+ " or char in [\"\\n\", \"\\t\"]\n",
+ " )\n",
+ "\n",
+ " # Normalize different quotation marks\n",
+ " text = text.replace(\"“\", '\"')\n",
+ " text = text.replace(\"”\", '\"')\n",
+ " text = text.replace(\"‘\", \"'\")\n",
+ " text = text.replace(\"’\", \"'\")\n",
+ "\n",
+ " # Normalize multiple spaces\n",
+ " text = re.sub(r\"\\s+\", \" \", text)\n",
+ "\n",
+ " # Remove spaces before punctuation\n",
+ " text = re.sub(r\"\\s+([,.!?;:])\", r\"\\1\", text)\n",
+ "\n",
+ " # Remove spaces around parentheses\n",
+ " text = re.sub(r\"\\(\\s+\", \"(\", text)\n",
+ " text = re.sub(r\"\\s+\\)\", \")\", text)\n",
+ "\n",
+ " return text.strip()"
+ ],
+ "metadata": {
+ "id": "pPhOIUG42aT8"
+ },
+ "execution_count": 22,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "df[\"Question\"] = df[\"Question\"].apply(clean_text)\n",
+ "df[\"Answer\"] = df[\"Answer\"].apply(clean_text)\n",
+ "df[\"Category\"] = df[\"Category\"].apply(clean_text)"
+ ],
+ "metadata": {
+ "id": "2yrmGHPC46E2"
+ },
+ "execution_count": 127,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [],
+ "metadata": {
+ "id": "BbWaNc6wgeQu"
+ },
+ "execution_count": null,
+ "outputs": []
+ }
+ ]
+}
\ No newline at end of file