{ "cells": [ { "cell_type": "code", "execution_count": 18, "id": "a8be6839", "metadata": {}, "outputs": [], "source": [ "import os\n", "import pandas as pd\n", "import janitor\n", "import matplotlib.pyplot as plt\n", "import seaborn as sns\n", "from matplotlib.ticker import MaxNLocator\n", "import math\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": 15, "id": "211ba466", "metadata": {}, "outputs": [], "source": [ "outdir=\"EU_CH_scope\"\n", "\n", "appln = pd.read_csv(f\"{outdir}/tls_201_scope.csv\")\n", "\n", "appln_title = pd.read_csv(f\"{outdir}/tls_202_scope.csv\")\n", "\n", "pers = pd.read_csv(f\"{outdir}/tls_206_scope.csv\")\n", "\n", "appln_pers = pd.read_csv(f\"{outdir}/tls_207_scope.csv\")\n", "\n", "appln_cpc = pd.read_csv(f\"{outdir}/tls_224_scope.csv\")" ] }, { "cell_type": "code", "execution_count": 31, "id": "f878b151", "metadata": {}, "outputs": [], "source": [ "# workdir_path=r\"CPCTitleList202302\"\n", "# # outfile='wos_extract_complete.csv'\n", "# # with_header=True\n", "# cpc_ids = pd.DataFrame()\n", "# for root, dirs, files in os.walk(workdir_path):\n", "# for filename in files:\n", "# path=os.path.join(root, filename)\n", "# section = pd.read_csv(path, sep='\\t', header=None)\n", "# cpc_ids=pd.concat([cpc_ids,section], ignore_index=True)\n", "# cpc_ids.columns =[\"cpc_id\",\"idk\",\"cpc_name\"]\n", "# cpc_ids = cpc_ids.drop(columns=\"idk\")" ] }, { "cell_type": "code", "execution_count": 106, "id": "95ea20da", "metadata": {}, "outputs": [], "source": [ "parsed = {x: [] for x in ['code', 'title', 'section', 'class', 'subclass', 'group', 'main_group']}\n", "for letter in 'ABCDEFGHY':\n", " file = f'CPCTitleList202302/cpc-section-{letter}_20230201.txt'\n", " with open(file) as f:\n", " for line in f:\n", " vals = line.strip().split('\\t')\n", " if len(vals) == 2:\n", " parsed['code'].append(vals[0])\n", " parsed['title'].append(vals[1])\n", " elif len(vals) == 3:\n", " parsed['code'].append(vals[0])\n", " parsed['title'].append(vals[2])\n", "\n", "\n", "\n", "for i in range(len(parsed['code'])):\n", " code = parsed['code'][i]\n", " main_group = code.split('/')[-1] if \"/\" in code else None\n", " group = code.split('/')[0][4:] if len(code) >= 5 else None\n", " subclass = code[3] if len(code) >= 4 else None\n", " class_ = code[1:3] if len(code) >= 3 else None\n", " section = code[0] if len(code) >= 1 else None\n", " \n", " parsed['main_group'].append(main_group)\n", " parsed['group'].append(group)\n", " parsed['subclass'].append(subclass)\n", " parsed['class'].append(class_)\n", " parsed['section'].append(section)\n", "\n", "cpc_ids2023 = pd.DataFrame.from_dict(parsed)\n", "cpc_ids2023['cpc_version']=2023\n", "cpc_ids2022 = pd.read_csv(\"CPC_data/cpc_titles_2022.csv\")\n", "cpc_ids2022['cpc_version']=2022\n", "cpc_ids = pd.concat([cpc_ids2023,cpc_ids2022], ignore_index=True)\n", "cpc_ids = cpc_ids.rename(columns={\"code\":\"cpc_id\",\"title\":\"cpc_name\"}).drop_duplicates(subset=\"cpc_id\")" ] }, { "cell_type": "code", "execution_count": 116, "id": "907d9c3e", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
cpc_idcpc_namesectionclasssubclassgroupmain_groupcpc_versioncpc_taxonomy
0AHUMAN NECESSITIESANoneNoneNoneNone2023[(A, HUMAN NECESSITIES)]
1A01AGRICULTURE; FORESTRY; ANIMAL HUSBANDRY; HUNTI...A01NoneNoneNone2023[(A, HUMAN NECESSITIES), (A01, AGRICULTURE; FO...
2A01BSOIL WORKING IN AGRICULTURE OR FORESTRY; PARTS...A01BNoneNone2023[(A, HUMAN NECESSITIES), (A01, AGRICULTURE; FO...
3A01B1/00Hand tools (edge trimmers for lawns A01G3/06 ...A01B1002023[(A, HUMAN NECESSITIES), (A01, AGRICULTURE; FO...
4A01B1/02Spades; Shovels {(hand-operated dredgers E02F3...A01B1022023[(A, HUMAN NECESSITIES), (A01, AGRICULTURE; FO...
\n", "
" ], "text/plain": [ " cpc_id cpc_name section class \n", "0 A HUMAN NECESSITIES A None \\\n", "1 A01 AGRICULTURE; FORESTRY; ANIMAL HUSBANDRY; HUNTI... A 01 \n", "2 A01B SOIL WORKING IN AGRICULTURE OR FORESTRY; PARTS... A 01 \n", "3 A01B1/00 Hand tools (edge trimmers for lawns A01G3/06 ... A 01 \n", "4 A01B1/02 Spades; Shovels {(hand-operated dredgers E02F3... A 01 \n", "\n", " subclass group main_group cpc_version \n", "0 None None None 2023 \\\n", "1 None None None 2023 \n", "2 B None None 2023 \n", "3 B 1 00 2023 \n", "4 B 1 02 2023 \n", "\n", " cpc_taxonomy \n", "0 [(A, HUMAN NECESSITIES)] \n", "1 [(A, HUMAN NECESSITIES), (A01, AGRICULTURE; FO... \n", "2 [(A, HUMAN NECESSITIES), (A01, AGRICULTURE; FO... \n", "3 [(A, HUMAN NECESSITIES), (A01, AGRICULTURE; FO... \n", "4 [(A, HUMAN NECESSITIES), (A01, AGRICULTURE; FO... " ] }, "execution_count": 116, "metadata": {}, "output_type": "execute_result" } ], "source": [] }, { "cell_type": "code", "execution_count": 108, "id": "1be8971a", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "40 cpc_ids not found\n", "0.11297201118422912 % lost\n" ] } ], "source": [ "appln_cpc[\"cpc_id\"] = appln_cpc[\"cpc_class_symbol\"].str.replace(\" \",\"\")\n", "appln_cpc_tax = appln_cpc.merge(cpc_ids, on=\"cpc_id\", how=\"left\")\n", "\n", "print(len(appln_cpc_tax[appln_cpc_tax[\"cpc_name\"].isna()][\"cpc_id\"].unique()), \"cpc_ids not found\")\n", "print(len(appln_cpc_tax[appln_cpc_tax[\"cpc_name\"].isna()][\"cpc_id\"].unique())/len(appln_cpc_tax[\"cpc_id\"].unique())*100, \"% lost\")" ] }, { "cell_type": "code", "execution_count": 110, "id": "b1274c34", "metadata": {}, "outputs": [], "source": [ "cpc_dict = dict(zip(cpc_ids.cpc_id.str.replace(\" \",\"\"), cpc_ids.cpc_name))\n", "# cpc_dict" ] }, { "cell_type": "code", "execution_count": 111, "id": "2a7e39ee", "metadata": {}, "outputs": [], "source": [ "def cpc_classifier(id_text):\n", " taxonomy = []\n", " iter_text = id_text.replace(\" \",\"\")\n", " for i in range(len(iter_text)+1):\n", " tax_id = iter_text[:i]\n", " tax_name = cpc_dict.get(iter_text[:i])\n", " if tax_name:\n", " taxonomy.append((tax_id,tax_name))\n", " return taxonomy\n", " " ] }, { "cell_type": "code", "execution_count": 112, "id": "e31a013f", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[('A', 'HUMAN NECESSITIES'),\n", " ('A01',\n", " 'AGRICULTURE; FORESTRY; ANIMAL HUSBANDRY; HUNTING; TRAPPING; FISHING'),\n", " ('A01B',\n", " 'SOIL WORKING IN AGRICULTURE OR FORESTRY; PARTS, DETAILS, OR ACCESSORIES OF AGRICULTURAL MACHINES OR IMPLEMENTS, IN GENERAL (making or covering furrows or holes for sowing, planting, or manuring A01C5/00; soil working for engineering purposes E01, E02, E21; {measuring areas for agricultural purposes G01B})'),\n", " ('A01B1/06',\n", " 'Hoes; Hand cultivators {(rakes A01D7/00; forks A01D9/00; picks B25D)}'),\n", " ('A01B1/065', '{powered}')]" ] }, "execution_count": 112, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cpc_classifier(\"A01B1/065\")" ] }, { "cell_type": "code", "execution_count": 117, "id": "f09a616c", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
cpc_idcpc_namesectionclasssubclassgroupmain_groupcpc_versioncpc_taxonomy
0AHUMAN NECESSITIESANoneNoneNoneNone2023[(A, HUMAN NECESSITIES)]
1A01AGRICULTURE; FORESTRY; ANIMAL HUSBANDRY; HUNTI...A01NoneNoneNone2023[(A, HUMAN NECESSITIES), (A01, AGRICULTURE; FO...
2A01BSOIL WORKING IN AGRICULTURE OR FORESTRY; PARTS...A01BNoneNone2023[(A, HUMAN NECESSITIES), (A01, AGRICULTURE; FO...
3A01B1/00Hand tools (edge trimmers for lawns A01G3/06 ...A01B1002023[(A, HUMAN NECESSITIES), (A01, AGRICULTURE; FO...
4A01B1/02Spades; Shovels {(hand-operated dredgers E02F3...A01B1022023[(A, HUMAN NECESSITIES), (A01, AGRICULTURE; FO...
\n", "
" ], "text/plain": [ " cpc_id cpc_name section class \n", "0 A HUMAN NECESSITIES A None \\\n", "1 A01 AGRICULTURE; FORESTRY; ANIMAL HUSBANDRY; HUNTI... A 01 \n", "2 A01B SOIL WORKING IN AGRICULTURE OR FORESTRY; PARTS... A 01 \n", "3 A01B1/00 Hand tools (edge trimmers for lawns A01G3/06 ... A 01 \n", "4 A01B1/02 Spades; Shovels {(hand-operated dredgers E02F3... A 01 \n", "\n", " subclass group main_group cpc_version \n", "0 None None None 2023 \\\n", "1 None None None 2023 \n", "2 B None None 2023 \n", "3 B 1 00 2023 \n", "4 B 1 02 2023 \n", "\n", " cpc_taxonomy \n", "0 [(A, HUMAN NECESSITIES)] \n", "1 [(A, HUMAN NECESSITIES), (A01, AGRICULTURE; FO... \n", "2 [(A, HUMAN NECESSITIES), (A01, AGRICULTURE; FO... \n", "3 [(A, HUMAN NECESSITIES), (A01, AGRICULTURE; FO... \n", "4 [(A, HUMAN NECESSITIES), (A01, AGRICULTURE; FO... " ] }, "execution_count": 117, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cpc_ids[\"cpc_taxonomy\"] = cpc_ids[\"cpc_id\"].map(cpc_classifier)\n", "cpc_ids.head()" ] }, { "cell_type": "code", "execution_count": 114, "id": "f3fa8bf3", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "40 cpc_ids not found\n", "0.11297201118422912 % lost\n" ] } ], "source": [ "appln_cpc[\"cpc_id\"] = appln_cpc[\"cpc_class_symbol\"].str.replace(\" \",\"\")\n", "appln_cpc_tax = appln_cpc.merge(cpc_ids, on=\"cpc_id\", how=\"left\")\n", "print(len(appln_cpc_tax[appln_cpc_tax[\"cpc_name\"].isna()][\"cpc_id\"].unique()), \"cpc_ids not found\")\n", "print(len(appln_cpc_tax[appln_cpc_tax[\"cpc_name\"].isna()][\"cpc_id\"].unique())/len(appln_cpc_tax[\"cpc_id\"].unique())*100, \"% lost\")" ] }, { "cell_type": "code", "execution_count": 118, "id": "58701721", "metadata": {}, "outputs": [], "source": [ "# appln_cpc_tax[appln_cpc_tax[\"cpc_name\"].isna()][\"cpc_id\"].unique()" ] }, { "cell_type": "markdown", "id": "ca631acf", "metadata": {}, "source": [ "## 'AI' keywords" ] }, { "cell_type": "code", "execution_count": 34, "id": "6c3baa5b", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
cpc_idcpc_name
12725A61B1/000096{using artificial intelligence}
13764A61B5/7264{Classification of physiological signals or da...
45143B23K31/006{relating to using of neural networks}
47746B25J9/161{Hardware, e.g. neural networks, fuzzy logic, ...
53935B29C66/965{using artificial neural networks}
.........
240426H04Q2213/343Neural network
240673H04R25/507{implemented by neural network or fuzzy logic}
246159Y10S128/924using artificial intelligence
246160Y10S128/925Neural network
250570Y10S706/00Data processing: artificial intelligence
\n", "

105 rows × 2 columns

\n", "
" ], "text/plain": [ " cpc_id cpc_name\n", "12725 A61B1/000096 {using artificial intelligence}\n", "13764 A61B5/7264 {Classification of physiological signals or da...\n", "45143 B23K31/006 {relating to using of neural networks}\n", "47746 B25J9/161 {Hardware, e.g. neural networks, fuzzy logic, ...\n", "53935 B29C66/965 {using artificial neural networks}\n", "... ... ...\n", "240426 H04Q2213/343 Neural network\n", "240673 H04R25/507 {implemented by neural network or fuzzy logic}\n", "246159 Y10S128/924 using artificial intelligence\n", "246160 Y10S128/925 Neural network\n", "250570 Y10S706/00 Data processing: artificial intelligence\n", "\n", "[105 rows x 2 columns]" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cpc_ids[cpc_ids[\"cpc_name\"].str.lower().str.contains(\"machine learn|neural network|deep learn|deep network|artificial intelligence\", regex=True)]" ] }, { "cell_type": "code", "execution_count": 121, "id": "2e8368b4", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
appln_idappln_authappln_nrappln_kindappln_filing_dateappln_filing_yearappln_nr_originalipr_typereceiving_officeinternat_appln_id...earliest_pat_publn_idgranteddocdb_family_idinpadoc_family_iddocdb_family_sizenb_citing_docdb_famnb_applicantsnb_inventorsappln_title_lgappln_title
0340657036EP12000117A2012-01-09201212000117PI0...407623142Y455073943406570363612enRotating membrane filter disc apparatus
1340982410EP12151915A2012-01-20201212151915PI0...365158710Y4553122034098241021626enHeating-Cooling-Capacity measurement controlli...
2341078960EP12700310A2012-01-11201212700310PI340778427...413564969Y454915823407784273211enTRANSMISSION DEVICE
3341078962EP12700311A2012-01-11201212700311PI340778431...413564970Y454915833407784313311enTRANSMISSION DEVICE
4341127772EP12700372A2012-01-02201212700372PI340460188...421840120Y454959233404601884812enPOWER CONTROL IN A WIRELESS COMMUNICATION SYST...
\n", "

5 rows × 28 columns

\n", "
" ], "text/plain": [ " appln_id appln_auth appln_nr appln_kind appln_filing_date \n", "0 340657036 EP 12000117 A 2012-01-09 \\\n", "1 340982410 EP 12151915 A 2012-01-20 \n", "2 341078960 EP 12700310 A 2012-01-11 \n", "3 341078962 EP 12700311 A 2012-01-11 \n", "4 341127772 EP 12700372 A 2012-01-02 \n", "\n", " appln_filing_year appln_nr_original ipr_type receiving_office \n", "0 2012 12000117 PI \\\n", "1 2012 12151915 PI \n", "2 2012 12700310 PI \n", "3 2012 12700311 PI \n", "4 2012 12700372 PI \n", "\n", " internat_appln_id ... earliest_pat_publn_id granted docdb_family_id \n", "0 0 ... 407623142 Y 45507394 \\\n", "1 0 ... 365158710 Y 45531220 \n", "2 340778427 ... 413564969 Y 45491582 \n", "3 340778431 ... 413564970 Y 45491583 \n", "4 340460188 ... 421840120 Y 45495923 \n", "\n", " inpadoc_family_id docdb_family_size nb_citing_docdb_fam nb_applicants \n", "0 340657036 3 6 1 \\\n", "1 340982410 2 16 2 \n", "2 340778427 3 2 1 \n", "3 340778431 3 3 1 \n", "4 340460188 4 8 1 \n", "\n", " nb_inventors appln_title_lg \n", "0 2 en \\\n", "1 6 en \n", "2 1 en \n", "3 1 en \n", "4 2 en \n", "\n", " appln_title \n", "0 Rotating membrane filter disc apparatus \n", "1 Heating-Cooling-Capacity measurement controlli... \n", "2 TRANSMISSION DEVICE \n", "3 TRANSMISSION DEVICE \n", "4 POWER CONTROL IN A WIRELESS COMMUNICATION SYST... \n", "\n", "[5 rows x 28 columns]" ] }, "execution_count": 121, "metadata": {}, "output_type": "execute_result" } ], "source": [ "appln_data = appln.merge(appln_title, on=\"appln_id\")\n", "appln_data.head()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.16" } }, "nbformat": 4, "nbformat_minor": 5 }