This tutorial will walk through how to use Semantra with practical examples. It is recommended for new users of the tool.
- Installation instructions: below
- Lesson 1: Semantically searching Shakespeare
- Lesson 2: Advanced searching across all U.S. presidential inagural speeches
Semantra is a command-line tool that is built with Python.
To install Semantra, you must first have Python installed, which you can accomplish in several ways:
- downloading from the Python website
- via a package manager. For instance, if you have Homebrew installed:
brew install python
Open the terminal and verify Python is working via:
python --version
It is recommended to use Python 3.9 or greater.
If you need help installing Python, consult the sections on installing Python 3 from this guide.
Once you have Python installed, you are ready to install Semantra. The most convenient way is via pipx. Run the following commands in the terminal:
python3 -m pip install --user pipx
python3 -m pipx ensurepath
Once pipx
is installed, you may need to open a new terminal window for the changes to go into affect. Once you launch a new terminal window, Semantra can be installed globally via:
pipx install semantra
If you already have a working installation of Semantra and want to upgrade, you can run pipx upgrade semantra
.
Once this command runs, verify that Semantra is installed by running the following in the terminal (it may take several seconds the first time it's run):
semantra
If all goes well, you'll get a print out to the terminal that looks like this:
Usage: semantra [OPTIONS] [FILENAME]...
Try 'semantra --help' for help.
Error: Must provide a filename to process/query
It's time to use the tool!
Now that Semantra is installed, let's start using it! We'll start by semantically searching Shakespeare: