New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

gliner-node-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gliner-node-wrapper

Node.js wrapper around Python-based GlinER NER library

latest
npmnpm
Version
1.1.2
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

GlinER Node.js Wrapper

A secure and production-ready Node.js wrapper for the GlinER Named Entity Recognition (NER) Python library.

This package allows you to call GlinER from Node.js to extract entities using labels of your choice.

📦 Installation

Prerequisites

  • Python 3.7+
  • Node.js 14+

Step 1: Install via npm

npm install gliner-node-wrapper

Step 2: Python Dependencies (Auto-installed)

This package automatically installs Python dependencies (gliner, torch, transformers) during installation using a postinstall hook.

🚀 Usage

Basic Example

const { extractEntities } = require('gliner-node-wrapper');

const text = "Barack Obama served as president of the United States.";
const labels = ["person", "organization", "location"];

extractEntities(text, labels)
  .then((entities) => console.log("Entities:", entities))
  .catch((err) => console.error("Error:", err.message));

Output

[
  { "text": "Barack Obama", "label": "person" },
  { "text": "United States", "label": "location" }
]

🛠 How It Works

  • A Node.js script (index.js) spawns a secure Python subprocess.
  • Input text and labels are passed via stdin to a Python script.
  • The Python script runs GlinER and returns extracted entities as JSON.

📁 Project Structure

gliner-node-wrapper/
├── index.js               # Main Node wrapper
├── gliner_wrapper.py      # Python subprocess handler
├── install-python.js      # Auto-installs Python deps
├── requirements.txt       # Python dependencies
├── example.js             # Demo usage
├── package.json
└── README.md

🔐 Security Features

  • Input validation on both JS and Python sides
  • Timeout to kill unresponsive subprocesses
  • No shell evaluation (uses spawn safely)
  • Full error reporting

🧪 Development

Clone the repo:

git clone https://github.com/yourname/gliner-node-wrapper.git
cd gliner-node-wrapper
npm install

Run the test:

npm test

📜 License

MIT © 2025 Your Name

Keywords

ner

FAQs

Package last updated on 19 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts