-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextAnalyzer.java
More file actions
89 lines (72 loc) · 2.85 KB
/
TextAnalyzer.java
File metadata and controls
89 lines (72 loc) · 2.85 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import java.util.*;
public class TextAnalyzer {
public static void main(String[] args) {
int badStuffCount = 0;
int shortStuffCount = 0;
int coolness = 0;
int badness = 0;
HashSet<String> badWords = new HashSet<>(Arrays.asList(
"fuck","bitch","shit","mf","whore","hoe","motherfucker","fucking"
));
HashSet<String> abrevation = new HashSet<>(Arrays.asList(
"lol","brb","wdym","wym","lmfao","omg","idk","btw","smh","ngl","fr"
));
Scanner in = new Scanner(System.in);
System.out.println("Input your message...");
String messageInput = in.nextLine();
String[] words = messageInput.split(" ");
// Scan + censor
for(String word : words) {
if(badWords.contains(word.toLowerCase())) {
word = "*".repeat(word.length());
badStuffCount++;
}
if(abrevation.contains(word.toLowerCase())) {
shortStuffCount++;
}
System.out.print(word + " ");
}
System.out.println();
// Badness analysis
if(badStuffCount >= 1 && badStuffCount < 4) {
System.out.println("Your message is informal");
badness += 4;
} else if(badStuffCount >= 4) {
System.out.println("Your message isn't just informal, it's filthy");
badness += 10;
} else {
System.out.println("Innocent message, cuss-free");
}
System.out.println();
// Coolness analysis
if(shortStuffCount >= 1 && shortStuffCount < 4) {
System.out.println("Your message is trying to be cool");
coolness += 5;
} else if(shortStuffCount >= 4) {
System.out.println("Your message is trying hard to be gen z slangy");
coolness += 10;
} else {
System.out.println("Not slang AT ALL");
}
System.out.println("Word Length: " + messageInput.length());
System.out.println("Overall: Coolness: " + coolness + " / 10");
System.out.println("Overall: Badness: " + badness + " / 10");
// Suggestions
if(coolness == 0) {
System.out.println("Suggestion: ADD COOLNESS");
}
if(badness == 0) {
System.out.println("Suggestion: KEEP IT UP NO CUSSING");
}
// Message type (prints ONCE)
if (badStuffCount == 0 && shortStuffCount == 0 && messageInput.length() > 15) {
System.out.println("Message Type: Professional");
} else if (shortStuffCount > 0 && badStuffCount <= 1) {
System.out.println("Message Type: Casual / DM");
} else if (badStuffCount >= 4) {
System.out.println("Message Type: Argument");
} else {
System.out.println("Message Type: Normal");
}
}
}