There's a
Python library that provides APIs for detecting headlines in textual data, especially on social media platforms such as Twitter. The library utilizes a model that has been developed and trained on a dataset of Twitter posts containing both headline and non-headline texts, with the assistance of journalism professionals to ensure the data quality.
Tested on Intel i7-6700k and 32GB of RAM.
1from headline_detector import FasttextDetector, IndoBERTweetDetector, CNNDetector
2
3detector = FasttextDetector.load_from_scenario(1)
4data = detector.predict_text(
5 [
6 "nama kamu siapa?",
7 "Kapolda Jatim Teddy Minahasa Dikabarkan Ditangkap Terkait Narkoba https://t.co/LD9X6VFaUR",
8 ]
9)
10print(data) # output: [0, 1]
11
12detector = CNNDetector.load_from_scenario(3)
13data = detector.predict_text(
14 [
15 "nama kamu siapa?",
16 "Kapolda Jatim Teddy Minahasa Dikabarkan Ditangkap Terkait Narkoba https://t.co/LD9X6VFaUR",
17 ]
18)
19print(data) # output: [0, 1]
20
21detector = IndoBERTweetDetector.load_from_scenario(5)
22data = detector.predict_text(
23 [
24 "nama kamu siapa?",
25 "Kapolda Jatim Teddy Minahasa Dikabarkan Ditangkap Terkait Narkoba https://t.co/LD9X6VFaUR",
26 ]
27)
28print(data) # output: [0, 1]
29
30# 0 is non-headline
31# 1 is headline