by using string matching algorithm with finite state machine

by using string matching algorithm with finite state machine

Show all steps please

In this project you need to develop an application that will check the similarity between a document (Pattern) and other documents. Your input will be a set of text files, at least 4 files, and a potentially plagiarized document. Your output must be the similarity percentage between the pattern and each text file (individually) and between the overall percentage between the pattern and all text files. Use the string matching algorithm with finite state machine to implement your detector. Your application should at least contain these functionalities: Load the pattern file (you may tokenize the file by sentence or by line). Build the state machine for each pattern. a. Show the built table (Transfer Function). Load the text files. Check similarity between the pattern and each individual text file. Show a percentage for each text file Cheek the overall similarity. (The percentage = sum of all similarities/number of text files).

Solution

//The following steps shows the algorithm and program for the above application.

Implementation of the above application in Java Program.

import java.util.*;

import java.lang.*;

public class docReader

{

public static void main(String[] args)

{

System.out.println(\"Enter the number of input files to read: \ \");

Scanner sc = new Scanner(System.in);

int n = sc.nextInt();

File dir = new File(\"Directoryoffilestoinput\");

for(File file : dir.listFiles()) // You can load the pattern files as well in the same manner

{

Scanner sc = new Scanner(file);// Reading files from the directory

LoadPattern(file); // Calling Step 2 loading the pattern of the file

}

}

void LoadPattern(File file) // Searching for the pattern in this method and load the percentage of that pattern

{

int count=0;// To count the matched pattern

float percentage;

BufferedReader Br = new BufferedReader(new FileReader(\"file.txt\");

String[] line = null;

System.out.println(\"Enter the pattern to search\ \");

Scanner sc = new Scanner(System.in);

String Pattern = sc.nextLine();

while(Br.readline()!=null)

{

line = Br.readline(); // Reading alll the lines of the file and storing them in a string object.

}

for(int i=0;i<line.length();i++)

{

if(line[i].equals(Pattern))

{

count++; // Counting the matched patterns

}

}

percentage = (float)count/line.lenth(); // Measuring the percentage of Pattern that is matched

System.out.println(\"The matched percentage is :\"+percentage); // Printing the percentage.

}

// Over all percentage can be calculated by adding all the percentage values that you get.

// All the steps are taken care in the load pattern function.

}

by using string matching algorithm with finite state machine Show all steps please In this project you need to develop an application that will check the simila
by using string matching algorithm with finite state machine Show all steps please In this project you need to develop an application that will check the simila

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site