Skip to content

Commit a87401d

Browse files
updating
1 parent b36d13f commit a87401d

File tree

3 files changed

+2654
-2577
lines changed

3 files changed

+2654
-2577
lines changed

.ipynb_checkpoints/Simple Search engine-checkpoint.ipynb

Lines changed: 119 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
{
22
"cells": [
3-
{
4-
"cell_type": "markdown",
5-
"id": "b7571819",
6-
"metadata": {},
7-
"source": [
8-
"<span style=\"font-family: Cambria;\"></span>"
9-
]
10-
},
113
{
124
"cell_type": "markdown",
135
"id": "123548c8",
@@ -66,7 +58,7 @@
6658
},
6759
{
6860
"cell_type": "code",
69-
"execution_count": 1,
61+
"execution_count": 13,
7062
"id": "82632cbb",
7163
"metadata": {
7264
"scrolled": false
@@ -97,7 +89,7 @@
9789
},
9890
{
9991
"cell_type": "code",
100-
"execution_count": 2,
92+
"execution_count": 14,
10193
"id": "df57de08",
10294
"metadata": {},
10395
"outputs": [],
@@ -134,7 +126,7 @@
134126
},
135127
{
136128
"cell_type": "code",
137-
"execution_count": 4,
129+
"execution_count": 7,
138130
"id": "7a9e6335",
139131
"metadata": {
140132
"scrolled": true
@@ -155,7 +147,7 @@
155147
"True"
156148
]
157149
},
158-
"execution_count": 4,
150+
"execution_count": 7,
159151
"metadata": {},
160152
"output_type": "execute_result"
161153
}
@@ -167,7 +159,7 @@
167159
},
168160
{
169161
"cell_type": "code",
170-
"execution_count": 5,
162+
"execution_count": 15,
171163
"id": "b6cfa98c",
172164
"metadata": {
173165
"scrolled": true
@@ -956,7 +948,7 @@
956948
},
957949
{
958950
"cell_type": "code",
959-
"execution_count": 6,
951+
"execution_count": 16,
960952
"id": "fef00e06",
961953
"metadata": {
962954
"scrolled": true
@@ -1026,7 +1018,7 @@
10261018
"4 5 They are distinguished by their “memory” as th..."
10271019
]
10281020
},
1029-
"execution_count": 6,
1021+
"execution_count": 16,
10301022
"metadata": {},
10311023
"output_type": "execute_result"
10321024
}
@@ -1052,7 +1044,7 @@
10521044
},
10531045
{
10541046
"cell_type": "code",
1055-
"execution_count": 8,
1047+
"execution_count": 17,
10561048
"id": "be68502e",
10571049
"metadata": {
10581050
"scrolled": false
@@ -1062,31 +1054,31 @@
10621054
"name": "stdout",
10631055
"output_type": "stream",
10641056
"text": [
1065-
" 1 2 3 4 5 6 7 8 9 10 ... 587 \\\n",
1066-
"ways, 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1067-
"eyes 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1068-
"tutorials 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1069-
"fields. 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1070-
"? 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1071-
"... ... ... ... ... ... ... ... ... ... ... ... ... \n",
1072-
"attention. 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1073-
"distant 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1074-
"effort 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1075-
"lecture.digital 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1076-
"three 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1057+
" 1 2 3 4 5 6 7 8 9 10 ... 587 \\\n",
1058+
"simplicity 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1059+
"recommendations. 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1060+
"nan. 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1061+
"together 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1062+
"t=0 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1063+
"... ... ... ... ... ... ... ... ... ... ... ... ... \n",
1064+
"discusses 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1065+
"decomposing 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1066+
"(lstm) 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1067+
"digital 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1068+
"patterns 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
10771069
"\n",
1078-
" 588 589 590 591 592 593 594 595 596 \n",
1079-
"ways, 0 0 0 0 0 0 0 0 0 \n",
1080-
"eyes 0 0 0 0 0 0 0 0 0 \n",
1081-
"tutorials 0 0 0 0 0 0 0 0 0 \n",
1082-
"fields. 0 0 0 0 0 0 0 0 0 \n",
1083-
"? 0 0 0 0 0 0 0 0 0 \n",
1084-
"... ... ... ... ... ... ... ... ... ... \n",
1085-
"attention. 0 0 0 0 0 0 0 0 0 \n",
1086-
"distant 0 0 0 0 0 0 0 0 0 \n",
1087-
"effort 0 0 0 0 0 0 0 0 0 \n",
1088-
"lecture.digital 0 0 0 0 0 0 0 0 0 \n",
1089-
"three 0 0 0 0 0 0 0 0 0 \n",
1070+
" 588 589 590 591 592 593 594 595 596 \n",
1071+
"simplicity 0 0 0 0 0 0 0 0 0 \n",
1072+
"recommendations. 0 0 0 0 0 0 0 0 0 \n",
1073+
"nan. 0 0 0 0 0 0 0 0 0 \n",
1074+
"together 0 0 0 0 0 0 0 0 0 \n",
1075+
"t=0 0 0 0 1 0 0 0 0 0 \n",
1076+
"... ... ... ... ... ... ... ... ... ... \n",
1077+
"discusses 0 0 0 0 0 0 0 0 0 \n",
1078+
"decomposing 0 0 0 0 0 0 0 0 0 \n",
1079+
"(lstm) 0 0 0 0 0 0 0 0 0 \n",
1080+
"digital 0 0 0 0 0 0 0 0 0 \n",
1081+
"patterns 0 0 0 0 0 0 0 0 0 \n",
10901082
"\n",
10911083
"[2593 rows x 596 columns]\n"
10921084
]
@@ -1128,7 +1120,7 @@
11281120
},
11291121
{
11301122
"cell_type": "code",
1131-
"execution_count": 56,
1123+
"execution_count": 18,
11321124
"id": "929844ac",
11331125
"metadata": {},
11341126
"outputs": [
@@ -1198,10 +1190,95 @@
11981190
"## <span style=\"font-family: Cambria;\">Step6: </span>"
11991191
]
12001192
},
1193+
{
1194+
"cell_type": "code",
1195+
"execution_count": 24,
1196+
"id": "7f153c70",
1197+
"metadata": {},
1198+
"outputs": [
1199+
{
1200+
"name": "stdout",
1201+
"output_type": "stream",
1202+
"text": [
1203+
"Stored search input: \n",
1204+
"\n",
1205+
"\n",
1206+
"\n",
1207+
"Stored search input: \n",
1208+
"\n",
1209+
"\n",
1210+
"\n",
1211+
"Stored search input: \n",
1212+
"\n",
1213+
"\n",
1214+
"\n",
1215+
"Stored search input: \n",
1216+
"\n",
1217+
"\n",
1218+
"\n"
1219+
]
1220+
}
1221+
],
1222+
"source": [
1223+
"import tkinter as tk\n",
1224+
"from tkinter import scrolledtext\n",
1225+
"import pandas as pd\n",
1226+
"\n",
1227+
"def store_search_input():\n",
1228+
" # Get the content of the ScrolledText widget\n",
1229+
" search_query = result_text.get(1.0, tk.END)\n",
1230+
" print(f\"Stored search input: {search_query}\")\n",
1231+
"\n",
1232+
" print( search_query)\n",
1233+
"def perform_search():\n",
1234+
" # Read the ranked output file\n",
1235+
" ranked_df = pd.read_csv('ranked_output.csv')\n",
1236+
"\n",
1237+
" # Get the top 10 IDs\n",
1238+
" top_ids = ranked_df['id'].head(10).tolist()\n",
1239+
"\n",
1240+
" # Read the output file\n",
1241+
" output_df = pd.read_csv('output.csv', index_col='id')\n",
1242+
"\n",
1243+
" # Display the sentences corresponding to the top IDs\n",
1244+
" result_text.delete(1.0, tk.END) # Clear the previous results\n",
1245+
"\n",
1246+
" for id in top_ids:\n",
1247+
" if id in output_df.index:\n",
1248+
" sentence = output_df.loc[id, 'sentence']\n",
1249+
" result_text.insert(tk.END, f\"{id}: {sentence}\\n\")\n",
1250+
" else:\n",
1251+
" result_text.insert(tk.END, f\"{id}: Not found\\n\")\n",
1252+
"\n",
1253+
"# Create the main window\n",
1254+
"root = tk.Tk()\n",
1255+
"root.title(\"Search Engine\")\n",
1256+
"\n",
1257+
"# Create a StringVar to store the search input\n",
1258+
"kiarash_string = tk.StringVar()\n",
1259+
"\n",
1260+
"search_entry = tk.Entry(root, width=40, textvariable=kiarash_string)\n",
1261+
"search_entry.grid(row=0, column=0, padx=10, pady=10)\n",
1262+
"\n",
1263+
"# Button to store search input\n",
1264+
"store_button = tk.Button(root, text=\"Store Input\", command=store_search_input)\n",
1265+
"store_button.grid(row=0, column=1, padx=10, pady=10)\n",
1266+
"\n",
1267+
"# Button to perform search\n",
1268+
"search_button = tk.Button(root, text=\"Perform Search\", command=perform_search)\n",
1269+
"search_button.grid(row=0, column=2, padx=10, pady=10)\n",
1270+
"\n",
1271+
"result_text = scrolledtext.ScrolledText(root, width=50, height=10, wrap=tk.WORD)\n",
1272+
"result_text.grid(row=1, column=0, columnspan=3, padx=10, pady=10)\n",
1273+
"\n",
1274+
"# Run the Tkinter event loop\n",
1275+
"root.mainloop()\n"
1276+
]
1277+
},
12011278
{
12021279
"cell_type": "code",
12031280
"execution_count": null,
1204-
"id": "9ca873c7",
1281+
"id": "e8732cc7",
12051282
"metadata": {},
12061283
"outputs": [],
12071284
"source": []

Simple Search engine.ipynb

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
},
5959
{
6060
"cell_type": "code",
61-
"execution_count": 1,
61+
"execution_count": 13,
6262
"id": "82632cbb",
6363
"metadata": {
6464
"scrolled": false
@@ -89,7 +89,7 @@
8989
},
9090
{
9191
"cell_type": "code",
92-
"execution_count": 2,
92+
"execution_count": 14,
9393
"id": "df57de08",
9494
"metadata": {},
9595
"outputs": [],
@@ -126,7 +126,7 @@
126126
},
127127
{
128128
"cell_type": "code",
129-
"execution_count": 4,
129+
"execution_count": 7,
130130
"id": "7a9e6335",
131131
"metadata": {
132132
"scrolled": true
@@ -147,7 +147,7 @@
147147
"True"
148148
]
149149
},
150-
"execution_count": 4,
150+
"execution_count": 7,
151151
"metadata": {},
152152
"output_type": "execute_result"
153153
}
@@ -159,7 +159,7 @@
159159
},
160160
{
161161
"cell_type": "code",
162-
"execution_count": 5,
162+
"execution_count": 15,
163163
"id": "b6cfa98c",
164164
"metadata": {
165165
"scrolled": true
@@ -948,7 +948,7 @@
948948
},
949949
{
950950
"cell_type": "code",
951-
"execution_count": 6,
951+
"execution_count": 16,
952952
"id": "fef00e06",
953953
"metadata": {
954954
"scrolled": true
@@ -1018,7 +1018,7 @@
10181018
"4 5 They are distinguished by their “memory” as th..."
10191019
]
10201020
},
1021-
"execution_count": 6,
1021+
"execution_count": 16,
10221022
"metadata": {},
10231023
"output_type": "execute_result"
10241024
}
@@ -1044,7 +1044,7 @@
10441044
},
10451045
{
10461046
"cell_type": "code",
1047-
"execution_count": 8,
1047+
"execution_count": 17,
10481048
"id": "be68502e",
10491049
"metadata": {
10501050
"scrolled": false
@@ -1054,31 +1054,31 @@
10541054
"name": "stdout",
10551055
"output_type": "stream",
10561056
"text": [
1057-
" 1 2 3 4 5 6 7 8 9 10 ... 587 \\\n",
1058-
"ways, 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1059-
"eyes 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1060-
"tutorials 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1061-
"fields. 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1062-
"? 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1063-
"... ... ... ... ... ... ... ... ... ... ... ... ... \n",
1064-
"attention. 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1065-
"distant 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1066-
"effort 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1067-
"lecture.digital 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1068-
"three 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1057+
" 1 2 3 4 5 6 7 8 9 10 ... 587 \\\n",
1058+
"simplicity 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1059+
"recommendations. 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1060+
"nan. 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1061+
"together 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1062+
"t=0 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1063+
"... ... ... ... ... ... ... ... ... ... ... ... ... \n",
1064+
"discusses 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1065+
"decomposing 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1066+
"(lstm) 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1067+
"digital 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
1068+
"patterns 0 0 0 0 0 0 0 0 0 0 ... 0 \n",
10691069
"\n",
1070-
" 588 589 590 591 592 593 594 595 596 \n",
1071-
"ways, 0 0 0 0 0 0 0 0 0 \n",
1072-
"eyes 0 0 0 0 0 0 0 0 0 \n",
1073-
"tutorials 0 0 0 0 0 0 0 0 0 \n",
1074-
"fields. 0 0 0 0 0 0 0 0 0 \n",
1075-
"? 0 0 0 0 0 0 0 0 0 \n",
1076-
"... ... ... ... ... ... ... ... ... ... \n",
1077-
"attention. 0 0 0 0 0 0 0 0 0 \n",
1078-
"distant 0 0 0 0 0 0 0 0 0 \n",
1079-
"effort 0 0 0 0 0 0 0 0 0 \n",
1080-
"lecture.digital 0 0 0 0 0 0 0 0 0 \n",
1081-
"three 0 0 0 0 0 0 0 0 0 \n",
1070+
" 588 589 590 591 592 593 594 595 596 \n",
1071+
"simplicity 0 0 0 0 0 0 0 0 0 \n",
1072+
"recommendations. 0 0 0 0 0 0 0 0 0 \n",
1073+
"nan. 0 0 0 0 0 0 0 0 0 \n",
1074+
"together 0 0 0 0 0 0 0 0 0 \n",
1075+
"t=0 0 0 0 1 0 0 0 0 0 \n",
1076+
"... ... ... ... ... ... ... ... ... ... \n",
1077+
"discusses 0 0 0 0 0 0 0 0 0 \n",
1078+
"decomposing 0 0 0 0 0 0 0 0 0 \n",
1079+
"(lstm) 0 0 0 0 0 0 0 0 0 \n",
1080+
"digital 0 0 0 0 0 0 0 0 0 \n",
1081+
"patterns 0 0 0 0 0 0 0 0 0 \n",
10821082
"\n",
10831083
"[2593 rows x 596 columns]\n"
10841084
]
@@ -1120,7 +1120,7 @@
11201120
},
11211121
{
11221122
"cell_type": "code",
1123-
"execution_count": 11,
1123+
"execution_count": 18,
11241124
"id": "929844ac",
11251125
"metadata": {},
11261126
"outputs": [

0 commit comments

Comments
 (0)