Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in our project string matching we using specific algorithms name edit distance. It is compare between two strings like car , cat and the different

in our project "string matching" we using specific algorithms name edit distance.

It is compare between two strings like car , cat and the different between them is only one character.

The time complexity we created and we do not need any change in any part of it

In our code we use data structure list. And we need to input str1 from user and we did it. ONLY we need solution for how can we pull first 10 rows from pcr data file which is have 1740 rows and compare the first 10 rows in str2 with str1 that user input.

NOTE: pcr data file contains data which is zeros and ones and we want to compare it like string not interger

THE PYTHON CODE WE WRITE IT IN SPYDER

# MATCHING STRING LIST # EDIT DISTANCE

import csv import time import pandas as pd

path = r"C:/Users/vip/Desktop/project/pcr_data.csv"

# making data frame from csv file # change data type from int to str data = pd.read_csv(path) data = data.astype(str)

# Join all the elements in each row with no separator data["joined_row"] = data.apply(lambda row: ''.join(row), axis=1) print(list(data["joined_row"]))

def readlist(): with open("pcr_data.csv",'r') as csvfile: reader = csv.reader(csvfile) dataList = [] # definition empty list for row in reader: dataList.append(row) return dataList

# start time complixity start_time = time.perf_counter()

def editDistance(str1, str2, m, n):

# If first string is empty, the only option is to # insert all characters of second string into first if m == 0: return n # If second string is empty, the only option is to # remove all characters of first string if n == 0: return m

# If last characters of two strings are same, nothing # much to do. Ignore last characters and get count for # remaining strings.

if str1[m-1] == str2[n-1]: return editDistance(str1, str2, m-1, n-1)

# If last characters are not same, consider all three # operations on last character of first string, recursively # compute minimum cost for all three operations and take # minimum of three values.

return 1 + min(editDistance(str1, str2, m, n-1), #insert editDistance(str1, str2, m-1, n), #remove editDistance(str1, str2, m-1, n-1) #replace )

# output str1 =(input("enter your first string")) str2 = data.loc[3] print ("edit distance",editDistance(str1, str2, len(str1), len(str2)))

# end time complixity end_time = time.perf_counter() print("Time taken:", end_time - start_time)

# This code is contributed by Bhavya Jain

HERE LINK JUST DOWNLOAD THE RT_PCR DATA FILE AND PUT RT_PCR DATA FILE AND PYTHON CODE IN THE SAME FOLDER IN YOUR COMPUTER

A Brazilian dataset of symptomatic patients for screening the risk of COVID-19 - Mendeley Data

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data In Just 7 Chapters

Authors: Prof Marcus Vinicius Pinto

1st Edition

B09NZ7ZX72, 979-8787954036

More Books

Students also viewed these Databases questions

Question

4. Explain why strategic planning is important to all managers.

Answered: 1 week ago