Skip to content

Commit 2bc6816

Browse files
updating codes
1 parent a87401d commit 2bc6816

File tree

2 files changed

+2
-188
lines changed

2 files changed

+2
-188
lines changed

.ipynb_checkpoints/Simple Search engine-checkpoint.ipynb

Lines changed: 1 addition & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,101 +1187,8 @@
11871187
"id": "3a08b08b",
11881188
"metadata": {},
11891189
"source": [
1190-
"## <span style=\"font-family: Cambria;\">Step6: </span>"
1190+
"## <span style=\"font-family: Cambria;\">Hope you enjoyed it! </span>"
11911191
]
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-
},
1278-
{
1279-
"cell_type": "code",
1280-
"execution_count": null,
1281-
"id": "e8732cc7",
1282-
"metadata": {},
1283-
"outputs": [],
1284-
"source": []
12851192
}
12861193
],
12871194
"metadata": {

Simple Search engine.ipynb

Lines changed: 1 addition & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,101 +1187,8 @@
11871187
"id": "3a08b08b",
11881188
"metadata": {},
11891189
"source": [
1190-
"## <span style=\"font-family: Cambria;\">Step6: </span>"
1190+
"## <span style=\"font-family: Cambria;\">Hope you enjoyed it! </span>"
11911191
]
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-
},
1278-
{
1279-
"cell_type": "code",
1280-
"execution_count": null,
1281-
"id": "e8732cc7",
1282-
"metadata": {},
1283-
"outputs": [],
1284-
"source": []
12851192
}
12861193
],
12871194
"metadata": {

0 commit comments

Comments
 (0)