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
| <div class="" id="modal-form"> | |
| <h2>Login</h2> | |
| <form method="POST" class="mx-auto" action="{% url 'login' %} "> | |
| {% csrf_token %} | |
| {% for field in form %} | |
| <div class="form-group"> | |
| {{ field }} | |
| {% if field.help_text %} | |
| <small class="form-text text-muted">{{ field.help_text|safe }}</small> |
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
| <head> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js"></script> | |
| </head> | |
| {% load static %} | |
| <section> | |
| <small class="form-text text-muted">Choose a dataset</small> | |
| <form action="{% url 'demographics' %}" class="" method="POST"> | |
| {% csrf_token %} | |
| <div class="form-check form-check-inline"> |
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
| // form dynamic request for charts | |
| document.body.addEventListener( 'click', function (event) { | |
| if( event.target.className === 'form-check-input dataset' ) { | |
| const form = event.target.form; | |
| const data = new FormData(form); | |
| const request = new XMLHttpRequest(); | |
| request.open(form.method, form.action, true); | |
| request.send(data); | |
| } |
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 django.shortcuts import render | |
| from django.template.loader import render_to_string | |
| from django.views.decorators.http import require_http_methods | |
| from django.http import JsonResponse | |
| from .data_preparation import user_demographics, hashtag_demographics, creation_date_demographics, text_demographics, demographics_info | |
| @require_http_methods(["GET", "POST"]) | |
| def demographics(request): |
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 .models import * | |
| from nltk.tokenize import TweetTokenizer | |
| from nltk.corpus import stopwords | |
| import seaborn as sns | |
| import time | |
| def hashtag_demographics(route, label): | |
| """Return most-used hashtags.""" |
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
| // form dynamic request for charts | |
| document.body.addEventListener( 'click', function (event) { | |
| if( event.target.className === 'form-check-input dataset' ) { | |
| const form = event.target.form; | |
| const data = new FormData(form); | |
| const request = new XMLHttpRequest(); | |
| request.open(form.method, form.action, true); | |
| request.send(data); | |
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
| function get_time_config(label, data_labels, data_values) { | |
| // configurations for the chart | |
| return { | |
| type: 'line', | |
| data: { | |
| labels: data_labels, | |
| datasets: [{ | |
| label: 'counts', | |
| data: data_values, | |
| backgroundColor: Array(56).fill('rgba(255, 99, 132, 0.5)'), |
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 fonts(doc, granularity=False): | |
| """Extracts fonts and their usage in PDF documents. | |
| :param doc: PDF document to iterate through | |
| :type doc: <class 'fitz.fitz.Document'> | |
| :param granularity: also use 'font', 'flags' and 'color' to discriminate text | |
| :type granularity: bool | |
| :rtype: [(font_size, count), (font_size, count}], dict | |
| :return: most used fonts sorted by count, font style information |
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 headers_para(doc, size_tag): | |
| """Scrapes headers & paragraphs from PDF and return texts with element tags. | |
| :param doc: PDF document to iterate through | |
| :type doc: <class 'fitz.fitz.Document'> | |
| :param size_tag: textual element tags for each size | |
| :type size_tag: dict | |
| :rtype: list | |
| :return: texts with pre-prended element tags |