-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMain.java
More file actions
43 lines (39 loc) · 1.48 KB
/
Copy pathMain.java
File metadata and controls
43 lines (39 loc) · 1.48 KB
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
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.text.Normalizer;
//Palavras para teste da arvore
// sociedade, automacao, ecossistemas, Twitter, inteligência
public class Main {
public static void main(String[] args) {
String folderPath = "artigos";
File folder = new File(folderPath);
File[] files = folder.listFiles();
AVL avlTree = new AVL();
if (files != null) {
for (File file : files) {
if (file.isFile()) {
try{
Scanner scanner = new Scanner(file);
scanner.useDelimiter("\\s+");
while(scanner.hasNext()){
String word = scanner.next();
word = word.replaceAll("\\p{Punct}", "");
word = removerAcentos(word);
avlTree.insertElement(word, file.getAbsolutePath());
}
}
catch (FileNotFoundException exception){
exception.printStackTrace();
}
}
}
}
Menu menu = new Menu(avlTree);
menu.display();
}
public static String removerAcentos(String palavra) {
String normalized = Normalizer.normalize(palavra, Normalizer.Form.NFD);
return normalized.replaceAll("[\\p{InCombiningDiacriticalMarks}]", "");
}
}