|
Algorithm 3 Classify Generated Story By Sentence. |
-
1:
Input: generated_story, bert_classifier
-
2:
Output: sentence_classification_results (list of Suitable/Unsuitable)
-
3:
Begin
-
4:
Split generated_story into individual sentences
-
5:
Initialize sentence_classification_results as an empty list
-
6:
for each sentence in generated_story do
-
7:
Preprocess the sentence
-
8:
Tokenize the sentence text
-
9:
Convert the sentence to the input format required by BERT
-
10:
Feed the preprocessed sentence into the fine-tuned BERT Classifier
-
11:
Perform classification
-
12:
Obtain prediction probabilities for “suitable” and “unsuitable”
-
13:
Set threshold for determining suitability (e.g., 0.5 probability)
-
14:
if prediction > threshold for “suitable” then
-
15:
Append “Suitable” to sentence_classification_results
-
16:
else
-
17:
Append “Unsuitable” to sentence_classification_results
-
18:
end if
-
19:
end for
-
20:
Return sentence_classification_results
-
21:
End
|