@nlp-x/spacy3.x
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

spacy3.x

NPM CI Issues Forks Stars License

JavaScript library for accessing linguistic annotations provided by spaCy v.3.x.

Prerequisites

  • Node.js
  • NPM
  • Python3
  • pip3

Installation

NPM:

npm install @nlp-x/spacy3.x

Yarn:

yarn add @nlp-x/spacy3.x

PNPM:

pnpm install @nlp-x/spacy3.x

Usage

import spacy from '@nlp-x/spacy3.x';

const info = spacy.info();
console.log(info);

const nlp = spacy.load('en_core_web_lg');

const doc = nlp(`The Mars Orbiter Mission (MOM), informally known as Mangalyaan, was launched into Earth orbit on 5 November 2013 by the Indian Space Research Organisation (ISRO) and has entered Mars orbit on 24 September 2014. India thus became the first country to enter Mars orbit on its first attempt. It was completed at a record low cost of $74 million.`);

const sentences = doc.sents;
const tokens = doc.tokens;
const ents = doc.ents;

console.log('doc', doc)
console.log('sentences', sentences);
console.log('tokens', tokens);
console.log('ents', ents);

console.log('tokens[0].text', tokens[0].text);
console.log('tokens[0].lemma', tokens[0].lemma);
console.log('tokens[0].lower', tokens[0].lower);
console.log('tokens[0].is_stop', tokens[0].is_stop);
console.log('tokens[0].is_sent_start', tokens[0].is_sent_start);
console.log('tokens[0].ent_type', tokens[0].ent_type);
console.log('tokens[0].ent_iob', tokens[0].ent_iob);

const sentence1 = sentences[0];

console.log('sentence1', sentence1);
console.log('sentence1.tokens[0]', sentence1.tokens[0]);
console.log('sentence1.tokens[0].text', sentence1.tokens[0].text);
console.log('sentence1.tokens[0].pos', sentence1.tokens[0].pos);
console.log('sentence1.tokens[0].is_sent_start', sentence1.tokens[0].is_sent_start);

Tests

yarn test

Download models

https://github.com/explosion/spacy-models/releases/tag/en_core_web_sm-3.6.0

MODEL_NAME=en_core_web_sm
MODEL_VERSION=3.6.0

curl --location --remote-header-name --remote-name https://github.com/explosion/spacy-models/releases/download/${MODEL_NAME}-${MODEL_VERSION}/${MODEL_NAME}-${MODEL_VERSION}-py3-none-any.whl

wheel unpack ${MODEL_NAME}-${MODEL_VERSION}-py3-none-any.whl
cp -r ${MODEL_NAME}-${MODEL_VERSION}/${MODEL_NAME}/${MODEL_NAME}-${MODEL_VERSION} tests
rm -r ${MODEL_NAME}-${MODEL_VERSION}
rm ${MODEL_NAME}-${MODEL_VERSION}-py3-none-any.whl

Package Sidebar

Install

npm i @nlp-x/spacy3.x

Weekly Downloads

2

Version

1.0.0

License

Apache-2.0

Unpacked Size

39.1 kB

Total Files

25

Last publish

Collaborators

  • kaiwedekind