This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import logging | |
| from logging import critical, error, info, warning, debug | |
| logging.basicConfig(format='%(message)s', level=logging.DEBUG, stream=sys.stdout) | |
| def main(): | |
| info("Running the main program.") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # File name: format.py | |
| # Description: Basic format for Python scripts | |
| # Author: Louis de Bruijn | |
| # Date: 19-05-2020 | |
| import sys | |
| import argparse | |
| import logging | |
| from logging import critical, error, info, warning, debug |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| def write_json(li, file_loc): | |
| """Write objects to a tab-delimited JSON file. | |
| :param li: objects array | |
| :type li: list | |
| :param file_loc: file location where JSON file is to be saved | |
| :type file_loc: str | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def cohen_kappa(ann1, ann2): | |
| """Computes Cohen kappa for pair-wise annotators. | |
| :param ann1: annotations provided by first annotator | |
| :type ann1: list | |
| :param ann2: annotations provided by second annotator | |
| :type ann2: list | |
| :rtype: float | |
| :return: Cohen kappa statistic |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def fleiss_kappa(M): | |
| """Computes Fleiss' kappa for group of annotators. | |
| :param M: a matrix of shape (:attr:'N', :attr:'k') with 'N' = number of subjects and 'k' = the number of categories. | |
| 'M[i, j]' represent the number of raters who assigned the 'i'th subject to the 'j'th category. | |
| :type: numpy matrix | |
| :rtype: float | |
| :return: Fleiss' kappa score | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from __future__ import absolute_import, unicode_literals | |
| # This will make sure the app is always imported when | |
| # Django starts so that shared_task will use this app. | |
| from .celery import app as celery_app | |
| __all__ = ('celery_app',) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from __future__ import absolute_import, unicode_literals | |
| import os | |
| from celery import Celery | |
| # set the default Django settings module for the 'celery' program. | |
| os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'projectname.settings') | |
| app = Celery('projectname') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # DEBUG, SECRET_KEY and ALLOWED_HOSTS | |
| INSTALLED_APPS = [ | |
| 'projectname', | |
| 'django.contrib.admin', | |
| 'django.contrib.auth', | |
| 'django.contrib.contenttypes', | |
| 'django.contrib.sessions', | |
| 'django.contrib.messages', | |
| 'django.contrib.staticfiles', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Create your tasks here | |
| from __future__ import absolute_import, unicode_literals | |
| from celery import shared_task | |
| from celery.utils.log import get_task_logger | |
| from .models import Tweet | |
| from .twitter import twitter_api, get_tweets | |
| logger = get_task_logger(__name__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from projectname.settings import config | |
| from .models import * | |
| from celery.utils.log import get_task_logger | |
| logger = get_task_logger(__name__) | |
| def twitter_api(): | |
| """Authenticate Twitter API and return the object. | |
| :rtype: tweepy.api |