Skip to main content

spacy-to-naf is a spaCy wrapper that converts text or NAF input to NAF. The converter minimally extracts a tokenized text layer, and can additionally extract terms, deps, entities and chunks layers.

Installation

To install spacy-to-naf:

pip install spacy-to-naf

Download a spaCy model, eg. 'en-core-web-sm':

python -m spacy download en-core-web-sm

Usage

Specify the spaCy model and the NAF layers to create (the text layer is always created).

from spacy_to_naf.converter import Converter
converter = Converter('en-core-web-sm', add_terms=True, add_deps=True, add_entities=True, add_chunks=True)

The input may be a naf or text directory or a text string.

Text input

To convert text to a file 'example.naf' in the current directory:

text = "The cat sat on the mat. Felix was his name."
naf = converter.convert(text, 'example.naf', '.')

The converter additionally returns a NafParser object for further processing.

Processing files

To process text files from a 'text_in' to 'naf_out' directory:

converter.convert_text_files('text_in', 'naf_out')

Note that input text files are expected to end in '.txt'.

To process NAF files from 'naf_in' to 'naf_out':

converter.convert_naf_files('naf_in', 'naf_out')

Output files carry the same name as the input file, extension excepted.

Release files for spacy-to-naf 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spacy-to-naf 0.2.0
File Size Uploaded
spacy-to-naf-0.2.0.tar.gz 8.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spacy-to-naf 0.2.0
File Interpreter ABI Platform
spacy_to_naf-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.5 kB

Release files / spacy-to-naf-0.2.0.tar.gz

Download URL spacy-to-naf-0.2.0.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
96fe6100a2bfb2177bb5b1f345411315f256851c04cb4b90cf03f1b0f06b1225
BLAKE2b-256 checksum
How to use checksums
5762e1ed71623f7ff422ce2fdf21a313e1cbc31223a4cfa530639b7304d67dad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.0

Release files / spacy_to_naf-0.2.0-py3-none-any.whl

Download URL spacy_to_naf-0.2.0-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9bc054fa48ad797f22ac6a4b1e8f444a60a33cf7f51ed175a8fd7ad02964f0ca
BLAKE2b-256 checksum
How to use checksums
cdd052cbc299900de98235a518f150d048df9a86b15dfcd6a6862b41741a809d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.0

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page