ormatting changes for notebooks

This commit is contained in:
Henry Dowd
2025-11-22 17:33:24 +00:00
parent a0e88c1525
commit 5a38131e9a
2 changed files with 100 additions and 58 deletions

View File

@@ -77,8 +77,8 @@
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-11-21T16:32:45.216663Z",
"start_time": "2025-11-21T16:32:42.601290Z"
"end_time": "2025-11-21T23:26:23.172796Z",
"start_time": "2025-11-21T23:26:21.541542Z"
}
},
"cell_type": "code",
@@ -129,17 +129,29 @@
"processed_syntactic = []\n",
"\n",
"for sentence in test_sentences:\n",
" processed_direct[iter] = preprocessor.semantic_analysis(sentence)\n",
"#print(preprocessor.syntactic_analysis(\"A completely different sentence about something else.\"))\n",
" print(\"-\" * 50)\n",
" print(f\"Sentence: {sentence}\")\n",
" direct = preprocessor.direct_detection(sentence)\n",
" processed_direct.append(direct)\n",
" print(\"--- Direct Sentence ---\")\n",
" print(f\"{direct}\")\n",
" semantic = preprocessor.semantic_analysis(sentence)\n",
" processed_semantic.append(semantic)\n",
" print(\"--- Semantic Sentence ---\")\n",
" print(f\"{semantic}\")\n",
" syntactic = preprocessor.syntactic_analysis(sentence)\n",
" processed_syntactic.append(syntactic)\n",
" print(\"--- Syntactic Sentence ---\")\n",
" print(f\"{syntactic}\")\n",
"\n",
"\n",
"for sent in test_sentences:\n",
" print(f\"Original Sentence: {sent}\")\n",
" print(\"--- Semantic Analysis ---\")\n",
" print(f\"Preprocessed Sentence: {preprocessor.semantic_analysis(sent)}\")\n",
" print(\"--- Syntactic Analysis ---\")\n",
" print(f\"Preprocessed Sentence: {preprocessor.syntactic_analysis(sent)}\")\n",
" print(\"-\" * 50)"
"print(\"-\" * 50)\n",
"#for sent in test_sentences:\n",
"# print(f\"Original Sentence: {sent}\")\n",
"# print(\"--- Semantic Analysis ---\")\n",
"# print(f\"Preprocessed Sentence: {preprocessor.semantic_analysis(sent)}\")\n",
"# print(\"--- Syntactic Analysis ---\")\n",
"# print(f\"Preprocessed Sentence: {preprocessor.syntactic_analysis(sent)}\")\n",
"# print(\"-\" * 50)"
],
"id": "5e488a878a5cfccb",
"outputs": [
@@ -147,34 +159,41 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Original Sentence: The cat sat on the mat.\n",
"--- Semantic Analysis ---\n",
"Preprocessed Sentence: cat sit mat\n",
"--- Syntactic Analysis ---\n",
"Preprocessed Sentence: the cat sit on the mat .\n",
"--------------------------------------------------\n",
"Original Sentence: On the mat, the cat was sitting.\n",
"--- Semantic Analysis ---\n",
"Preprocessed Sentence: mat cat sit\n",
"--- Syntactic Analysis ---\n",
"Preprocessed Sentence: on the mat , the cat be sit .\n",
"Sentence: The cat sat on the mat.\n",
"--- Direct Sentence ---\n",
"the cat sat on the mat.\n",
"--- Semantic Sentence ---\n",
"cat sit mat\n",
"--- Syntactic Sentence ---\n",
"the cat sit on the mat .\n",
"--------------------------------------------------\n",
"Original Sentence: A completely different sentence about something else.\n",
"--- Semantic Analysis ---\n",
"Preprocessed Sentence: completely different sentence\n",
"--- Syntactic Analysis ---\n",
"Preprocessed Sentence: a completely different sentence about something else .\n",
"Sentence: On the mat, the cat was sitting.\n",
"--- Direct Sentence ---\n",
"on the mat, the cat was sitting.\n",
"--- Semantic Sentence ---\n",
"mat cat sit\n",
"--- Syntactic Sentence ---\n",
"on the mat , the cat be sit .\n",
"--------------------------------------------------\n",
"Sentence: A completely different sentence about something else.\n",
"--- Direct Sentence ---\n",
"a completely different sentence about something else.\n",
"--- Semantic Sentence ---\n",
"completely different sentence\n",
"--- Syntactic Sentence ---\n",
"a completely different sentence about something else .\n",
"--------------------------------------------------\n"
]
}
],
"execution_count": 17
"execution_count": 37
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-11-20T15:51:42.074798Z",
"start_time": "2025-11-20T15:51:42.050593Z"
"end_time": "2025-11-21T23:39:48.443022Z",
"start_time": "2025-11-21T23:39:48.411766Z"
}
},
"cell_type": "code",
@@ -192,7 +211,7 @@
"\n",
" return doc\n",
"\n",
"for sentence in test_sentences:\n",
"for sentence in processed_syntactic:\n",
" doc = extract_parse_tree(sentence)\n",
" print(\"\\n\" + \"=\"*60 + \"\\n\")"
],
@@ -202,44 +221,44 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Sentence: The cat sat on the mat.\n",
"Sentence: the cat sit on the mat .\n",
"\n",
"Dependenct Parse Tree:\n",
"--------------------------------------------------\n",
"The det cat []\n",
"cat nsubj sat ['The']\n",
"sat ROOT sat ['cat', 'on', '.']\n",
"on prep sat ['mat']\n",
"the det cat []\n",
"cat nsubj sit ['the']\n",
"sit ROOT sit ['cat', 'on', '.']\n",
"on prep sit ['mat']\n",
"the det mat []\n",
"mat pobj on ['the']\n",
". punct sat []\n",
". punct sit []\n",
"\n",
"============================================================\n",
"\n",
"Sentence: On the mat, the cat was sitting.\n",
"Sentence: on the mat , the cat be sit .\n",
"\n",
"Dependenct Parse Tree:\n",
"--------------------------------------------------\n",
"On prep sitting ['mat']\n",
"on prep sit ['mat']\n",
"the det mat []\n",
"mat pobj On ['the']\n",
", punct sitting []\n",
"mat pobj on ['the']\n",
", punct sit []\n",
"the det cat []\n",
"cat nsubj sitting ['the']\n",
"was aux sitting []\n",
"sitting ROOT sitting ['On', ',', 'cat', 'was', '.']\n",
". punct sitting []\n",
"cat nsubj sit ['the']\n",
"be aux sit []\n",
"sit ROOT sit ['on', ',', 'cat', 'be', '.']\n",
". punct sit []\n",
"\n",
"============================================================\n",
"\n",
"Sentence: A completely different sentence about something else.\n",
"Sentence: a completely different sentence about something else .\n",
"\n",
"Dependenct Parse Tree:\n",
"--------------------------------------------------\n",
"A det sentence []\n",
"a det sentence []\n",
"completely advmod different []\n",
"different amod sentence ['completely']\n",
"sentence ROOT sentence ['A', 'different', 'about', '.']\n",
"sentence ROOT sentence ['a', 'different', 'about', '.']\n",
"about prep sentence ['something']\n",
"something pobj about ['else']\n",
"else advmod something []\n",
@@ -250,7 +269,7 @@
]
}
],
"execution_count": 15
"execution_count": 39
},
{
"metadata": {},