{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":59575,"databundleVersionId":8060720,"sourceType":"competition"},{"sourceId":8413600,"sourceType":"datasetVersion","datasetId":5007812},{"sourceId":174185912,"sourceType":"kernelVersion"}],"dockerImageVersionId":30698,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"! pip install /kaggle/input/uspto-whoosh-reloaded-2-7-5-patched/Whoosh_Reloaded-2.7.5-py2.py3-none-any.whl","metadata":{"execution":{"iopub.status.busy":"2024-05-14T18:52:07.969552Z","iopub.execute_input":"2024-05-14T18:52:07.969978Z","iopub.status.idle":"2024-05-14T18:52:46.370736Z","shell.execute_reply.started":"2024-05-14T18:52:07.969944Z","shell.execute_reply":"2024-05-14T18:52:46.369584Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"! sed 's:/kaggle/input/whoosh-wheel-2-7-4/Whoosh-2.7.4-py2.py3-none-any.whl:whoosh-reloaded==2.7.5:g' /kaggle/usr/lib/whoosh_utils/whoosh_utils.py > whoosh_utils.py\nimport whoosh_utils","metadata":{"execution":{"iopub.status.busy":"2024-05-14T18:52:46.373612Z","iopub.execute_input":"2024-05-14T18:52:46.374016Z","iopub.status.idle":"2024-05-14T18:53:21.961750Z","shell.execute_reply.started":"2024-05-14T18:52:46.373980Z","shell.execute_reply":"2024-05-14T18:53:21.960012Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_idx = whoosh_utils.load_index('/kaggle/input/uspto-explainable-ai/train_index')\nsearcher = whoosh_utils.get_searcher(train_idx)\nqp = whoosh_utils.get_query_parser()","metadata":{"execution":{"iopub.status.busy":"2024-05-14T18:53:21.963801Z","iopub.execute_input":"2024-05-14T18:53:21.964252Z","iopub.status.idle":"2024-05-14T18:54:37.567496Z","shell.execute_reply.started":"2024-05-14T18:53:21.964203Z","shell.execute_reply":"2024-05-14T18:54:37.566327Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\n# https://www.kaggle.com/competitions/uspto-explainable-ai/discussion/498283\nquery_3 = 'cpc:G03G15/224 OR cpc:B33Y10/00 OR cpc:B33Y30/00'\nwhoosh_utils.execute_query(query_3, qp, searcher)","metadata":{"execution":{"iopub.status.busy":"2024-05-14T18:54:44.694076Z","iopub.execute_input":"2024-05-14T18:54:44.694499Z","iopub.status.idle":"2024-05-14T18:54:44.714918Z","shell.execute_reply.started":"2024-05-14T18:54:44.694468Z","shell.execute_reply":"2024-05-14T18:54:44.713469Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\n# https://www.kaggle.com/competitions/uspto-explainable-ai/discussion/498283#2782101\nquery_4 = 'cpc:C07B2200/13 OR cpc:A61P35/00 OR cpc:C07D487/04 OR cpc:C07D471/04 OR cpc:A61P43/00 OR cpc:C07D401/14 OR cpc:A61P31/12 OR cpc:A61K31/519 OR cpc:A61P31/20 OR cpc:C07D513/04 OR cpc:C07D403/06 OR cpc:C07D417/14 OR cpc:C07D405/12'\nwhoosh_utils.execute_query(query_4, qp, searcher)","metadata":{"execution":{"iopub.status.busy":"2024-05-14T18:54:48.037556Z","iopub.execute_input":"2024-05-14T18:54:48.037946Z","iopub.status.idle":"2024-05-14T18:54:48.177981Z","shell.execute_reply.started":"2024-05-14T18:54:48.037916Z","shell.execute_reply":"2024-05-14T18:54:48.176654Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Credit goes to https://www.kaggle.com/code/sash2104/debug-ver-2-uspto-discussion-498283 @ sash2104¶","metadata":{}}]}