Skip to content

Commit 6b54d2a

Browse files
add awareness function
1 parent 8e42202 commit 6b54d2a

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

code/logic/fossil/io/soap.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ int32_t fossil_soap_count_offensive(const char *input);
5454
*/
5555
int32_t fossil_soap_count_rotbrain(const char *input);
5656

57+
/**
58+
* Check if a string is context-aware.
59+
* Returns EXIT_FAILURE if the string is context-aware, EXIT_SUCCESS otherwise.
60+
*/
61+
int32_t fossil_soap_context_aware(const char *input);
62+
5763
#ifdef __cplusplus
5864
}
5965

@@ -114,6 +120,14 @@ namespace fossil {
114120
static int32_t count_rotbrain(const char *input) {
115121
return fossil_soap_count_rotbrain(input);
116122
}
123+
124+
/**
125+
* Check if a string is context-aware.
126+
* Returns EXIT_FAILURE if the string is context-aware, EXIT_SUCCESS otherwise.
127+
*/
128+
static int32_t context_aware(const char *input) {
129+
return fossil_soap_context_aware(input);
130+
}
117131
};
118132
}
119133
}

code/logic/soap.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,15 @@ int32_t fossil_soap_count_offensive(const char *input) {
174174
int32_t fossil_soap_count_rotbrain(const char *input) {
175175
return count_matches(input, FOSSIL_SOAP_ROTBRAIN, sizeof(FOSSIL_SOAP_ROTBRAIN) / sizeof(*FOSSIL_SOAP_ROTBRAIN));
176176
}
177+
178+
int32_t fossil_soap_context_aware(const char *input) {
179+
int offensive_count = fossil_soap_count_offensive(input);
180+
int rotbrain_count = fossil_soap_count_rotbrain(input);
181+
182+
if (offensive_count > 0) {
183+
return 1; // Offensive content detected
184+
} else if (rotbrain_count > 0) {
185+
return 2; // Rotbrain content detected
186+
}
187+
return 0; // No offensive or rotbrain content detected
188+
}

0 commit comments

Comments
 (0)