mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-08-29 04:26:20 +00:00
Refactor Unstructured Cookbook imports for better modularity
This commit is contained in:
@@ -30,14 +30,10 @@
|
||||
"source": [
|
||||
"# !pip install semantica[all]\n",
|
||||
"\n",
|
||||
"from semantica.semantic_extract import NERExtractor, RelationExtractor\n",
|
||||
"from semantica.ontology import OntologyGenerator, OntologyValidator, LLMOntologyGenerator, OntologyOptimizer\n",
|
||||
"from semantica.visualization import OntologyVisualizer\n",
|
||||
"from semantica.export import OWLExporter\n",
|
||||
"from semantica.utils.logging import get_logger\n",
|
||||
"\n",
|
||||
"logger = get_logger(\"unstructured_guide\")\n",
|
||||
"print(\"Libraries loaded successfully.\")"
|
||||
"print(\"Environment setup complete.\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -89,6 +85,9 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from semantica.semantic_extract import NERExtractor, RelationExtractor\n",
|
||||
"from semantica.ontology import OntologyGenerator, OntologyOptimizer\n",
|
||||
"\n",
|
||||
"# 1. Initialize Extractors\n",
|
||||
"ner = NERExtractor()\n",
|
||||
"re = RelationExtractor()\n",
|
||||
@@ -137,6 +136,8 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from semantica.ontology import LLMOntologyGenerator\n",
|
||||
"\n",
|
||||
"try:\n",
|
||||
" # Initialize LLM Generator (ensure OPENAI_API_KEY is set in env)\n",
|
||||
" llm_gen = LLMOntologyGenerator(provider=\"openai\", model=\"gpt-4\")\n",
|
||||
@@ -172,6 +173,8 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from semantica.visualization import OntologyVisualizer\n",
|
||||
"\n",
|
||||
"visualizer = OntologyVisualizer()\n",
|
||||
"\n",
|
||||
"print(\"--- NLP Approach Visualization ---\")\n",
|
||||
@@ -201,6 +204,8 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from semantica.ontology import OntologyValidator\n",
|
||||
"\n",
|
||||
"validator = OntologyValidator()\n",
|
||||
"\n",
|
||||
"def print_report(name, ont):\n",
|
||||
@@ -231,6 +236,8 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from semantica.export import OWLExporter\n",
|
||||
"\n",
|
||||
"exporter = OWLExporter()\n",
|
||||
"\n",
|
||||
"# Export the NLP ontology by default, or the LLM one if preferred\n",
|
||||
|
||||
Reference in New Issue
Block a user