Views
No views yet
clean_text function in utils.py.1from transformers import pipeline
2from utils import clean_text
3
4classifier = pipeline(
5 "text-classification",
6 model="fakespot-ai/roberta-base-ai-text-detection-v1"
7)
8
9# single text
10text = "text 1"
11classifier(clean_text(text))
12[
13 {
14 'label': str,
15 'score': float
16 }
17]
18
19# list of texts
20texts = ["text 1", "text 2"]
21classifier([clean_text(t) for t in texts])
22[
23 {
24 'label': str,
25 'score': float
26 },
27 {
28 'label': str,
29 'score': float
30 }
31]