{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "eef90c68", "metadata": {}, "outputs": [], "source": [ "from openmed.core import ModelLoader\n", "from openmed.processing import format_predictions\n", "\n", "loader = ModelLoader() # uses the default configuration\n", "ner = loader.create_pipeline(\n", " \"disease_detection_superclinical\", # registry key or full model ID\n", " aggregation_strategy=\"simple\", # group sub-token predictions for quick wins\n", ")\n", "\n", "text = \"Patient diagnosed with acute lymphoblastic leukemia and started on imatinib.\"\n", "raw_predictions = ner(text)\n", "\n", "result = format_predictions(raw_predictions, text, model_name=\"Disease Detection\")\n", "for entity in result.entities:\n", " print(f\"{entity.label:<12} -> {entity.text} (confidence={entity.confidence:.2f})\")" ] }, { "cell_type": "code", "execution_count": null, "id": "a14de1a5", "metadata": {}, "outputs": [], "source": [ "import os\n", "import json\n", "\n", "data_dir = \"/home/mshahidul/readctrl/data/kyw_def_raw\"\n", "json_list = []\n", "\n", "for filename in os.listdir(data_dir):\n", " print(f\"Processing file: {filename}\")\n", " if filename.endswith(\".json\"):\n", " file_path = os.path.join(data_dir, filename)\n", " with open(file_path, \"r\") as f:\n", " json_file=json.load(f)\n", " if \"chatgpt_answer\" in json_file:\n", " json_file=json_file[\"chatgpt_answer\"]\n", " json_list.append(json_file)\n", "\n", "# Save the combined list to a new file\n", "save_dir = \"/home/mshahidul/readctrl/data/kyw_def_train\"\n", "os.makedirs(save_dir, exist_ok=True)\n", "with open(os.path.join(save_dir, \"kyw_gen_gpt5.json\"), \"w\") as out_f:\n", " json.dump(json_list, out_f, indent=4)" ] } ], "metadata": { "kernelspec": { "display_name": "unsloth", "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.11.11" } }, "nbformat": 4, "nbformat_minor": 5 }