Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this lab, you are asked to complete similars.c program file which has been already given in LMS . In this program, there are four

In this lab, you are asked to complete similars.c program file which has been already given in LMS. In this
program, there are four functions, namely, main, hash_text, strong_similar, and weak_similar. main
function is already provided, and it is supposed to remain as it is (you should not change it). You are
required to implement hash_text, strong_similar, and weak_similar functions.
Here are the operations performed in main function:
An array of strings with name list with the size 10 is created to hold name and surname
data in name_surname format and the elements are read into it.
An array of integers with name hashed_vals is created to hold hashed values of name and and
surname in unsigned integer format.
A two-dimensional array of integers to keep the mapping of similarities between each name
surname pair.
hashed_vals array is initialize by calling hash_text function to calculate the hash values of full
name and surname pair.
strong_similar function is called to find the same names and fill the two-dimensional array called
same to keep the mapping of similarities.
The name surname pairs, the calculated hash values and similarity mapping is printed on the
standard output.
weak_similar function is called to calculate the hash values of each name and surname separately,
then build the similarity map using hash values.
The name surname pairs, and weakly similarity mapping is printed on the standard output.
average_similarity function calculates the average similarity between pairs of strings based on the
values in the same matrix, which represents strong and weak similarities between strings.
Task 1: Implement hash_text function.
unsigned int hash_text (char * list) ;
A character pointer holding names and surnames is sent as an input, and the hash value of the input text
is returned. During the calculation a basic formula is used as follows when the name is ali. The ascii code
for a is 97, for l is 108 and for i is 105. The function calculates the hash value by the following formula;
hash =46
2*97+46*108+105
The algorithm should be applied to all symbols including whitespaces between name and surname. At the
end mod 1000 of hash value should be returned.
hash = hash mod 1000
Computer Engineering Department
TED University
Task 2: Implement strong_similar function.
void strong_similar (int hval[MAX_ELEM], int map[MAX_ELEM][MAX_ELEM], int *strong_count) ;
Calculated hash values of all names-surnames pair are sent to the function. The function modifies and
returns the map of exact matches. Exact matching of the entries is calculated only by using hashed values.
Also, you will find the strong similarity count.
Task 3: Implement weak_similar function.
void weak_similar (char list[MAX_ELEM][STR_LEN],int map[MAX_ELEM][MAX_ELEM]);
Array of names and surnames list is sent as input and previously calculated similarity map is sent as inputoutput parameter.
During the execution of the function strtok function is used to split names and surnames by using the
space between them. To store the splitted names and surnames a three-dimensional array is created. First
dimension is same as the list in main function, second dimension is two either to point name string or
surname string. Similarly, two-dimensional array is created to keep hash values of names and surnames
for each pair.
The function then calculates hash values of names and surnames for each pair by calling hash_text
function. Once the hash values of all names and surnames are calculated the function updates the map
array to mark the weak similarities (either names or surnames are same). For example;
ali kemal and mustafa kemal are weakly similar. They both are weakly similar to kemal ahmet.

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

Database And Expert Systems Applications 31st International Conference Dexa 2020 Bratislava Slovakia September 14 17 2020 Proceedings Part 1 Lncs 12391

Authors: Sven Hartmann ,Josef Kung ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

303059002X, 978-3030590024

More Books

Students also viewed these Databases questions

Question

first 3 articles in the constitution and what they establish

Answered: 1 week ago