|
1 | 1 | {
|
2 | 2 | "cells": [
|
3 |
| - { |
4 |
| - "cell_type": "markdown", |
5 |
| - "id": "b7571819", |
6 |
| - "metadata": {}, |
7 |
| - "source": [ |
8 |
| - "<span style=\"font-family: Cambria;\"></span>" |
9 |
| - ] |
10 |
| - }, |
11 | 3 | {
|
12 | 4 | "cell_type": "markdown",
|
13 | 5 | "id": "123548c8",
|
|
66 | 58 | },
|
67 | 59 | {
|
68 | 60 | "cell_type": "code",
|
69 |
| - "execution_count": 1, |
| 61 | + "execution_count": 13, |
70 | 62 | "id": "82632cbb",
|
71 | 63 | "metadata": {
|
72 | 64 | "scrolled": false
|
|
97 | 89 | },
|
98 | 90 | {
|
99 | 91 | "cell_type": "code",
|
100 |
| - "execution_count": 2, |
| 92 | + "execution_count": 14, |
101 | 93 | "id": "df57de08",
|
102 | 94 | "metadata": {},
|
103 | 95 | "outputs": [],
|
|
134 | 126 | },
|
135 | 127 | {
|
136 | 128 | "cell_type": "code",
|
137 |
| - "execution_count": 4, |
| 129 | + "execution_count": 7, |
138 | 130 | "id": "7a9e6335",
|
139 | 131 | "metadata": {
|
140 | 132 | "scrolled": true
|
|
155 | 147 | "True"
|
156 | 148 | ]
|
157 | 149 | },
|
158 |
| - "execution_count": 4, |
| 150 | + "execution_count": 7, |
159 | 151 | "metadata": {},
|
160 | 152 | "output_type": "execute_result"
|
161 | 153 | }
|
|
167 | 159 | },
|
168 | 160 | {
|
169 | 161 | "cell_type": "code",
|
170 |
| - "execution_count": 5, |
| 162 | + "execution_count": 15, |
171 | 163 | "id": "b6cfa98c",
|
172 | 164 | "metadata": {
|
173 | 165 | "scrolled": true
|
|
956 | 948 | },
|
957 | 949 | {
|
958 | 950 | "cell_type": "code",
|
959 |
| - "execution_count": 6, |
| 951 | + "execution_count": 16, |
960 | 952 | "id": "fef00e06",
|
961 | 953 | "metadata": {
|
962 | 954 | "scrolled": true
|
|
1026 | 1018 | "4 5 They are distinguished by their “memory” as th..."
|
1027 | 1019 | ]
|
1028 | 1020 | },
|
1029 |
| - "execution_count": 6, |
| 1021 | + "execution_count": 16, |
1030 | 1022 | "metadata": {},
|
1031 | 1023 | "output_type": "execute_result"
|
1032 | 1024 | }
|
|
1052 | 1044 | },
|
1053 | 1045 | {
|
1054 | 1046 | "cell_type": "code",
|
1055 |
| - "execution_count": 8, |
| 1047 | + "execution_count": 17, |
1056 | 1048 | "id": "be68502e",
|
1057 | 1049 | "metadata": {
|
1058 | 1050 | "scrolled": false
|
|
1062 | 1054 | "name": "stdout",
|
1063 | 1055 | "output_type": "stream",
|
1064 | 1056 | "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", |
1077 | 1069 | "\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", |
1090 | 1082 | "\n",
|
1091 | 1083 | "[2593 rows x 596 columns]\n"
|
1092 | 1084 | ]
|
|
1128 | 1120 | },
|
1129 | 1121 | {
|
1130 | 1122 | "cell_type": "code",
|
1131 |
| - "execution_count": 56, |
| 1123 | + "execution_count": 18, |
1132 | 1124 | "id": "929844ac",
|
1133 | 1125 | "metadata": {},
|
1134 | 1126 | "outputs": [
|
|
1198 | 1190 | "## <span style=\"font-family: Cambria;\">Step6: </span>"
|
1199 | 1191 | ]
|
1200 | 1192 | },
|
| 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 | + }, |
1201 | 1278 | {
|
1202 | 1279 | "cell_type": "code",
|
1203 | 1280 | "execution_count": null,
|
1204 |
| - "id": "9ca873c7", |
| 1281 | + "id": "e8732cc7", |
1205 | 1282 | "metadata": {},
|
1206 | 1283 | "outputs": [],
|
1207 | 1284 | "source": []
|
|
0 commit comments