Skip to main content

NERNA is a lightweight tool for annotating named entities directly within Python notebooks, ideal for quick and interactive NER tasks without the need for deployment or external servers.

Project description

NERNA (NER & Text Classification for Notebooks)

Follow the official repository: NER-Notebook-Annotation - GitHub

NERNA is a lightweight package designed for Named Entity Recognition (NER) annotation and Text Classification directly within Python notebooks.

Originally intended as a Streamlit-based interface, it has been reworked to run natively inside notebook environments (such as Jupyter, Google Colab, Databricks, etc.). This makes it easier to use without requiring deployment of web applications or cloud server contracts.

Key Features

  • ✅ Lightweight, interactive JavaScript interface embedded in notebooks
  • ✅ Compatible with local notebooks and cloud platforms (e.g., Colab, Databricks)
  • ✅ Supports both Span-level NER Annotation and Document-level Classification
  • ✅ No need for external servers or deployments
  • ⚠️ Annotations are made using JavaScript, so they cannot be accessed directly as Python variables. However, the input to the tool must be a Python list of strings (or a list of [id, text] tuples).

1. NER Annotation

from nerna import NERAnnotator

# List of texts to annotate
texts = [
    'Brazil won the 2002 World Cup.',
    'The planet’s drinking water is running out.'
]

# Initialize annotation (optionally customize labels)
annotator = NERAnnotator(texts, labels=['Location', 'Date', 'Event'])

# Render the interactive annotation interface
annotator.render(variable_name="annotator")

After annotating in the UI, click "🐍 Export to Python" and access your data:

print(annotator.annotations)

2. Text Classification

The TextClassifier provides a fast way to label entire documents with a single click.

from nerna import TextClassifier

# Using tuples to preserve document IDs
data = [
    ["doc_01", "The new smartphone has a great battery life but the camera is sub-par."],
    ["doc_02", "I love the design, very sleek and modern!"]
]

labels = ["Positive", "Negative", "Neutral"]

# Initialize the classifier
classifier = TextClassifier(texts=data, labels=labels)

# Render the UI
classifier.render(variable_name="classifier")

After classifying in the UI, click "🐍 Export to Python" and retrieve:

print(classifier.classifications)
# Output format: {"doc_01": "Negative", "doc_02": "Positive"}

Notes

Retrieving Data

There are two ways to retrieve the annotated data back into Python:

Option A: Export to Python Variable (Recommended for Colab/Jupyter)

Pass the name of your variable to the render method:

annotator.render(variable_name="annotator")
# or for classification:
# classifier.render(variable_name="classifier")
  • In the UI, click the "🐍 Export to Python" button.
  • Access the data in Python via .annotations or .classifications.

Option B: Load from JSON (Fallback)

  • Click "📥 Download JSON" in the UI to save a .json file.
  • Load it manually in Python.

  • Ideal for manual review, small-scale labeling tasks, or quick experimentation in NLP workflows.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nerna-0.2.2.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nerna-0.2.2-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file nerna-0.2.2.tar.gz.

File metadata

  • Download URL: nerna-0.2.2.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for nerna-0.2.2.tar.gz
Algorithm Hash digest
SHA256 32352e35015aa056a50af1c350cd76b1f1a00dd6c562df09bee2646834165bef
MD5 4f4ba11fc21be240af328614a3d9ac0b
BLAKE2b-256 d785e555d91c3dbcf3ae060de7b56bdc91ee454a59a64a4470f4854e8186c134

See more details on using hashes here.

File details

Details for the file nerna-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: nerna-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for nerna-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3d672972e04b6766b98fc5d748b56e0c12268521a50c66454dff1c0baa8bc4fb
MD5 deeebdef1278202d26da4f1fd17e6899
BLAKE2b-256 476281ed4fff38e9c904a0f54f444e59ddc71f8e008e8343ec8ed19dd94533ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page