Library that adds FoLiA (format for linguistic annotation) support to spaCy
Project description
Convert Spacy output to FoLiA XML Documents.
Installation
$ pip install spacy2folia
Usage Example
Using the command line tool on an input file named test.txt:
$ spacy2folia --model en_core_web_sm test.txt
This results in a document test.folia.xml in the current working directory.
You can also invoke the command line tool on one or more FoLiA documents as input (note that this will edit the given file in-place unless you set --stdout!)
$ spacy2folia --model en_core_web_sm document.folia.xml
Usage from Python:
import spacy
from spacy2folia import spacy2folia
text = "Input text goes here"
nlp = spacy.load("en_core_web_sm")
doc = nlp(text)
foliadoc = spacy2folia.convert(doc, "example", paragraphs=True)
foliadoc.save("/tmp/output.folia.xml")
Usage from Python with FoLiA input:
import spacy
import folia.main as folia
from spacy2folia import spacy2folia
foliadoc = folia.Document(file="/tmp/input.folia.xml")
nlp = spacy.load("en_core_web_sm")
spacy2folia.convert_folia(foliadoc, nlp)
foliadoc.save("/tmp/output.folia.xml")
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
Spacy2FoLiA-0.3.tar.gz
(5.3 kB
view hashes)