diff --git a/README.md b/README.md
index 03c52be..6a9f783 100644
--- a/README.md
+++ b/README.md
@@ -22,4 +22,7 @@ Eingabe Ausgabe
\Iac{ecu} A ECU
\acused{ecu}
\acsu{ecu} ECU
-\aclu{ecu} European currency unit
\ No newline at end of file
+\aclu{ecu} European currency unit
+
+
+https://www.kaggle.com/datasets/lakritidis/product-classification-and-categorization
\ No newline at end of file
diff --git a/fetchDatafromDb/getProductDetails.ipynb b/fetchDatafromDb/getProductDetails.ipynb
index 54d91f5..d8916f5 100644
--- a/fetchDatafromDb/getProductDetails.ipynb
+++ b/fetchDatafromDb/getProductDetails.ipynb
@@ -1,5 +1,43 @@
{
"cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 54,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "15865.52s - pydevd: Sending message related to process being replaced timed-out after 5 seconds\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Defaulting to user installation because normal site-packages is not writeable\n",
+ "Collecting scikit-learn\n",
+ " Downloading scikit_learn-1.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.6 MB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m9.6/9.6 MB\u001b[0m \u001b[31m3.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n",
+ "\u001b[?25hRequirement already satisfied: numpy>=1.17.3 in /home/shoney/.local/lib/python3.10/site-packages (from scikit-learn) (1.24.3)\n",
+ "Collecting scipy>=1.3.2\n",
+ " Downloading scipy-1.10.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (34.4 MB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m34.4/34.4 MB\u001b[0m \u001b[31m6.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
+ "\u001b[?25hCollecting joblib>=1.1.1\n",
+ " Downloading joblib-1.2.0-py3-none-any.whl (297 kB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m298.0/298.0 KB\u001b[0m \u001b[31m6.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n",
+ "\u001b[?25hCollecting threadpoolctl>=2.0.0\n",
+ " Downloading threadpoolctl-3.1.0-py3-none-any.whl (14 kB)\n",
+ "Installing collected packages: threadpoolctl, scipy, joblib, scikit-learn\n",
+ "Successfully installed joblib-1.2.0 scikit-learn-1.2.2 scipy-1.10.1 threadpoolctl-3.1.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "!python3 -m pip install scikit-learn"
+ ]
+ },
{
"cell_type": "code",
"execution_count": 1,
@@ -53,26 +91,44 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 55,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "ename": "ModuleNotFoundError",
+ "evalue": "No module named 'seaborn'",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
+ "Cell \u001b[0;32mIn[55], line 7\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39msklearn\u001b[39;00m\n\u001b[1;32m 6\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mmatplotlib\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mpyplot\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39mplt\u001b[39;00m\n\u001b[0;32m----> 7\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mseaborn\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39msns\u001b[39;00m\n",
+ "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'seaborn'"
+ ]
+ }
+ ],
"source": [
- "import pandas as pd"
+ "import pandas as pd\n",
+ "import re\n",
+ "import numpy as np\n",
+ "\n",
+ "import sklearn\n",
+ "import matplotlib.pyplot as plt\n",
+ "import seaborn as sns"
]
},
{
"cell_type": "code",
- "execution_count": 15,
+ "execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
- "df_eng = pd.DataFrame(columns=['name','sdesc','desc','category','categorypath'])\n",
+ "df_eng = pd.DataFrame(columns=['name','sdesc','category','catlevel0','catlevel1','catlevel2','catlevel3','catlevel4','catlevel5'])\n",
"df_de = pd.DataFrame(columns=['name','sdesc','desc','category','categorypath'])"
]
},
{
"cell_type": "code",
- "execution_count": 23,
+ "execution_count": 34,
"metadata": {},
"outputs": [
{
@@ -98,9 +154,13 @@
"
| \n",
" name | \n",
" sdesc | \n",
- " desc | \n",
" category | \n",
- " categorypath | \n",
+ " catlevel0 | \n",
+ " catlevel1 | \n",
+ " catlevel2 | \n",
+ " catlevel3 | \n",
+ " catlevel4 | \n",
+ " catlevel5 | \n",
" \n",
" \n",
" \n",
@@ -110,11 +170,11 @@
],
"text/plain": [
"Empty DataFrame\n",
- "Columns: [name, sdesc, desc, category, categorypath]\n",
+ "Columns: [name, sdesc, category, catlevel0, catlevel1, catlevel2, catlevel3, catlevel4, catlevel5]\n",
"Index: []"
]
},
- "execution_count": 23,
+ "execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
@@ -125,7 +185,42 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 22,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def cleanStr(text):\n",
+ " \n",
+ " # remove numbers\n",
+ " # no_number_string = re.sub(r'\\d+','',lower_string)\n",
+ "\n",
+ " # remove all punctuation except words and space\n",
+ " # text = re.sub(r'[^\\w\\s]','', lower_string)\n",
+ "\n",
+ " # clean = re.compile('<.*?>')\n",
+ "\n",
+ " # text = re.sub(clean,'',text)\n",
+ " text = re.sub('<[^>]*>', '', text)\n",
+ " emoticons = re.findall('(?::|;|=)(?:-)?(?:\\)|\\(|D|P)', text)\n",
+ " text = (re.sub('[\\W]+', ' ', text.lower()) + ' ' .join(emoticons).replace('-', ''))\n",
+ "\n",
+ " return text\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def readHtml(html):\n",
+ " dftable = pd.read_html(html)\n",
+ " return dftable"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 49,
"metadata": {},
"outputs": [],
"source": [
@@ -145,47 +240,65 @@
"catpath_de=[]\n",
"\n",
"for hit in resp['hits']['hits']:\n",
+ " list_row =[]\n",
" for name in hit['_source']['nameSource']:\n",
" if (name[\"language\"]==\"en\"):\n",
- " name_en.append(name[\"value\"])\n",
+ " list_row.append(cleanStr(name[\"value\"]))\n",
" else:\n",
" name_de.append(name[\"value\"])\n",
" \n",
" for sdesc in hit['_source']['shortDescriptionSource']:\n",
" if (sdesc[\"language\"]==\"en\"):\n",
- " sdesc_en.append(sdesc[\"value\"])\n",
+ " list_row.append(cleanStr(sdesc[\"value\"]))\n",
" else:\n",
" sdesc_de.append(sdesc[\"value\"])\n",
"\n",
- " for desc in hit['_source']['descriptionsSource']:\n",
- " if (desc[\"language\"]==\"en\"):\n",
- " desc_en.append(desc[\"value\"])\n",
- " else:\n",
- " desc_de.append(desc[\"value\"])\n",
+ " # for desc in hit['_source']['descriptionsSource']:\n",
+ " # if (desc[\"language\"]==\"en\"):\n",
+ " # desc_en.append(readHtml(desc[\"value\"]))\n",
+ " # else:\n",
+ " # desc_de.append(desc[\"value\"])\n",
" \n",
" for cats in hit['_source']['categoriesSource']:\n",
" if (cats[\"language\"]==\"en\"):\n",
- " cat_en.append(cats[\"label\"])\n",
+ " list_row.append(cleanStr(cats[\"label\"]))\n",
" else:\n",
" desc_de.append(cats[\"label\"])\n",
"\n",
" if (cats[\"language\"]==\"en\"):\n",
- " catpath_en.append(cats[\"path\"])\n",
+ " categories =cats[\"path\"].split('/')\n",
+ " i =0\n",
+ " catls=[]\n",
+ " for category in categories:\n",
+ "\n",
+ " list_row.append(cleanStr(category))\n",
+ " i= i+1\n",
+ " \n",
" else:\n",
- " catpath_de.append(cats[\"path\"])\n"
+ " catpath_de.append(cats[\"path\"])\n",
+ " \n",
+ " # new_row = pd.DataFrame({'name':_name, 'sdesc':_sdesc, 'category':_cat_en }, index=[0])\n",
+ "\n",
+ " # pd.concat([new_row,df_eng.loc[:]]).reset_index(drop=True)\n",
+ "\n",
+ " for i in range (0,9-len(list_row)):\n",
+ " list_row.append(np.nan)\n",
+ "\n",
+ " df_eng.loc[len(df_eng)] = list_row\n",
+ "\n"
]
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
- "df_en = pd.DataFrame({'name':name_en,\n",
- " 'sdesc':sdesc_en,\n",
- " 'desc':desc_en,\n",
- " 'category':cat_en,\n",
- " 'categorypath':catpath_en})\n",
+ "# df_en = pd.DataFrame({'name':name_en,\n",
+ "# 'sdesc':sdesc_en,\n",
+ "# # 'desc':desc_en,\n",
+ "# 'category':cat_en,\n",
+ "# 'categorypath':catpath_en})\n",
"\n",
"\n",
"# df_de = pd.DataFrame({'name':name_de,\n",
@@ -197,7 +310,7 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 50,
"metadata": {},
"outputs": [
{
@@ -223,51 +336,75 @@
" | \n",
" name | \n",
" sdesc | \n",
- " desc | \n",
" category | \n",
- " categorypath | \n",
+ " catlevel0 | \n",
+ " catlevel1 | \n",
+ " catlevel2 | \n",
+ " catlevel3 | \n",
+ " catlevel4 | \n",
+ " catlevel5 | \n",
" \n",
" \n",
" \n",
" \n",
" | 0 | \n",
- " DENSO DTM82363 Thermostat, coolant | \n",
- " Thermostat, coolant | \n",
- " <div class='criterias'><table class='criterias... | \n",
+ " denso dtm82363 thermostat coolant | \n",
+ " thermostat coolant | \n",
+ " thermostat | \n",
+ " SparePart | \n",
+ " Cooling System | \n",
" Thermostat | \n",
- " SparePart/Cooling System/Thermostat | \n",
+ " na | \n",
+ " na | \n",
+ " na | \n",
"
\n",
" \n",
" | 1 | \n",
- " ZF 1043.010.297 Automatic Transmission | \n",
+ " zf 1043 010 297 automatic transmission | \n",
+ " automatic transmission | \n",
+ " automatic transmission | \n",
+ " SparePart | \n",
+ " Transmission | \n",
" Automatic Transmission | \n",
- " <div class='criterias'><table class='criterias... | \n",
" Automatic Transmission | \n",
- " SparePart/Transmission/Automatic Transmission/... | \n",
+ " na | \n",
+ " na | \n",
"
\n",
" \n",
" | 2 | \n",
- " ZF 1060.040.003 Automatic Transmission | \n",
+ " zf 1060 040 003 automatic transmission | \n",
+ " automatic transmission | \n",
+ " automatic transmission | \n",
+ " SparePart | \n",
+ " Transmission | \n",
" Automatic Transmission | \n",
- " <div class='criterias'><table class='criterias... | \n",
" Automatic Transmission | \n",
- " SparePart/Transmission/Automatic Transmission/... | \n",
+ " na | \n",
+ " na | \n",
"
\n",
" \n",
" | 3 | \n",
- " VAICO V10-0131 Camshaft | \n",
+ " vaico v10 0131 camshaft | \n",
+ " camshaft | \n",
+ " camshaft | \n",
+ " SparePart | \n",
+ " Engine | \n",
+ " Engine Timing | \n",
" Camshaft | \n",
- " <div class='criterias'><table class='criterias... | \n",
- " Camshaft | \n",
- " SparePart/Engine/Engine Timing/Camshaft | \n",
+ " na | \n",
+ " na | \n",
"
\n",
" \n",
" | 4 | \n",
- " VAICO V26-0302 Track Control Arm | \n",
+ " vaico v26 0302 track control arm | \n",
+ " track control arm | \n",
+ " track control arm | \n",
+ " SparePart | \n",
+ " Powertrain & Suspension | \n",
+ " Wheel Suspension | \n",
" Track Control Arm | \n",
- " <div class='criterias'><table class='criterias... | \n",
- " Track Control Arm | \n",
- " SparePart/Powertrain & Suspension/Wheel Suspen... | \n",
+ " na | \n",
+ " na | \n",
"
\n",
" \n",
"\n",
@@ -275,34 +412,83 @@
],
"text/plain": [
" name sdesc \\\n",
- "0 DENSO DTM82363 Thermostat, coolant Thermostat, coolant \n",
- "1 ZF 1043.010.297 Automatic Transmission Automatic Transmission \n",
- "2 ZF 1060.040.003 Automatic Transmission Automatic Transmission \n",
- "3 VAICO V10-0131 Camshaft Camshaft \n",
- "4 VAICO V26-0302 Track Control Arm Track Control Arm \n",
+ "0 denso dtm82363 thermostat coolant thermostat coolant \n",
+ "1 zf 1043 010 297 automatic transmission automatic transmission \n",
+ "2 zf 1060 040 003 automatic transmission automatic transmission \n",
+ "3 vaico v10 0131 camshaft camshaft \n",
+ "4 vaico v26 0302 track control arm track control arm \n",
"\n",
- " desc category \\\n",
- "0