15
15
#define FOSSIL_IO_SOAP_H
16
16
17
17
#include < stdint.h>
18
+ #include < stddef.h>
18
19
19
20
#ifdef __cplusplus
20
21
extern " C" {
21
22
#endif
22
23
23
24
/* *
24
- * Sanitize a string by replacing curse words with asterisks.
25
- * This function scans the input string for offensive words and replaces them with asterisks,
26
- * thereby making the string suitable for use in contexts where offensive language is not allowed.
27
- * The input string is modified in place.
25
+ * @brief Sanitize input text by removing or replacing "rot-brain" and meme-based language.
28
26
*
29
- * @param input The input string to be sanitized in-place.
27
+ * @param text The input text to sanitize.
28
+ * @return A dynamically allocated sanitized string (must be freed by the caller).
30
29
*/
31
- void fossil_soap_sanitize ( char *input );
30
+ char * fossil_io_soap_sanitize ( const char *text );
32
31
33
32
/* *
34
- * Check if a word is an offensive word or phrase.
35
- * Returns EXIT_FAILURE if the word is considered offensive, EXIT_SUCCESS otherwise.
33
+ * @brief Suggest proper alternatives for rot-brain words or grammar fixes.
34
+ *
35
+ * @param text The input text.
36
+ * @return A dynamically allocated string with suggestions (must be freed by the caller).
36
37
*/
37
- int32_t fossil_soap_is_offensive (const char *word );
38
+ char * fossil_io_soap_suggest (const char *text );
38
39
39
40
/* *
40
- * Check if a word is meme speak.
41
- * Returns EXIT_FAILURE if the word is considered meme speak, EXIT_SUCCESS otherwise.
41
+ * @brief Add a custom word or phrase to the filter.
42
+ *
43
+ * @param phrase The phrase to add.
44
+ * @return 0 on success, nonzero on failure.
42
45
*/
43
- int32_t fossil_soap_is_rotbrain (const char *word );
46
+ int fossil_io_soap_add_custom_filter (const char *phrase );
44
47
45
48
/* *
46
- * Count offensive words in a string.
47
- * Returns the number of offensive words found in the input string.
49
+ * @brief Clear all custom filters.
48
50
*/
49
- int32_t fossil_soap_count_offensive ( const char *input );
51
+ void fossil_io_soap_clear_custom_filters ( void );
50
52
51
53
/* *
52
- * Count meme speak words in a string.
53
- * Returns the number of meme speak words found in the input string.
54
+ * @brief Detect the tone of a sentence.
55
+ *
56
+ * @param text The input text.
57
+ * @return A string representing the detected tone ("formal", "casual", "sarcastic", etc.).
54
58
*/
55
- int32_t fossil_soap_count_rotbrain (const char *input );
59
+ const char * fossil_io_soap_detect_tone (const char *text );
56
60
57
61
#ifdef __cplusplus
58
62
}
59
63
64
+ #include < string>
65
+
60
66
/* *
61
67
* C++ wrapper for the SOAP API.
62
68
*/
@@ -72,50 +78,98 @@ namespace fossil {
72
78
class Soap {
73
79
public:
74
80
/* *
75
- * Sanitize a string by replacing curse words with asterisks.
76
- * This function scans the input string for offensive words and replaces them with asterisks,
77
- * thereby making the string suitable for use in contexts where offensive language is not allowed.
78
- * The input string is modified in place.
81
+ * Sanitize input text by removing or replacing "rot-brain" and meme-based language.
82
+ *
83
+ * @param text The input text to sanitize.
84
+ * @return A dynamically allocated sanitized string (must be freed by the caller).
85
+ */
86
+ static std::string sanitize (const std::string &text) {
87
+ return fossil_io_soap_sanitize (text.c_str ());
88
+ }
89
+
90
+ /* *
91
+ * Suggest proper alternatives for rot-brain words or grammar fixes.
92
+ *
93
+ * @param text The input text.
94
+ * @param format_type Custom format for output (e.g., "*" or "#").
95
+ * @return A dynamically allocated string with suggestions (must be freed by the caller).
96
+ */
97
+ static std::string suggest (const std::string &text) {
98
+ return fossil_io_soap_suggest (text.c_str ());
99
+ }
100
+
101
+ /* *
102
+ * Add a custom word or phrase to the filter.
103
+ *
104
+ * @param phrase The phrase to add.
105
+ * @return 0 on success, nonzero on failure.
106
+ */
107
+ static int add_custom_filter (const std::string &phrase) {
108
+ return fossil_io_soap_add_custom_filter (phrase.c_str ());
109
+ }
110
+
111
+ /* *
112
+ * Clear all custom filters.
113
+ */
114
+ static void clear_custom_filters () {
115
+ fossil_io_soap_clear_custom_filters ();
116
+ }
117
+
118
+ /* *
119
+ * Detect the tone of a sentence.
79
120
*
80
- * @param input The input string to be sanitized in-place.
121
+ * @param text The input text.
122
+ * @return A string representing the detected tone ("formal", "casual", "sarcastic", etc.).
81
123
*/
82
- static void sanitize ( char *input ) {
83
- fossil_soap_sanitize (input );
124
+ static std::string detect_tone ( const std::string &text ) {
125
+ return fossil_io_soap_detect_tone (text. c_str () );
84
126
}
85
127
86
128
/* *
87
- * Check if a word is an offensive word or phrase.
88
- * Returns EXIT_FAILURE if the word is considered offensive, EXIT_SUCCESS otherwise.
129
+ * Sanitize input text by removing or replacing "rot-brain" and meme-based language.
130
+ *
131
+ * @param text The input text to sanitize.
132
+ * @return A dynamically allocated sanitized string (must be freed by the caller).
89
133
*/
90
- static int32_t is_offensive (const char *word ) {
91
- return fossil_soap_is_offensive (word );
134
+ static char * sanitize (const char * text ) {
135
+ return fossil_io_soap_sanitize (text );
92
136
}
93
137
94
138
/* *
95
- * Check if a word is meme speak.
96
- * Returns EXIT_FAILURE if the word is considered meme speak, EXIT_SUCCESS otherwise.
139
+ * Suggest proper alternatives for rot-brain words or grammar fixes.
140
+ *
141
+ * @param text The input text.
142
+ * @param format_type Custom format for output (e.g., "*" or "#").
143
+ * @return A dynamically allocated string with suggestions (must be freed by the caller).
97
144
*/
98
- static int32_t is_rotbrain (const char *word ) {
99
- return fossil_soap_is_rotbrain (word );
145
+ static char * suggest (const char * text ) {
146
+ return fossil_io_soap_suggest (text );
100
147
}
101
148
102
149
/* *
103
- * Count offensive words in a string.
104
- * Returns the number of offensive words found in the input string.
150
+ * Add a custom word or phrase to the filter.
151
+ *
152
+ * @param phrase The phrase to add.
153
+ * @return 0 on success, nonzero on failure.
105
154
*/
106
- static int32_t count_offensive (const char *input ) {
107
- return fossil_soap_count_offensive (input );
155
+ static int add_custom_filter (const char * phrase ) {
156
+ return fossil_io_soap_add_custom_filter (phrase );
108
157
}
109
158
110
159
/* *
111
- * Count meme speak words in a string.
112
- * Returns the number of meme speak words found in the input string.
160
+ * Detect the tone of a sentence.
161
+ *
162
+ * @param text The input text.
163
+ * @return A string representing the detected tone ("formal", "casual", "sarcastic", etc.).
113
164
*/
114
- static int32_t count_rotbrain (const char *input ) {
115
- return fossil_soap_count_rotbrain (input );
165
+ static const char * detect_tone (const char * text ) {
166
+ return fossil_io_soap_detect_tone (text );
116
167
}
168
+
117
169
};
170
+
118
171
}
172
+
119
173
}
120
174
121
175
#endif
0 commit comments