Spaces:
Runtime error
Runtime error
File size: 2,700 Bytes
c706f5e 159bf74 eceff29 159bf74 c706f5e 159bf74 c706f5e 159bf74 c706f5e |
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
from TextClassifier import TextClassifier
# Some examples of tweets:
data_dict = {
'25 years ago we made a promise to the people of Hong Kong. We intend to keep it. https://t.co/nIN96ZydgV': {
'hour': '17',
'nlikes': 7878,
'nreplies': 2999,
'nretweets': 1993,
'topic': '',
'sentiment': ''},
'A huge delight to meet @SwedishPM Magdalena Andersson and President @niinisto again. The accession of Finland '
'and Sweden to @NATO will permanently strengthen our defensive Alliance, helping to keep us all safe. #WeAreNATO '
' https://t.co/pArvdWHr2F': {
'hour': '16',
'nlikes': 3468,
'nreplies': 686,
'nretweets': 435,
'topic': '',
'sentiment': ''},
'At this @NATO Leaders’ Summit, I’ll be urging fellow nations to continue to do everything they can to support '
'Ukraine. The UK has always played a historic role in the @NATO alliance, working to address the biggest global '
'threats and build a more secure world.': {
'hour': '07',
'nlikes': 7742,
'nreplies': 1838,
'nretweets': 1112,
'topic': '',
'sentiment': ''},
'Morgan Johansson måste avgå som minister. Otryggheten biter sig fast och gängkriminaliteten är allt annat än knäckt. Antalet skjutningar ökar och sätter skräck i varje del av vårt land. Sverige har förvandlats till ett gangsterland.': {
'hour': '16',
'nlikes': 3468,
'nreplies': 686,
'nretweets': 435,
'topic': '',
'sentiment': ''},
'Döms man för brott, särskilt våldsbrott, ska man vara inlåst från det att domen faller tills straffet är avtjänat. Allt annat är vansinne.': {
'hour': '16',
'nlikes': 3468,
'nreplies': 686,
'nretweets': 435,
'topic': '',
'sentiment': ''},
'Motionerna: ' + '\n' + 'K339 avslogs av enig riksdag (inkl KD).' + '\n' + 'K220 avslogs av enig riksdag (inkl KD).' + '\n' + '1601 avslogs av enig riksdag (inkl KD).' + '\n' + 'K281 avslogs av enig riksdag (inkl KD).' + '\n' + '\n' + '¯\_(ツ)_/¯': {
'hour': '16',
'nlikes': 3468,
'nreplies': 686,
'nretweets': 435,
'topic': '',
'sentiment': ''}
}
# Classify the TOPICS and insert the results into the data dictionary found above
topic_results = TextClassifier.classify_topics(data_dict)
# Classify the SENTIMENTS and insert the results into the data dictionary found above
sentiment_results = TextClassifier.classify_sentiments(data_dict)
# Print simple statistics related to TOPICS and SENTIMENTS
TextClassifier.print_stats(sentiment_results)
|