0% found this document useful (0 votes)
30 views

Assignment 4

This document describes a Python code for a simple document retrieval system interface that allows users to enter queries and returns connected documents from a directory based on a graph model, with functions to gather documents, create a proximal node model graph, and run the main interactive query function. It imports common Python libraries for file handling, GUI creation, and includes descriptions of the code structure and limitations for a basic implementation.

Uploaded by

Pac SaQii
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Assignment 4

This document describes a Python code for a simple document retrieval system interface that allows users to enter queries and returns connected documents from a directory based on a graph model, with functions to gather documents, create a proximal node model graph, and run the main interactive query function. It imports common Python libraries for file handling, GUI creation, and includes descriptions of the code structure and limitations for a basic implementation.

Uploaded by

Pac SaQii
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Information Retrieval

Assignment 4

Session: 2020 – 2024

Submitted by:
Saqlain Nawaz 2020-CS-135

Supervised by:
Sir Khaldoon Syed Khurshid

Department of Computer Science


University of Engineering and Technology
Lahore Pakistan
Overview
This code is designed to create a simple user interface for a document retrieval
system using Python’s Tkinter library. It includes a function for gathering documents
from a directory and functions for implementing the Structure Guided Browsing and
Hypertext models.

Libraries Used
The following libraries are used in this code:

● os: Provides functions for interacting with the operating system, used here for
file operations and directory traversal.
● tkinter: A standard Python interface to the Tk GUI toolkit, used here to create
the user interface.
● tkinter.ttk: Provides access to the Tk themed widget set, used here to create a
Treeview widget.
● tkinter.filedialog: Provides dialogs for opening and saving files, used here to
allow the user to open a file.

Code Flow
The code is structured as follows:

Import Libraries
The required libraries are imported at the beginning of the code.

gather_documents Function
This function takes a directory path as input and returns a list of all text files in that
directory. It uses the os.walk function to traverse the directory and its
subdirectories.

proximal_nodes_model Function

This function takes a graph G and a list of proximal_nodes as input. It returns a


dictionary where each key is a node from proximal_nodes that exists in G, and
each value is a list of nodes in G that are connected to the key node.

Main Function
In the main function, the program first gathers all text files from a specified directory.
Then it creates a graph and adds nodes and edges to it. It enters a loop where it
allows the user to enter a query. For each term in the query, it finds and prints all
documents (nodes) that are connected to that term in the graph.
Execution
The main function is executed when the script is run. The user can interact with the
program by entering queries, and the program will print out documents connected to
the query terms according to the graph.

Please note that this is a basic implementation of a proximal node model. It does not
take into account the proximity of terms within documents or the structure of the
documents. For a more advanced implementation, you might need to use a library
that can parse and query structured documents.

You might also like