1-DAV-202 Data Management 2023/24
Previously 2-INF-185 Data Source Integration
HWcpp
Jump to navigation
Jump to search
See the lecture
You should implement all functionalities in two versions:
- Pure Python
- Python interface with C++ implementation
Task A
You are given a list of documents. Each document consists of multiple words separated by space. You should design and implement an indexing datastructure that allows the following two operations:
- Add a document to the index (your index should assign it a unique ID)
- Retrieve a document with the given ID
- Find all documents that contain the given word
This is the recommended interface for your datastructure with its example usage:
from typing import List
class DocumentIndex:
def __init__(self):
"""Initialize what you need here"""
def add_document(self, document:str) -> int:
"""Adds document to index, generates unique id for it"""
def get_document(self, document_id:int) -> std:
"""Returns document for given ID"""
def search(self, word:str) -> List[int]:
"""Returns list of document IDs containing the given word"""
TODO Python signature and implementation hints, example usage
Task B
Extend you index so that it support following query:
- Given list of words (W1, W2, ...) find all documents, which contain all of the words (so each document has to contain all of the word from the query).
TODO Python signature and implementation hints, example usage