@@ -1 +1,1313 @@
+from search.html import HTMLVisualization%0Afrom utils.transcription import WordCoord%0A%0Adef search_word(word, save=False):%0A    %22%22%22%0A    Finds all locations of a word. Optionally the locations can be saved in an%0A    HTML file with the same name as the word.%0A    %22%22%22%0A    # TODO: Find the word. Currently just dummy data for testing.%0A    locations = %5B'270-01-01', '274-01-01', '270-02-02', '273-01-01', '273-02-02', '273-05-01', '270-09-01'%5D%0A    if save:%0A        display_all_occurences(locations, output=word+'.html')%0A%0A    return locations%0A%0Adef display_all_occurences(locations, output='default.html'):%0A    %22%22%22%0A    Displays all images that are in the list of locations and highlights all%0A    locations within the images.%0A    %22%22%22%0A    locations.sort()%0A    word_coords = %5BWordCoord(w) for w in locations%5D%0A    visual = HTMLVisualization()%0A    while word_coords:%0A        same_doc = 0%0A        curr_doc = word_coords%5B0%5D.get_doc()%0A        for word in word_coords:%0A            if word.get_doc() == curr_doc:%0A                same_doc += 1%0A            else:%0A                break%0A        # remove the words of the same doc from the list%0A        word_ids = %5Bw.__str__() for w in word_coords%5B:same_doc%5D%5D%0A        word_coords = word_coords%5Bsame_doc:%5D%0A        visual.add_image_by_id(curr_doc, word_ids=word_ids)%0A    visual.save(output)
 %0A

Add visualization for search results