In this story, I will share what I use in my day-to-day work and what has helped me improve my code. Check the list below to see if there’s anything new for you!
_
operator.get
instead of [key]
for dictionary iterationszip
function*
and **
Hallelujah! That is what I thought when I learned about the Python 3.6+ update that includes a new way of formatting strings: the Python formatted string literal. …
In this article, I’ll show you three scripting conventions and corresponding built-in modules to help better format your Python scripts. These modules are designed to adhere to the DRY (don’t repeat yourself) principle and are there to improve the quality of your code and scripts!
In short, we’ll go over the following three components:
ifmain
and corresponding main()
function.argparse
.logging()
module instead of print()
.ifmain
refers to the last lines of code in a Python script that you often see: if __name__ == "__main__":
. When…
In this article, you will learn how the Django messages framework works and how you can use its power, including a way to fade the messages when submitting forms via JavaScript without reloading the page.
What happens when a user sends a request, but processing that request takes longer than the HTTP request-response cycle? What if you’re accessing multiple databases or want to return a document too large to process within the time window? What if you want to access an API, but the number of requests is throttled to a maximum of n requests per t time window?
These are part of the questions that were raised during the data collection process for my master’s thesis. For my research, microposts from Twitter were scraped via the Twitter API. …
In this story, we’ll look at JavaScript Object Notation or JSON, probably the world’s preferred data-interchange format and a sure-fire upgrade from more traditional file storage options (XML, CSV, TSV).
We’ll cover the basics for creating and loading JSON files, file storage, and newline delimited JSON storage and take a look into a more specific use-case of working with textual data and JSON.
JSON is widely used in web applications as the preferred way to interchange data, especially to and from front-end to back-end middleware.
In this story, we’ll explore the Inter-Annotator Agreement (IAA), a measure of how well multiple annotators can make the same annotation decision for a certain category. Supervised Natural Language Processing algorithms use a labeled dataset, that is often annotated by humans. An example would be the annotation scheme for my master’s thesis, where tweets were labeled as either abusive or non-abusive.
IAA shows you how clear your annotation guidelines are, how uniformly your annotators understood it, and how reproducible the annotation task is. It is a vital part of both the validation and reproducibility of classification results.
Accuracy and F1…
I had learned the hard way that functional parts, such as database operations, log-ins, or registrations break without you noticing. Your users, however, will notice. Testing is a vital part of the production process of and in this story, we’ll briefly introduce how to test your Django application.
This story covers:
TestCase
jQuery is a lightweight and easy to use JavaScript library that helps in creating complex functionalities with few lines of coding. jQuery coding is shorter and often more simplified than equivalent vanilla JS code. So why do many developers move away from this library and towards plain or vanilla JavaScript?
In this story we’ll go through:
fading an element
jQuery is a library that has a high level of abstraction, making it easy to use but…
This tutorial will provide you with all that you need to know to create a user registration route with email verification. We’ll go through the registration process, unique token generation, and sending e-mails with the email-client Sendgrid. They offer a free plan with up to 100 emails per day. We’ll also show you how to create a forgot password route where users can enter their e-mail to get a reset password link.
The Django app parts we’re going to go through are the URLs, the project views, the unique token generation, and the registration forms and models. …
Here’s for something completely different: parsing pdf documents and extracting the headers and paragraphs! There are various packages that extract text from pdf documents and convert them to HTML, but I’ve found these to be either too elaborate for the task at hand and/or too complex. In my experience, generic pdf parsers generalize okay-ish over all documents, but for a specific use-case of somewhat similarly structured documents, we can enhance performance with some code of our own!
Since pdf files consist of unstructured text, we need to find some similarities over the different documents on how headers and paragraphs are…