Question: Write a function random_text(m) that returns a random text of n characters in upper-case characters. Use lorem-text as described and the function upper(). If you

Write a function random_text(m) that returns a random text of n characters in upper-case characters. Use "lorem-text" as described and the function upper(). If you are using another programming language, please locate something equivalent.

[2] Write a function random_pattern(n, text) that returns a random pattern within the text. Generate a random index idx between 0 and len(text) - n, and then return text[idx:idx+n]. Remember that index so you can compare it to the index found by the search algorithms. (Generally n, the size of the pattern, will be small compared to m, the size of the text.)

[3] For each of the aforementioned string-search algorithms, write a function that implements it. You can copy the code from an online source, just acknowledge the source. Keep the signatures consistent (same arguments in the same positions) so they can all be called in the same fashion as shown in class. Those arguments should be text and pattern.

[4] In your main function, iterate over all the searches for a given text and pattern length. Capture the time before and after so you can track the elapsed time for the sorting algorithm. [Repeat these runs multiple times for the same size and find their average time.] Use the same text and pattern for all five algorithms to create a meaningful comparison.

[5] Repeat these runs for different sizes of the random pattern and text.

[6] Summarize the results in a table. Place the algorithms along the left side and the different sizes across the top.

[7] Visualize the statistics with a graphing package. Place all algorithms in the same graph for easy comparison. Use a different color for each sort and create a color legend either in or below the graph.

------------------------------------------------------------

my already complete most of code, but i still have some error , please help me fix please

import string import random import time import numpy as np import pandas as pd import tabulate import matplotlib.pyplot as plt from lorem_text import lorem from copy import deepcopy def random_text(n): letters = string.ascii_uppercase return ''.join(random.choice(letters) for i in range(n)) def random_pattern(text, size): index = random.randint(0, len(text) - size) return text[index:len(text) - size] def brute_force_algo(pat, txt): a = txt.find(pat) M = len(pat) N = len(txt) # A loop to slide pat[] one by one */ for i in range(N - M + 1): j = 0 # For current index i, check for pattern match */ while (j = 0 and pat[j] == txt[s + j]: j -= 1 if j  

Write a function random_text(m) that returns a random text of n characters

Run: main Traceback (most recent call last): File "C:\Users\heten PycharmProjects assignment3\main.py", line 255, in main() File "C:\Users\heten PycharmProjects assignment3\main.py", line 240, in main search(temp_text, temp-pat) File "C:\Users\heten\PycharmProjects assignment3\main.py", line 117, in rabin_karp_algo t = (d * t + ord(txt[i])) % q IndexError: string index out of range Process finished with exit code 1 12 Worcion Control TODO roblo Muthon Doolaar Dathon Concolo > Torminal

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!