I learned much of my natural language processing using Python’s `nltk` library which, coupled with the nltk book (https://www.nltk.org/book/), provides a great introduction to the topic. When I hit industry, however, I never really found a use for it, nor motivate myself to learn the intricacies of creating a corpus from my own dataset. Many…
Author: Foggy Programmer
How Python Finds Your Imports
It seems easy. I need a package, say pandas, so I run pip install pandas. Then, at the top of my file I can get access to this library by a simple import at the top: import pandas as pd. But how does Python determine where the package is located? First, Python will check if…
string — Common string operations (Part 1: methods)
The string module provides a number of methods and constants for manipulating strings (type: str). These work on all strings in Python which are created using quotation marks: ‘single’, “double”, ”’triple-single”’, and “””triple-double”””-quoted text. Strings can also be created by applying the built-in str( ) function to any other datatype. In Python, strings are immutable…
How Virtual Environments Work (on Windows)
Brett Cannon made a short (and quite interesting post) on virtual environments and their context, though this focused on their application to a Unix-based OS rather than Windows. I’d like to summarize the content there and adapt it to Windows. History Why do we have virtual environments? This may be a perplexing question to someone…
More Unwanted WordPress Logins
Two weeks ago I discussed a plugin for ‘hiding’ WordPress login/admin sites: rather than /wp-admin/, we have /abrakadabra/ (or anything…). At a prior time, I had installed another plugin called WordFence. This allowed setting up 2FA (i.e., two factor authentication with an Authenticator app) and provided a list of login attempts. The majority of targets…
pathlib
— Object-oriented filesystem paths
The pathlib module was introduced in Python 3.4 (see PEP-428) — or, more accurately, pathlib was a 3rd party module which was added to the standard library (i.e., the packages that come with all installs of Python — unless excluded for, e.g., including library on smaller devices). It was attempting to provide a more friendly,…
Hiding WordPress Login Page
This blog runs on WordPress, and, despite the hours I’ve invested in generating this great content, the nearly one thousand ‘visitors’ to my website each day seem to really like my sign-in page: https://SITE/wp-admin. And they like to experiment with random username and password combinations… I didn’t contribute at all to that page, and so…
Moving Large Program Data to Another Drive with Links
I regularly run a program (on Windows) that downloads and indexes quite a bit of data. While this makes the application run quite smoothly, it does take up a lot of disk space. Recently, a change modified the save location for this data from my spacious D:\ to the rather more cramped conditions of C:\Users\foggy\AppData\Local….
Editing On GitHub
I’ll sometimes edit directly on GitHub. It’s probably a package I’m using and I need to remove or add a line or two. For example, the prompt for this posting was to remove a line that added a log file globally using loguru. It seemed a good idea at the time, when the file was…
Walruses and Regular Expressions
Incorporating regular expressions has been clunky. Let’s imagine that we need to search for a few regular expressions in some text and then perform task when a term is found. In code: Unfortunately, we can’t just use the match because, if the pattern is not in text, the result is None. So, before using the…