https://github.com/brandenvs/semantic-similarity
This application was built so that I could learn NLP concepts and the spaCy module.
https://github.com/brandenvs/semantic-similarity
learning python semantic spacy-nlp
Last synced: about 2 months ago
JSON representation
This application was built so that I could learn NLP concepts and the spaCy module.
- Host: GitHub
- URL: https://github.com/brandenvs/semantic-similarity
- Owner: brandenvs
- Created: 2023-10-03T10:54:10.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-03T12:41:47.000Z (over 1 year ago)
- Last Synced: 2025-02-01T14:33:23.474Z (4 months ago)
- Topics: learning, python, semantic, spacy-nlp
- Language: Python
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Semantic.py
## Overview: Semantic Demonstration Python Script
The "semantic.py" script is a Python application that demonstrates the use of spaCy, a popular natural language processing library. Specifically, it showcases how to calculate the similarity between words using spaCy's pre-trained English core model (en_core_web_md). This script can help you understand how spaCy's word vectors work and how they can be used to measure the semantic similarity between words.## Usage
To run the "semantic.py" script, you can use Docker to set up a consistent environment. Here are the steps to run the script with Docker:### Prerequisites
- Make sure you have Docker installed on your system.### Step 1: Clone the Repository
```bash
git clone https://github.com/BrandenSysoutHelloWorld/semantic-similarity.git
cd .../semantic-similarity
```### Step 2: Build the Docker Image
Run the following command to build a Docker image named "my-python-app" from the provided Dockerfile:```bash
docker build -t semantic-similarity .
```### Step 3: Run the Docker Container
Once the image is built, you can run a Docker container based on it:```bash
docker run semantic-similarity
```This command will execute the "semantic.py" script inside the container, and you'll see the results of word similarity calculations.
## Script Explanation
The "semantic.py" script does the following:1. Imports the spaCy module and loads the en_core_web_md English core model.
2. Casts words ("cat," "monkey," "banana") to the model.
3. Calculates and prints the similarities between words based on the model.
4. Provides explanatory notes about the calculated similarities.
5. Demonstrates how to compare similarities between a set of custom words ("moderator," "admin," "user," "guest").
## Notes
The script's notes explain interesting observations about word similarities based on the spaCy model. It highlights how the model considers general facts and stereotypes when calculating similarity scores.## Author
- Branden van StadenFeel free to modify and experiment with the script to explore word similarities further or use it as a starting point for your own natural language processing tasks.