noshot 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- noshot/__init__.py +1 -0
- noshot/data/AIDS CN NLP/AIDS/1. Implement Basic Search Strategies/(A) Breadth First Search.ipynb +112 -0
- noshot/data/AIDS CN NLP/AIDS/1. Implement Basic Search Strategies/(B) Depth First Search.ipynb +111 -0
- noshot/data/AIDS CN NLP/AIDS/1. Implement Basic Search Strategies/(C) Uniform Cost Search.ipynb +134 -0
- noshot/data/AIDS CN NLP/AIDS/1. Implement Basic Search Strategies/(D) Depth Limites Search.ipynb +115 -0
- noshot/data/AIDS CN NLP/AIDS/1. Implement Basic Search Strategies/(E) Iterative Deepening DFS.ipynb +123 -0
- noshot/data/AIDS CN NLP/AIDS/10. ANOVA/2_ANOVA.csv +769 -0
- noshot/data/AIDS CN NLP/AIDS/10. ANOVA/One Way ANOVA (Repeated Measure).ipynb +126 -0
- noshot/data/AIDS CN NLP/AIDS/10. ANOVA/One Way ANOVA.ipynb +134 -0
- noshot/data/AIDS CN NLP/AIDS/10. ANOVA/Sample 1 Way ANOVA Test.ipynb +119 -0
- noshot/data/AIDS CN NLP/AIDS/10. ANOVA/Two Way ANOVA.ipynb +138 -0
- noshot/data/AIDS CN NLP/AIDS/10. ANOVA/reaction_time.csv +5 -0
- noshot/data/AIDS CN NLP/AIDS/10. ANOVA/sample_data.csv +16 -0
- noshot/data/AIDS CN NLP/AIDS/10. ANOVA/sleep_deprivation.csv +4 -0
- noshot/data/AIDS CN NLP/AIDS/11. Linear Regression/3_Linear.csv +4802 -0
- noshot/data/AIDS CN NLP/AIDS/11. Linear Regression/Linear Regression LAB.ipynb +113 -0
- noshot/data/AIDS CN NLP/AIDS/11. Linear Regression/Linear Regression New- sklearn.ipynb +118 -0
- noshot/data/AIDS CN NLP/AIDS/11. Linear Regression/Linear Regression.ipynb +148 -0
- noshot/data/AIDS CN NLP/AIDS/11. Linear Regression/house_rate.csv +22 -0
- noshot/data/AIDS CN NLP/AIDS/12. Logistic Regression/Logistic Regression New- sklearn.ipynb +128 -0
- noshot/data/AIDS CN NLP/AIDS/12. Logistic Regression/Logistic Regression.ipynb +145 -0
- noshot/data/AIDS CN NLP/AIDS/12. Logistic Regression/default.csv +1001 -0
- noshot/data/AIDS CN NLP/AIDS/12. Logistic Regression/hours_scores_records.csv +101 -0
- noshot/data/AIDS CN NLP/AIDS/2. Implement A Star And MA Star/(A) Astar.ipynb +256 -0
- noshot/data/AIDS CN NLP/AIDS/2. Implement A Star And MA Star/(B) IDAstar.ipynb +157 -0
- noshot/data/AIDS CN NLP/AIDS/2. Implement A Star And MA Star/(C) SMAstar.ipynb +178 -0
- noshot/data/AIDS CN NLP/AIDS/3. Genetic Algorithm/Genetic.ipynb +95 -0
- noshot/data/AIDS CN NLP/AIDS/4. Simulated Annealing/Simulated Annealing.ipynb +74 -0
- noshot/data/AIDS CN NLP/AIDS/4. Simulated Annealing/Sudoku Simulated Annealing.ipynb +103 -0
- noshot/data/AIDS CN NLP/AIDS/5. Alpha Beta Pruning/AlphaBetaPruning.ipynb +182 -0
- noshot/data/AIDS CN NLP/AIDS/6. Consraint Satisfaction Problems (CSP)/(A) CSP House Allocation.ipynb +120 -0
- noshot/data/AIDS CN NLP/AIDS/6. Consraint Satisfaction Problems (CSP)/(B) CSP Map Coloring.ipynb +125 -0
- noshot/data/AIDS CN NLP/AIDS/7. Random Sampling/Random Sampling.ipynb +73 -0
- noshot/data/AIDS CN NLP/AIDS/7. Random Sampling/height_weight_bmi.csv +8389 -0
- noshot/data/AIDS CN NLP/AIDS/8. Z Test/Z Test Hash Function.ipynb +141 -0
- noshot/data/AIDS CN NLP/AIDS/8. Z Test/Z Test.ipynb +151 -0
- noshot/data/AIDS CN NLP/AIDS/8. Z Test/height_weight_bmi.csv +8389 -0
- noshot/data/AIDS CN NLP/AIDS/9. T Test/1_heart.csv +304 -0
- noshot/data/AIDS CN NLP/AIDS/9. T Test/Independent T Test.ipynb +119 -0
- noshot/data/AIDS CN NLP/AIDS/9. T Test/Paired T Test.ipynb +118 -0
- noshot/data/AIDS CN NLP/AIDS/9. T Test/T Test Hash Function.ipynb +142 -0
- noshot/data/AIDS CN NLP/AIDS/9. T Test/T Test.ipynb +158 -0
- noshot/data/AIDS CN NLP/AIDS/9. T Test/height_weight_bmi.csv +8389 -0
- noshot/data/AIDS CN NLP/AIDS/9. T Test/iq_test.csv +0 -0
- noshot/data/AIDS CN NLP/AIDS/Others (AllinOne)/All In One.ipynb +4581 -0
- noshot/data/AIDS CN NLP/CN/1. Chat Application/chat.java +81 -0
- noshot/data/AIDS CN NLP/CN/1. Chat Application/output.png +0 -0
- noshot/data/AIDS CN NLP/CN/1. Chat Application/procedure.png +0 -0
- noshot/data/AIDS CN NLP/CN/10. Ethernet LAN IEEE 802.3/LAN.tcl +65 -0
- noshot/data/AIDS CN NLP/CN/10. Ethernet LAN IEEE 802.3/analysis.awk +44 -0
- noshot/data/AIDS CN NLP/CN/10. Ethernet LAN IEEE 802.3/output.png +0 -0
- noshot/data/AIDS CN NLP/CN/10. Ethernet LAN IEEE 802.3/procedure.png +0 -0
- noshot/data/AIDS CN NLP/CN/11. Wireless LAN IEEE 802.11/complexdcf.tcl +229 -0
- noshot/data/AIDS CN NLP/CN/11. Wireless LAN IEEE 802.11/output.png +0 -0
- noshot/data/AIDS CN NLP/CN/11. Wireless LAN IEEE 802.11/procedure.png +0 -0
- noshot/data/AIDS CN NLP/CN/2. File Transfer/file_to_send.txt +2 -0
- noshot/data/AIDS CN NLP/CN/2. File Transfer/filetransfer.java +119 -0
- noshot/data/AIDS CN NLP/CN/2. File Transfer/output.png +0 -0
- noshot/data/AIDS CN NLP/CN/2. File Transfer/procedure.png +0 -0
- noshot/data/AIDS CN NLP/CN/3. RMI (Remote Method Invocation)/output.png +0 -0
- noshot/data/AIDS CN NLP/CN/3. RMI (Remote Method Invocation)/procedure.png +0 -0
- noshot/data/AIDS CN NLP/CN/3. RMI (Remote Method Invocation)/rmi.java +56 -0
- noshot/data/AIDS CN NLP/CN/4. Wired Network/output.png +0 -0
- noshot/data/AIDS CN NLP/CN/4. Wired Network/procedure.png +0 -0
- noshot/data/AIDS CN NLP/CN/4. Wired Network/wired.awk +25 -0
- noshot/data/AIDS CN NLP/CN/4. Wired Network/wired.tcl +81 -0
- noshot/data/AIDS CN NLP/CN/5. Wireless Network/output.png +0 -0
- noshot/data/AIDS CN NLP/CN/5. Wireless Network/procedure.png +0 -0
- noshot/data/AIDS CN NLP/CN/5. Wireless Network/wireless.awk +27 -0
- noshot/data/AIDS CN NLP/CN/5. Wireless Network/wireless.tcl +153 -0
- noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Sack And Vegas/analysis.awk +27 -0
- noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Sack And Vegas/output.png +0 -0
- noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Sack And Vegas/sack.tcl +86 -0
- noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Sack And Vegas/vegas.tcl +86 -0
- noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Tahoe And Reno/analysis.awk +28 -0
- noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Tahoe And Reno/output.png +0 -0
- noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Tahoe And Reno/reno.tcl +78 -0
- noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Tahoe And Reno/tahoe.tcl +79 -0
- noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Flow Control/analysis.awk +27 -0
- noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Flow Control/flow.tcl +163 -0
- noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Flow Control/output.png +0 -0
- noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/procedure.png +0 -0
- noshot/data/AIDS CN NLP/CN/7. Link State And Distance Vector Routing/DV.tcl +111 -0
- noshot/data/AIDS CN NLP/CN/7. Link State And Distance Vector Routing/LS.tcl +106 -0
- noshot/data/AIDS CN NLP/CN/7. Link State And Distance Vector Routing/analysis.awk +36 -0
- noshot/data/AIDS CN NLP/CN/7. Link State And Distance Vector Routing/output.png +0 -0
- noshot/data/AIDS CN NLP/CN/7. Link State And Distance Vector Routing/procedure.png +0 -0
- noshot/data/AIDS CN NLP/CN/8. Multicast And Broadcast Routing/analysis.awk +20 -0
- noshot/data/AIDS CN NLP/CN/8. Multicast And Broadcast Routing/broadcast.tcl +76 -0
- noshot/data/AIDS CN NLP/CN/8. Multicast And Broadcast Routing/multicast.tcl +103 -0
- noshot/data/AIDS CN NLP/CN/8. Multicast And Broadcast Routing/output.png +0 -0
- noshot/data/AIDS CN NLP/CN/8. Multicast And Broadcast Routing/procedure.png +0 -0
- noshot/data/AIDS CN NLP/CN/9. DHCP/DHCP.java +125 -0
- noshot/data/AIDS CN NLP/CN/9. DHCP/output.png +0 -0
- noshot/data/AIDS CN NLP/CN/9. DHCP/procedure.png +0 -0
- noshot/data/AIDS CN NLP/NLP/NLP 1/1-Prereqs.py +18 -0
- noshot/data/AIDS CN NLP/NLP/NLP 1/2-Chi2test.py +83 -0
- noshot/data/AIDS CN NLP/NLP/NLP 1/2-T-test.py +79 -0
- noshot/data/AIDS CN NLP/NLP/NLP 1/3-WSD-nb.py +53 -0
- noshot/data/AIDS CN NLP/NLP/NLP 1/4-Hindle-Rooth.py +53 -0
- noshot/data/AIDS CN NLP/NLP/NLP 1/5-HMM-Trellis.py +82 -0
- noshot/data/AIDS CN NLP/NLP/NLP 1/6-HMM-Viterbi.py +16 -0
- noshot/data/AIDS CN NLP/NLP/NLP 1/7-PCFG-parsetree.py +15 -0
- noshot/data/AIDS CN NLP/NLP/NLP 1/Chi2test.ipynb +285 -0
- noshot/data/AIDS CN NLP/NLP/NLP 1/Hindle-Rooth.ipynb +179 -0
- noshot/data/AIDS CN NLP/NLP/NLP 1/Lab 10 - Text generator using LSTM.ipynb +1461 -0
- noshot/data/AIDS CN NLP/NLP/NLP 1/Lab 11 NMT.ipynb +2307 -0
- noshot/data/AIDS CN NLP/NLP/NLP 1/PCFG.ipynb +134 -0
- noshot/data/AIDS CN NLP/NLP/NLP 1/Prereqs.ipynb +131 -0
- noshot/data/AIDS CN NLP/NLP/NLP 1/T test.ipynb +252 -0
- noshot/data/AIDS CN NLP/NLP/NLP 1/TFIDF BOW.ipynb +171 -0
- noshot/data/AIDS CN NLP/NLP/NLP 1/Trellis.ipynb +244 -0
- noshot/data/AIDS CN NLP/NLP/NLP 1/WSD.ipynb +645 -0
- noshot/data/AIDS CN NLP/NLP/NLP 1/Word2Vec.ipynb +93 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab01(tokenizer)/tokenizer.ipynb +370 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab01(tokenizer)/training_tokenizer.txt +6 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab02(stemming)/exp0.ipynb +274 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab02(stemming)/lab2.ipynb +905 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab02(stemming)/test.txt +1 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab02(stemming)/tokenizing.ipynb +272 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab03(parse-tree)/collocation.ipynb +332 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab03(parse-tree)/lab3.ipynb +549 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab03(parse-tree)/nlp.txt +1 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab04(collocation)/Lab4-NLP-Exp-2.ipynb +817 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab04(collocation)/collocation.ipynb +332 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab05(WSD)/NLP-Lab-5-Exp3.ipynb +231 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab05(WSD)/word-sense-disambiguation.ipynb +507 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab06(additional-exercise)/lab6.ipynb +134 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab07(HMM,Viterbi)/NLP Exp 4.ipynb +255 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab07(HMM,Viterbi)/NLP_Exp_5.ipynb +159 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab08(PCFG)/PCFG.ipynb +282 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab09-Hindle-rooth&MLP/Lab 9 - MLP classifier.ipynb +670 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab09-Hindle-rooth&MLP/MLP-alternative-code.ipynb +613 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab09-Hindle-rooth&MLP/hindle-rooth-algorithm.ipynb +74 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab10(LSTM)/Lab_10_Text_generator_using_LSTM.ipynb +480 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab11(Viterbi-PCFG,Machine-translation)/Machine-translation.ipynb +445 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab11(Viterbi-PCFG,Machine-translation)/Viterbi-PCFG.ipynb +105 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab11(Viterbi-PCFG,Machine-translation)/corpora_tools.py +87 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab11(Viterbi-PCFG,Machine-translation)/data_utils.py +11 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab11(Viterbi-PCFG,Machine-translation)/train_translator.py +83 -0
- noshot/data/AIDS CN NLP/NLP/NLP 2/Lab12(Information-Extraction)/Information_Extraction.ipynb +201 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/Backtrack-without-Verbitri.ipynb +185 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/Backward-Procedure.ipynb +597 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/Bag_of.ipynb +1422 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/CYK-algorithm.ipynb +1067 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/Forward-Procedure.ipynb +477 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/LSTM.ipynb +1290 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/Lab 10 - Text generator using LSTM.ipynb +1461 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/Lab 11 NMT.ipynb +2307 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/NLP-LAB-4.ipynb +216 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/NLP-LAB-5.ipynb +216 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/abc.txt +6 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/ex-1-nltk.ipynb +711 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/ex-2-nlp.ipynb +267 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/exp8&9.ipynb +305 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/hind.ipynb +287 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/lab66.ipynb +752 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/leb_3.ipynb +612 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/naive_bayes_classifier.pkl +0 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/nlp_leb_1.ipynb +3008 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/nlp_leb_2.ipynb +3095 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/nlplab-9.ipynb +295 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/nltk-ex-4.ipynb +506 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/text1.txt +48 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/text2.txt +8 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/text3.txt +48 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/translation-rnn.ipynb +812 -0
- noshot/data/AIDS CN NLP/NLP/NLP 3/word2vector.ipynb +173 -0
- noshot/data/AIDS CN NLP/NLP/NLP 4/Backward Procedure Algorithm.ipynb +179 -0
- noshot/data/AIDS CN NLP/NLP/NLP 4/Chi Square Collocation.ipynb +208 -0
- noshot/data/AIDS CN NLP/NLP/NLP 4/Collocation (T test).ipynb +188 -0
- noshot/data/AIDS CN NLP/NLP/NLP 4/Experiment 1.ipynb +437 -0
- noshot/data/AIDS CN NLP/NLP/NLP 4/Forward Procedure Algorithm.ipynb +132 -0
- noshot/data/AIDS CN NLP/NLP/NLP 4/Hindle Rooth.ipynb +414 -0
- noshot/data/AIDS CN NLP/NLP/NLP 4/MachineTranslation.ipynb +368 -0
- noshot/data/AIDS CN NLP/NLP/NLP 4/Multi Layer Perceptron using MLPClassifier.ipynb +86 -0
- noshot/data/AIDS CN NLP/NLP/NLP 4/Multi Layer Perceptron using Tensorflow.ipynb +112 -0
- noshot/data/AIDS CN NLP/NLP/NLP 4/PCFG Inside Probability.ipynb +451 -0
- noshot/data/AIDS CN NLP/NLP/NLP 4/Text Generation using LSTM.ipynb +297 -0
- noshot/data/AIDS CN NLP/NLP/NLP 4/Viterbi.ipynb +310 -0
- noshot/data/AIDS CN NLP/NLP/NLP 4/Word Sense Disambiguation.ipynb +335 -0
- noshot/data/AIDS CN NLP/NLP/NLP 5/10.Text Generation using LSTM.ipynb +316 -0
- noshot/data/AIDS CN NLP/NLP/NLP 5/11.Machine Translation.ipynb +868 -0
- noshot/data/AIDS CN NLP/NLP/NLP 5/2.T and Chi2 Test.ipynb +204 -0
- noshot/data/AIDS CN NLP/NLP/NLP 5/3.Word Sense Diambiguation.ipynb +234 -0
- noshot/data/AIDS CN NLP/NLP/NLP 5/4.Hinddle and Rooth.ipynb +128 -0
- noshot/data/AIDS CN NLP/NLP/NLP 5/5.Forward and Backward.ipynb +149 -0
- noshot/data/AIDS CN NLP/NLP/NLP 5/6.Viterbi.ipynb +111 -0
- noshot/data/AIDS CN NLP/NLP/NLP 5/7.PCFG Parse Tree.ipynb +134 -0
- noshot/data/AIDS CN NLP/NLP/NLP 5/7.PCFG using cyk.ipynb +101 -0
- noshot/data/AIDS CN NLP/NLP/NLP 5/8.Bag of words and TF-IDF.ipynb +310 -0
- noshot/data/AIDS CN NLP/NLP/NLP 5/9.Word2Vector.ipynb +78 -0
- noshot/data/AIDS CN NLP/NLP/NLP 5/NLP ALL In One.ipynb +2619 -0
- noshot/data/AIDS CN NLP/NLP/NLP 5/sample1.txt +15 -0
- noshot/data/AIDS CN NLP/NLP/NLP 5/sample2.txt +4 -0
- noshot/data/AIDS CN NLP/NLP/NLP 5/word2vec_model.bin +0 -0
- noshot/data/AIDS CN NLP/NLP/NLP 6/1. Tokenize, Tagging, NER, Parse Tree.ipynb +312 -0
- noshot/data/AIDS CN NLP/NLP/NLP 6/2. T Test and Chi2 Test.ipynb +185 -0
- noshot/data/AIDS CN NLP/NLP/NLP 6/3. Naive Bayes WSD.ipynb +199 -0
- noshot/data/AIDS CN NLP/NLP/NLP 6/4. Hinddle and Rooth.ipynb +151 -0
- noshot/data/AIDS CN NLP/NLP/NLP 6/5 and 6 FWD, BWD, Viterbi.ipynb +164 -0
- noshot/data/AIDS CN NLP/NLP/NLP 6/7. PCFG using CYK.ipynb +383 -0
- noshot/data/AIDS CN NLP/NLP/NLP 6/8. BOW and TF-IDF.ipynb +252 -0
- noshot/data/AIDS CN NLP/Ubuntu CN Lab.iso +0 -0
- noshot/main.py +47 -0
- noshot-0.1.0.dist-info/LICENSE.txt +21 -0
- noshot-0.1.0.dist-info/METADATA +65 -0
- noshot-0.1.0.dist-info/RECORD +210 -0
- noshot-0.1.0.dist-info/WHEEL +5 -0
- noshot-0.1.0.dist-info/top_level.txt +1 -0
noshot/__init__.py
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
from .main import get
|
noshot/data/AIDS CN NLP/AIDS/1. Implement Basic Search Strategies/(A) Breadth First Search.ipynb
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
{
|
2
|
+
"cells": [
|
3
|
+
{
|
4
|
+
"cell_type": "code",
|
5
|
+
"execution_count": null,
|
6
|
+
"id": "d2b42a21-ddab-46e8-9926-fb21c7209107",
|
7
|
+
"metadata": {},
|
8
|
+
"outputs": [],
|
9
|
+
"source": [
|
10
|
+
"import networkx as nx\n",
|
11
|
+
"import matplotlib.pyplot as plt\n",
|
12
|
+
"\n",
|
13
|
+
"def display(graph, directed = False):\n",
|
14
|
+
" g = nx.DiGraph(graph) if directed else nx.Graph(graph)\n",
|
15
|
+
" nx.draw(g, with_labels = True)\n",
|
16
|
+
" plt.suptitle(\"Breadth First Search\")\n",
|
17
|
+
" plt.show()\n",
|
18
|
+
" plt.clf()\n",
|
19
|
+
"def print_path(node, parent):\n",
|
20
|
+
" if node != None:\n",
|
21
|
+
" return print_path(parent[node], parent) + [node]\n",
|
22
|
+
" return []\n",
|
23
|
+
"def BFS(graph, start, goal):\n",
|
24
|
+
" queue = [start]\n",
|
25
|
+
" visited = []\n",
|
26
|
+
" parent = {start : None}\n",
|
27
|
+
" while queue:\n",
|
28
|
+
" node = queue.pop(0)#First element\n",
|
29
|
+
" visited.append(node)\n",
|
30
|
+
" if node == goal:\n",
|
31
|
+
" print(f\"Result(BFS {start} to {goal}):\",print_path(node, parent))\n",
|
32
|
+
" return True \n",
|
33
|
+
" for adj in graph[node]:\n",
|
34
|
+
" if adj not in visited and adj not in queue:\n",
|
35
|
+
" queue.append(adj)\n",
|
36
|
+
" parent[adj] = node\n",
|
37
|
+
" print(f\"Result(BFS {start} to {goal}): No Solution\")\n",
|
38
|
+
" return False\n",
|
39
|
+
"def get_graph(directed = False):\n",
|
40
|
+
" graph = {}\n",
|
41
|
+
" print(\"Enter edge (u, v)\")\n",
|
42
|
+
" print(\"[PRESS ENTER TO STOP]\")\n",
|
43
|
+
" x = input()\n",
|
44
|
+
" while x:\n",
|
45
|
+
" x = x.split(maxsplit = 1)\n",
|
46
|
+
" u, adj = x[0], {v.strip() for v in x[1].strip(' []').split(',') if v}\n",
|
47
|
+
" graph[u] = graph.get(u,set()) | adj\n",
|
48
|
+
" for v in adj:\n",
|
49
|
+
" graph[v] = graph.get(v,set()) | ({u} if not directed else set())\n",
|
50
|
+
" x = input()\n",
|
51
|
+
" return graph\n",
|
52
|
+
"def example():\n",
|
53
|
+
" graph = {\"A\" : [\"B\",\"C\",\"D\"],\n",
|
54
|
+
" \"B\" : [\"A\",\"E\"],\n",
|
55
|
+
" \"C\" : [\"A\",\"E\",\"F\"],\n",
|
56
|
+
" \"D\" : [\"A\",\"F\"],\n",
|
57
|
+
" \"E\" : [\"B\",\"G\",\"C\"],\n",
|
58
|
+
" \"F\" : [\"D\",\"C\",\"G\"],\n",
|
59
|
+
" \"G\" : [\"E\",\"F\"]}\n",
|
60
|
+
" display(graph)\n",
|
61
|
+
" print(graph)\n",
|
62
|
+
" BFS(graph, \"A\", \"F\")\n",
|
63
|
+
" \n",
|
64
|
+
"def main():\n",
|
65
|
+
" #example();return #Uncomment to run the example\n",
|
66
|
+
" graph = get_graph(directed = False)#undirected graph\n",
|
67
|
+
" source, goal = input(\"Enter source and goal: \").split()\n",
|
68
|
+
" display(graph, directed = False)\n",
|
69
|
+
" print(graph)\n",
|
70
|
+
" BFS(graph, source, goal)\n",
|
71
|
+
" \n",
|
72
|
+
" #Sample output\n",
|
73
|
+
" #Enter edge (u, v)\n",
|
74
|
+
" #[PRESS ENTER TO STOP]\n",
|
75
|
+
" #A B\n",
|
76
|
+
" #A C\n",
|
77
|
+
" #A D\n",
|
78
|
+
" #B E\n",
|
79
|
+
" #C E\n",
|
80
|
+
" #C F\n",
|
81
|
+
" #D F\n",
|
82
|
+
" #E G\n",
|
83
|
+
" #F G\n",
|
84
|
+
"\n",
|
85
|
+
" #Enter source and goal: A F\n",
|
86
|
+
" #Result(BFS A to F): ['A', 'D', 'F']\n",
|
87
|
+
"main()"
|
88
|
+
]
|
89
|
+
}
|
90
|
+
],
|
91
|
+
"metadata": {
|
92
|
+
"kernelspec": {
|
93
|
+
"display_name": "Python 3 (ipykernel)",
|
94
|
+
"language": "python",
|
95
|
+
"name": "python3"
|
96
|
+
},
|
97
|
+
"language_info": {
|
98
|
+
"codemirror_mode": {
|
99
|
+
"name": "ipython",
|
100
|
+
"version": 3
|
101
|
+
},
|
102
|
+
"file_extension": ".py",
|
103
|
+
"mimetype": "text/x-python",
|
104
|
+
"name": "python",
|
105
|
+
"nbconvert_exporter": "python",
|
106
|
+
"pygments_lexer": "ipython3",
|
107
|
+
"version": "3.12.4"
|
108
|
+
}
|
109
|
+
},
|
110
|
+
"nbformat": 4,
|
111
|
+
"nbformat_minor": 5
|
112
|
+
}
|
noshot/data/AIDS CN NLP/AIDS/1. Implement Basic Search Strategies/(B) Depth First Search.ipynb
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
{
|
2
|
+
"cells": [
|
3
|
+
{
|
4
|
+
"cell_type": "code",
|
5
|
+
"execution_count": null,
|
6
|
+
"id": "a5759a8d-8689-4924-ae96-afd00a7f2910",
|
7
|
+
"metadata": {},
|
8
|
+
"outputs": [],
|
9
|
+
"source": [
|
10
|
+
"import networkx as nx\n",
|
11
|
+
"import matplotlib.pyplot as plt\n",
|
12
|
+
"def display(graph, directed = False):\n",
|
13
|
+
" g = nx.DiGraph(graph) if directed else nx.Graph(graph)\n",
|
14
|
+
" nx.draw(g, with_labels = True)\n",
|
15
|
+
" plt.suptitle(\"Depth First Search\")\n",
|
16
|
+
" plt.show()\n",
|
17
|
+
" plt.clf()\n",
|
18
|
+
"def print_path(node, parent):\n",
|
19
|
+
" if node != None:\n",
|
20
|
+
" return print_path(parent[node], parent) + [node]\n",
|
21
|
+
" return []\n",
|
22
|
+
"def DFS(graph, start, goal):\n",
|
23
|
+
" stack = [start]\n",
|
24
|
+
" visited = []\n",
|
25
|
+
" parent = {start : None}\n",
|
26
|
+
" while stack:\n",
|
27
|
+
" node = stack.pop()#last element\n",
|
28
|
+
" visited.append(node)\n",
|
29
|
+
" if node == goal:\n",
|
30
|
+
" print(f\"Result(DFS {start} to {goal}):\",print_path(node, parent))\n",
|
31
|
+
" return True\n",
|
32
|
+
" for adj in graph[node]:\n",
|
33
|
+
" if adj not in visited and adj not in stack:\n",
|
34
|
+
" stack.append(adj)\n",
|
35
|
+
" parent[adj] = node\n",
|
36
|
+
" print(f\"Result(DFS {start} to {goal}): No Solution\")\n",
|
37
|
+
" return False\n",
|
38
|
+
"def get_graph(directed = False):\n",
|
39
|
+
" graph = {}\n",
|
40
|
+
" print(\"Enter edge (u, v)\")\n",
|
41
|
+
" print(\"[PRESS ENTER TO STOP]\")\n",
|
42
|
+
" x = input()\n",
|
43
|
+
" while x:\n",
|
44
|
+
" x = x.split(maxsplit = 1)\n",
|
45
|
+
" u, adj = x[0], {v.strip() for v in x[1].strip(' []').split(',') if v}\n",
|
46
|
+
" graph[u] = graph.get(u,set()) | adj\n",
|
47
|
+
" for v in adj:\n",
|
48
|
+
" graph[v] = graph.get(v,set()) | ({u} if not directed else set())\n",
|
49
|
+
" x = input()\n",
|
50
|
+
" return graph\n",
|
51
|
+
"def example():\n",
|
52
|
+
" graph = {\"A\" : [\"B\",\"C\",\"D\"],\n",
|
53
|
+
" \"B\" : [\"A\",\"E\"],\n",
|
54
|
+
" \"C\" : [\"A\",\"E\",\"F\"],\n",
|
55
|
+
" \"D\" : [\"A\",\"F\"],\n",
|
56
|
+
" \"E\" : [\"B\",\"G\",\"C\"],\n",
|
57
|
+
" \"F\" : [\"D\",\"C\",\"G\"],\n",
|
58
|
+
" \"G\" : [\"E\",\"F\"]}\n",
|
59
|
+
" display(graph)\n",
|
60
|
+
" print(graph)\n",
|
61
|
+
" DFS(graph, \"A\", \"F\")\n",
|
62
|
+
"\n",
|
63
|
+
"def main():\n",
|
64
|
+
" #example();return #Uncomment to run the example\n",
|
65
|
+
" graph = get_graph(directed = False)#undirected graph\n",
|
66
|
+
" source, goal = input(\"Enter source and goal: \").split()\n",
|
67
|
+
" display(graph, directed = False)\n",
|
68
|
+
" print(graph)\n",
|
69
|
+
" DFS(graph, source, goal)\n",
|
70
|
+
"\n",
|
71
|
+
" #Sample output\n",
|
72
|
+
" #Enter edge (u, v)\n",
|
73
|
+
" #[PRESS ENTER TO STOP]\n",
|
74
|
+
" #A B\n",
|
75
|
+
" #A C\n",
|
76
|
+
" #A D\n",
|
77
|
+
" #B E\n",
|
78
|
+
" #C E\n",
|
79
|
+
" #C F\n",
|
80
|
+
" #D F\n",
|
81
|
+
" #E G\n",
|
82
|
+
" #F G\n",
|
83
|
+
"\n",
|
84
|
+
" #Enter source and goal: A F\n",
|
85
|
+
" #Result(DFS A to F): ['A', 'B', 'E', 'G', 'F']\n",
|
86
|
+
"main()"
|
87
|
+
]
|
88
|
+
}
|
89
|
+
],
|
90
|
+
"metadata": {
|
91
|
+
"kernelspec": {
|
92
|
+
"display_name": "Python 3 (ipykernel)",
|
93
|
+
"language": "python",
|
94
|
+
"name": "python3"
|
95
|
+
},
|
96
|
+
"language_info": {
|
97
|
+
"codemirror_mode": {
|
98
|
+
"name": "ipython",
|
99
|
+
"version": 3
|
100
|
+
},
|
101
|
+
"file_extension": ".py",
|
102
|
+
"mimetype": "text/x-python",
|
103
|
+
"name": "python",
|
104
|
+
"nbconvert_exporter": "python",
|
105
|
+
"pygments_lexer": "ipython3",
|
106
|
+
"version": "3.12.4"
|
107
|
+
}
|
108
|
+
},
|
109
|
+
"nbformat": 4,
|
110
|
+
"nbformat_minor": 5
|
111
|
+
}
|
noshot/data/AIDS CN NLP/AIDS/1. Implement Basic Search Strategies/(C) Uniform Cost Search.ipynb
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
{
|
2
|
+
"cells": [
|
3
|
+
{
|
4
|
+
"cell_type": "code",
|
5
|
+
"execution_count": null,
|
6
|
+
"id": "500c2d15-c6aa-4dc6-869a-ab13b598cf36",
|
7
|
+
"metadata": {},
|
8
|
+
"outputs": [],
|
9
|
+
"source": []
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"cell_type": "code",
|
13
|
+
"execution_count": null,
|
14
|
+
"id": "1ee3b7e9-ef2b-4e25-b40c-89b66bfb7d09",
|
15
|
+
"metadata": {},
|
16
|
+
"outputs": [],
|
17
|
+
"source": [
|
18
|
+
"import networkx as nx\n",
|
19
|
+
"import matplotlib.pyplot as plt\n",
|
20
|
+
"def display(graph, directed = False):\n",
|
21
|
+
" graph = {u : {v : {'weight' : graph[u][v]} for v in graph[u]} for u in graph}\n",
|
22
|
+
" g = nx.from_dict_of_dicts(graph)\n",
|
23
|
+
" pos = nx.circular_layout(g)\n",
|
24
|
+
" nx.draw(g, pos, with_labels = True)\n",
|
25
|
+
" nx.draw_networkx_edge_labels(g, pos, edge_labels = nx.get_edge_attributes(g, 'weight'))\n",
|
26
|
+
" plt.suptitle(\"Uniform Cost Search\")\n",
|
27
|
+
" plt.show()\n",
|
28
|
+
" plt.clf()\n",
|
29
|
+
"def print_path(node, parent):\n",
|
30
|
+
" if node != None:\n",
|
31
|
+
" return print_path(parent[node], parent) + [node]\n",
|
32
|
+
" return []\n",
|
33
|
+
"def UCS(graph, start, goal):\n",
|
34
|
+
" queue = [start]\n",
|
35
|
+
" visited = []\n",
|
36
|
+
" parent = {start : None}\n",
|
37
|
+
" cost = {start : 0}\n",
|
38
|
+
" while queue:\n",
|
39
|
+
" queue.sort(key = lambda x : cost[x])\n",
|
40
|
+
" node = queue.pop(0)\n",
|
41
|
+
" visited.append(node)\n",
|
42
|
+
" if node == goal:\n",
|
43
|
+
" print(f\"Result(UCS {start} to {goal}):\",print_path(node, parent),\"Path cost =\",cost[node])\n",
|
44
|
+
" return True\n",
|
45
|
+
" for adj in graph[node]:\n",
|
46
|
+
" if adj not in visited:\n",
|
47
|
+
" new_cost = cost[node] + graph[node][adj]\n",
|
48
|
+
" if adj not in queue:\n",
|
49
|
+
" queue.append(adj)\n",
|
50
|
+
" elif new_cost > cost[adj]:\n",
|
51
|
+
" continue\n",
|
52
|
+
" cost[adj] = new_cost\n",
|
53
|
+
" parent[adj] = node\n",
|
54
|
+
" print(f\"Result(UCS {start} to {goal}): No Solution\")\n",
|
55
|
+
" return False\n",
|
56
|
+
"def get_graph(directed = False):\n",
|
57
|
+
" graph = {}\n",
|
58
|
+
" print(\"Enter edge (u, v, weight)\")\n",
|
59
|
+
" print(\"[PRESS ENTER TO STOP]\")\n",
|
60
|
+
" x = input()\n",
|
61
|
+
" while x:\n",
|
62
|
+
" x = x.split(maxsplit = 1)\n",
|
63
|
+
" u, adj = x[0], [v.strip(' ()') for v in x[1].strip('[]').split(',') if v] \n",
|
64
|
+
" if len(adj) == 1:\n",
|
65
|
+
" v, w = adj[0].split()\n",
|
66
|
+
" adj = {v : int(w)}\n",
|
67
|
+
" else:\n",
|
68
|
+
" adj = {v : int(w) for v, w in zip(adj[::2],adj[1::2])}\n",
|
69
|
+
" graph[u] = graph.get(u, {}) | adj\n",
|
70
|
+
" for v, w in adj.items():\n",
|
71
|
+
" graph[v] = graph.get(v, {}) | ({u : w} if not directed else {})\n",
|
72
|
+
" x = input()\n",
|
73
|
+
" return graph\n",
|
74
|
+
"def example():\n",
|
75
|
+
" graph = {\"A\" : {\"B\":9,\"C\":4,\"D\":7},\n",
|
76
|
+
" \"B\" : {\"A\":9,\"E\":11},\n",
|
77
|
+
" \"C\" : {\"A\":4,\"E\":17,\"F\":12},\n",
|
78
|
+
" \"D\" : {\"A\":7,\"F\":14},\n",
|
79
|
+
" \"E\" : {\"B\":11,\"G\":5,\"C\":17},\n",
|
80
|
+
" \"F\" : {\"D\":14,\"C\":12,\"G\":9},\n",
|
81
|
+
" \"G\" : {\"E\":5,\"F\":9}}\n",
|
82
|
+
" display(graph)\n",
|
83
|
+
" print(graph)\n",
|
84
|
+
" UCS(graph, \"A\", \"G\")\n",
|
85
|
+
"\n",
|
86
|
+
"def main():\n",
|
87
|
+
" #example();return #Uncomment to run the example\n",
|
88
|
+
" graph = get_graph(directed = False)#undirected graph\n",
|
89
|
+
" source, goal = input(\"Enter source and goal: \").split()\n",
|
90
|
+
" display(graph, directed = False)\n",
|
91
|
+
" print(graph)\n",
|
92
|
+
" UCS(graph, source, goal)\n",
|
93
|
+
"\n",
|
94
|
+
" #Sample output\n",
|
95
|
+
" #Enter edge (u, v, weight) \n",
|
96
|
+
" #[Press Enter To Stop]\n",
|
97
|
+
" #A B 9\n",
|
98
|
+
" #A C 4\n",
|
99
|
+
" #A D 7\n",
|
100
|
+
" #B E 11\n",
|
101
|
+
" #C E 17\n",
|
102
|
+
" #C F 12\n",
|
103
|
+
" #D F 14\n",
|
104
|
+
" #E G 5\n",
|
105
|
+
" #F G 9\n",
|
106
|
+
" \n",
|
107
|
+
" #Enter source and goal: A G\n",
|
108
|
+
" #Result(UCS A to G): ['A', 'B', 'E', 'G'] Path cost = 25\n",
|
109
|
+
"main()"
|
110
|
+
]
|
111
|
+
}
|
112
|
+
],
|
113
|
+
"metadata": {
|
114
|
+
"kernelspec": {
|
115
|
+
"display_name": "Python 3 (ipykernel)",
|
116
|
+
"language": "python",
|
117
|
+
"name": "python3"
|
118
|
+
},
|
119
|
+
"language_info": {
|
120
|
+
"codemirror_mode": {
|
121
|
+
"name": "ipython",
|
122
|
+
"version": 3
|
123
|
+
},
|
124
|
+
"file_extension": ".py",
|
125
|
+
"mimetype": "text/x-python",
|
126
|
+
"name": "python",
|
127
|
+
"nbconvert_exporter": "python",
|
128
|
+
"pygments_lexer": "ipython3",
|
129
|
+
"version": "3.12.4"
|
130
|
+
}
|
131
|
+
},
|
132
|
+
"nbformat": 4,
|
133
|
+
"nbformat_minor": 5
|
134
|
+
}
|
noshot/data/AIDS CN NLP/AIDS/1. Implement Basic Search Strategies/(D) Depth Limites Search.ipynb
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
{
|
2
|
+
"cells": [
|
3
|
+
{
|
4
|
+
"cell_type": "code",
|
5
|
+
"execution_count": null,
|
6
|
+
"id": "ddb94be1-e76f-45bf-9c2f-2e02f4a98a9f",
|
7
|
+
"metadata": {},
|
8
|
+
"outputs": [],
|
9
|
+
"source": [
|
10
|
+
"import networkx as nx\n",
|
11
|
+
"import matplotlib.pyplot as plt\n",
|
12
|
+
"def display(graph, directed = False):\n",
|
13
|
+
" g = nx.DiGraph(graph) if directed else nx.Graph(graph)\n",
|
14
|
+
" nx.draw(g, with_labels = True)\n",
|
15
|
+
" plt.suptitle(\"Depth Limited Search\")\n",
|
16
|
+
" plt.show()\n",
|
17
|
+
" plt.clf()\n",
|
18
|
+
"def print_path(node, parent):\n",
|
19
|
+
" if node != None:\n",
|
20
|
+
" return print_path(parent[node], parent) + [node]\n",
|
21
|
+
" return []\n",
|
22
|
+
"def DLS(graph, start, goal, limit):\n",
|
23
|
+
" result = recursive_dls(graph, start, goal, limit, [start])\n",
|
24
|
+
" print(f\"Result(DLS {start} to {goal}):\",result,\"at depth limit =\",limit)\n",
|
25
|
+
"def recursive_dls(graph, node, goal, limit, visited):\n",
|
26
|
+
" if node == goal:\n",
|
27
|
+
" return [node]\n",
|
28
|
+
" elif limit == 0:\n",
|
29
|
+
" return 'cutoff'\n",
|
30
|
+
" else:\n",
|
31
|
+
" status = 'failure'\n",
|
32
|
+
" for adj in graph[node]:\n",
|
33
|
+
" if adj not in visited:\n",
|
34
|
+
" visited.append(adj)\n",
|
35
|
+
" result = recursive_dls(graph, adj, goal, limit - 1, visited)\n",
|
36
|
+
" if result == 'cutoff':\n",
|
37
|
+
" status = 'cutoff'\n",
|
38
|
+
" visited.remove(adj)\n",
|
39
|
+
" elif result != 'failure':\n",
|
40
|
+
" return [node] + result\n",
|
41
|
+
" return status\n",
|
42
|
+
"def get_graph(directed = False):\n",
|
43
|
+
" graph = {}\n",
|
44
|
+
" print(\"Enter edge (u, v)\")\n",
|
45
|
+
" print(\"[PRESS ENTER TO STOP]\")\n",
|
46
|
+
" x = input()\n",
|
47
|
+
" while x:\n",
|
48
|
+
" x = x.split(maxsplit = 1)\n",
|
49
|
+
" u, adj = x[0], {v.strip() for v in x[1].strip(' []').split(',') if v}\n",
|
50
|
+
" graph[u] = graph.get(u,set()) | adj\n",
|
51
|
+
" for v in adj:\n",
|
52
|
+
" graph[v] = graph.get(v,set()) | ({u} if not directed else set())\n",
|
53
|
+
" x = input()\n",
|
54
|
+
" return graph\n",
|
55
|
+
"def example():\n",
|
56
|
+
" graph = {\"A\" : [\"B\",\"C\",\"D\"],\n",
|
57
|
+
" \"B\" : [\"A\",\"E\"],\n",
|
58
|
+
" \"C\" : [\"A\",\"E\",\"F\"],\n",
|
59
|
+
" \"D\" : [\"A\",\"F\"],\n",
|
60
|
+
" \"E\" : [\"B\",\"G\",\"C\"],\n",
|
61
|
+
" \"F\" : [\"D\",\"C\",\"G\"],\n",
|
62
|
+
" \"G\" : [\"E\",\"F\"]}\n",
|
63
|
+
" display(graph)\n",
|
64
|
+
" print(graph)\n",
|
65
|
+
" DLS(graph, \"A\", \"F\", 3)\n",
|
66
|
+
"\n",
|
67
|
+
"def main():\n",
|
68
|
+
" #example();return #Uncomment to run the example\n",
|
69
|
+
" graph = get_graph(directed = False)#undirected graph\n",
|
70
|
+
" source, goal, limit = input(\"Enter source, goal and depthlimit: \").split() \n",
|
71
|
+
" display(graph, directed = False)\n",
|
72
|
+
" print(graph)\n",
|
73
|
+
" DLS(graph, source, goal, int(limit))\n",
|
74
|
+
"\n",
|
75
|
+
" #Sample output\n",
|
76
|
+
" #Enter edge (u, v)\n",
|
77
|
+
" #[Press Enter To Stop]\n",
|
78
|
+
" #A B\n",
|
79
|
+
" #A C\n",
|
80
|
+
" #A D\n",
|
81
|
+
" #B E\n",
|
82
|
+
" #C E\n",
|
83
|
+
" #C F\n",
|
84
|
+
" #D F\n",
|
85
|
+
" #E G\n",
|
86
|
+
" #F G\n",
|
87
|
+
"\n",
|
88
|
+
" #Enter source, goal and depthlimit: A G 3\n",
|
89
|
+
" #Result(DLS A to G): ['A', 'D', 'F', 'G'] at depth limit = 3\n",
|
90
|
+
"main()"
|
91
|
+
]
|
92
|
+
}
|
93
|
+
],
|
94
|
+
"metadata": {
|
95
|
+
"kernelspec": {
|
96
|
+
"display_name": "Python 3 (ipykernel)",
|
97
|
+
"language": "python",
|
98
|
+
"name": "python3"
|
99
|
+
},
|
100
|
+
"language_info": {
|
101
|
+
"codemirror_mode": {
|
102
|
+
"name": "ipython",
|
103
|
+
"version": 3
|
104
|
+
},
|
105
|
+
"file_extension": ".py",
|
106
|
+
"mimetype": "text/x-python",
|
107
|
+
"name": "python",
|
108
|
+
"nbconvert_exporter": "python",
|
109
|
+
"pygments_lexer": "ipython3",
|
110
|
+
"version": "3.12.4"
|
111
|
+
}
|
112
|
+
},
|
113
|
+
"nbformat": 4,
|
114
|
+
"nbformat_minor": 5
|
115
|
+
}
|
noshot/data/AIDS CN NLP/AIDS/1. Implement Basic Search Strategies/(E) Iterative Deepening DFS.ipynb
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
{
|
2
|
+
"cells": [
|
3
|
+
{
|
4
|
+
"cell_type": "code",
|
5
|
+
"execution_count": null,
|
6
|
+
"id": "604537d7-a687-4bb1-b77f-aae948b257f0",
|
7
|
+
"metadata": {},
|
8
|
+
"outputs": [],
|
9
|
+
"source": [
|
10
|
+
"import networkx as nx\n",
|
11
|
+
"import matplotlib.pyplot as plt\n",
|
12
|
+
"def display(graph, directed = False):\n",
|
13
|
+
" g = nx.DiGraph(graph) if directed else nx.Graph(graph)\n",
|
14
|
+
" nx.draw(g, with_labels = True)\n",
|
15
|
+
" plt.suptitle(\"Iterative Deepening Depth First Search\")\n",
|
16
|
+
" plt.show()\n",
|
17
|
+
" plt.clf()\n",
|
18
|
+
"def print_path(node, parent):\n",
|
19
|
+
" if node != None:\n",
|
20
|
+
" return print_path(parent[node], parent) + [node]\n",
|
21
|
+
" return []\n",
|
22
|
+
"def IDS(graph, start, goal):\n",
|
23
|
+
" depth = 0\n",
|
24
|
+
" while True:\n",
|
25
|
+
" result = recursive_dls(graph, start, goal, depth, [start])\n",
|
26
|
+
" print(f\"Result(IDS/IDDFS {start} to {goal}):\",result,\"at depth limit =\",depth)\n",
|
27
|
+
" if result != 'cutoff':\n",
|
28
|
+
" return\n",
|
29
|
+
" depth += 1\n",
|
30
|
+
"def recursive_dls(graph, node, goal, limit, visited):\n",
|
31
|
+
" if node == goal:\n",
|
32
|
+
" return [node]\n",
|
33
|
+
" elif limit == 0:\n",
|
34
|
+
" return 'cutoff'\n",
|
35
|
+
" else:\n",
|
36
|
+
" status = 'failure'\n",
|
37
|
+
" for adj in graph[node]:\n",
|
38
|
+
" if adj not in visited:\n",
|
39
|
+
" visited.append(adj)\n",
|
40
|
+
" result = recursive_dls(graph, adj, goal, limit - 1, visited)\n",
|
41
|
+
" if result == 'cutoff':\n",
|
42
|
+
" status = 'cutoff'\n",
|
43
|
+
" visited.remove(adj)\n",
|
44
|
+
" elif result != 'failure':\n",
|
45
|
+
" return [node] + result\n",
|
46
|
+
" return status\n",
|
47
|
+
"def get_graph(directed = False):\n",
|
48
|
+
" graph = {}\n",
|
49
|
+
" print(\"Enter edge (u, v)\")\n",
|
50
|
+
" print(\"[PRESS ENTER TO STOP]\")\n",
|
51
|
+
" x = input()\n",
|
52
|
+
" while x:\n",
|
53
|
+
" x = x.split(maxsplit = 1)\n",
|
54
|
+
" u, adj = x[0], {v.strip() for v in x[1].strip(' []').split(',') if v}\n",
|
55
|
+
" graph[u] = graph.get(u,set()) | adj\n",
|
56
|
+
" for v in adj:\n",
|
57
|
+
" graph[v] = graph.get(v,set()) | ({u} if not directed else set())\n",
|
58
|
+
" x = input()\n",
|
59
|
+
" return graph\n",
|
60
|
+
"def example():\n",
|
61
|
+
" graph = {\"A\" : [\"B\",\"C\",\"D\"],\n",
|
62
|
+
" \"B\" : [\"A\",\"E\"],\n",
|
63
|
+
" \"C\" : [\"A\",\"E\",\"F\"],\n",
|
64
|
+
" \"D\" : [\"A\",\"F\"],\n",
|
65
|
+
" \"E\" : [\"B\",\"G\",\"C\"],\n",
|
66
|
+
" \"F\" : [\"D\",\"C\",\"G\"],\n",
|
67
|
+
" \"G\" : [\"E\",\"F\"]}\n",
|
68
|
+
" display(graph)\n",
|
69
|
+
" print(graph)\n",
|
70
|
+
" IDS(graph, \"A\", \"F\", 3)\n",
|
71
|
+
"\n",
|
72
|
+
"def main():\n",
|
73
|
+
" #example();return #Uncomment to run the example\n",
|
74
|
+
" graph = get_graph(directed = False)#undirected graph\n",
|
75
|
+
" source, goal = input(\"Enter source, goal: \").split() \n",
|
76
|
+
" display(graph, directed = False)\n",
|
77
|
+
" print(graph)\n",
|
78
|
+
" IDS(graph, source, goal)\n",
|
79
|
+
"\n",
|
80
|
+
" #Sample output\n",
|
81
|
+
" #Enter edge (u, v)\n",
|
82
|
+
" #[PRESS ENTER TO STOP]\n",
|
83
|
+
" #A B\n",
|
84
|
+
" #A C\n",
|
85
|
+
" #A D\n",
|
86
|
+
" #B E\n",
|
87
|
+
" #C E\n",
|
88
|
+
" #C F\n",
|
89
|
+
" #D F\n",
|
90
|
+
" #E G\n",
|
91
|
+
" #F G\n",
|
92
|
+
" \n",
|
93
|
+
" #Enter source, goal: A G\n",
|
94
|
+
" #Result(IDS/IDDFS): cutoff at depth limit = 0\n",
|
95
|
+
" #Result(IDS/IDDFS): cutoff at depth limit = 1\n",
|
96
|
+
" #Result(IDS/IDDFS): cutoff at depth limit = 2\n",
|
97
|
+
" #Result(IDS/IDDFS): ['A', 'D', 'F', 'G'] at depth limit = 3\n",
|
98
|
+
"main()"
|
99
|
+
]
|
100
|
+
}
|
101
|
+
],
|
102
|
+
"metadata": {
|
103
|
+
"kernelspec": {
|
104
|
+
"display_name": "Python 3 (ipykernel)",
|
105
|
+
"language": "python",
|
106
|
+
"name": "python3"
|
107
|
+
},
|
108
|
+
"language_info": {
|
109
|
+
"codemirror_mode": {
|
110
|
+
"name": "ipython",
|
111
|
+
"version": 3
|
112
|
+
},
|
113
|
+
"file_extension": ".py",
|
114
|
+
"mimetype": "text/x-python",
|
115
|
+
"name": "python",
|
116
|
+
"nbconvert_exporter": "python",
|
117
|
+
"pygments_lexer": "ipython3",
|
118
|
+
"version": "3.12.4"
|
119
|
+
}
|
120
|
+
},
|
121
|
+
"nbformat": 4,
|
122
|
+
"nbformat_minor": 5
|
123
|
+
}
|