File size: 654 Bytes
b11ac48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import langdetect

import json


DATA_FILE = "data/thecrashes_data.json"


def main():
    texts = get_texts()
    for text in texts:
        if langdetect.detect(text) == "en":
            print("\n<-------------------------------")
            print(text)
            print("------------------------------>\n")


def get_texts():
    with open(DATA_FILE, encoding="utf-8") as f:
        data = json.load(f)

    texts = []

    for event in data:
        for article in event["articles"]:
            texts.append(article["title"] + "\n\n" + article["summary"])

    return texts


if __name__ == '__main__':
    main()