Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.1 kB
33
Indexable
Never
from typing import List


class Document:
    def __init__(self, title: str, text: str):
        self.title = title
        self.text = text


class SearchEngine:

    def __init__(self, documents: List[List[str]]):
        self.documents = self._parse_documents(documents=documents)

    def _parse_documents(self, documents: List[List[str]]) -> List[Document]:
        # TODO Implement parsing here
        document_list: List[Document] = []
        return document_list

    def search(self, query: str) -> List[Document]:
        """ Implement a function to search for a query in the document text
        :returns
        Sublist of the original list of documents matching the query
        """
        # TODO Implement search here
        pass


documents = [
    ['Why I love Football', 'Football is my life and ...'],
    ['My sporting interests', 'Tennis, football and rugby are sports I love...'],
    ['Football, football, football', 'This is a guide to the best things about...']
]

se = SearchEngine(documents=documents)


if __name__ == '__main__':
    query = "football"
    se.search(query=query)