-
Notifications
You must be signed in to change notification settings - Fork 0
/
SignatureMatch.java
51 lines (45 loc) · 1.19 KB
/
SignatureMatch.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.io.File;
import java.util.Scanner;
import java.util.ArrayList;
public class SignatureMatch
{
private String txt1;
private String txt2;
private ArrayList<String> words = new ArrayList<String>();
private ArrayList<String> punct = new ArrayList<String>();
public SignatureMatch(String t1, String t2)
{
txt1 = t1.toLowerCase();
txt2 = t2.toLowerCase();;
txt1 = txt1.replaceAll("\\p{Punct}", "");
txt2 = txt2.replaceAll("\\p{Punct}", "");
File file = new File("CommonWords.txt");
Scanner scan = null;
try
{
scan = new Scanner(file);
}
catch(Exception ex)
{
System.out.println("File not found");
System.exit(1);
}
while(scan.hasNext())
{
words.add(scan.nextLine());
}
for(int x = 0; x<words.size(); x++)
{
txt1 = txt1.replaceAll(words.get(x), " ");
txt2 = txt2.replaceAll(words.get(x), " ");
}
}
public String getFirstText()
{
return txt1;
}
public String getSecondText()
{
return txt2;
}
}