Skip to content

benthecoder/notion_nlp

Repository files navigation

Notion NLP Journal

Bringing NLP to notion.so with expert.ai.

Do you write your daily journal on Notion?

This app automatically add sentiment analysis, keyword extraction, and emotional traits to your journal entries.

See this live demo of a journal entry with NLP!

Features

The main features of this app are:

  • Sentiment analysis: score from -100 to 100
  • Emotional traits: see list of emotions here
  • Topic extraction: see list of topics here
  • Automatic updates for new journal entries with Github Actions

Below is a sample entry of a bad day generated by texti.app

ex1

And here's a good day

ex2

Limitations

Here are a couple of limitations of this app:

  • journal entries must be in title
  • properties must be created beforehand and must match spelling and capitalization, as well as property type
  • keyword extraction is not great, some of them don't make sense

Usage

Step 1: Get credentials

Get your Notion Token and database ID for your journal page by following this guide

Sign up for a developer account with expert.ai and save your username and password.

Save replace the placeholders with your credentials in .env.example file.

NOTION_TOKEN=<NOTION_TOKEN>
NOTION_DATABASE_ID=<YOUR_JOURNAL_DATABASE_ID>
EAI_USERNAME=<YOUR_USERNAME>
EAI_PASSWORD=<YOUR_PASSWORD>

Rename .env.example to .env

Step 2: Setup your notion page

First, the page must have the following properties, note the spelling and capitalization must be exact.

  • date - Date
  • sentiment_score - # number
  • topics - text
  • emotions - text

Below is an image of the properties

properties

Next, make sure the journal entries have to be the title of the pages.

entries

step 3: Run locally

Create Conda environment

conda env create -n notion-nlp python=3.8

Activate the environment

conda activate notion-nlp

Install requirements

pip install -r requirements.txt

run the script

python main.py --all

You should see that your journal entires are now enriched with sentiment, topics and emotions like below

nlp-res

Tip: you can turn those topics and emotions into tags by switching it's property to multi_select

tags

However, note that to add NLP info to future journal entries, you need to keep it as a text property.

step 4: setup Github Workflows (optional)

add the secrets from .env to your repo by going to Settings > Secrets > Actions > New repository secret

setup dev environment

pip install -r requirements-dev.txt

run pre-commit

pre-commit run --all-files

References

libraries

Docs

Try the api live

Todo

  • Add tests
  • Save api call results in MongoDB
  • Build a streamlit app that visualizes knowledge graph of journal entries

About

Adds NLP to Notion

Topics

Resources

Stars

Watchers

Forks