11# Parsing to CoNLL with spaCy, spacy-stanza, and spacy-udpipe
22
3- ** The last version to support spaCy v2 can be found** [ here] ( < https://github.com/BramVanroy/spacy_conll/tree/v2.1.0 > ) .
4- The current version only supports v3.
5-
6- This module allows you to parse text into CoNLL-U format\_ . You can use it as a command line tool, or embed it in your
3+ This module allows you to parse text into CoNLL-U format. You can use it as a command line tool, or embed it in your
74 own scripts by adding it as a custom pipeline component to a spaCy, ` spacy-stanza ` , or ` spacy-udpipe ` pipeline. It
85 also provides an easy-to-use function to quickly initialize a parser as well as a ConllParser class with built-in
96 functionality to parse files or text.
@@ -26,23 +23,22 @@ By default, this package automatically installs only [spaCy](https://spacy.io/us
2623 * are* trained on UD data.
2724
2825** NOTE** : ` spacy-stanza ` and ` spacy-udpipe ` are not installed automatically as a dependency for this library, because
29- it might be too much overhead for those who don't need UD. If you wish to use their functionality (e.g. better
30- performance, real UD output), you have to install them manually or use one of the available options as described
31- below.
26+ it might be too much overhead for those who don't need UD. If you wish to use their functionality, you have to install
27+ them manually or use one of the available options as described below.
3228
3329If you want to retrieve CoNLL info as a ` pandas ` DataFrame, this library will automatically export it if it detects
3430 that ` pandas ` is installed. See the Usage section for more.
3531
3632To install the library, simply use pip.
3733
38- ``` bash
34+ ``` shell
3935# only includes spacy by default
4036pip install spacy_conll
4137```
4238
4339A number of options are available to make installation of additional dependencies easier:
4440
45- ``` bash
41+ ``` shell
4642# include spacy-stanza and spacy-udpipe
4743pip install spacy_conll[parsers]
4844# include pandas
@@ -100,11 +96,8 @@ Because this library supports different spaCy wrappers (`spacy`, `stanza`, and `
10096 find the function's signature below. Have a look at the [ source code] ( spacy_conll/utils.py ) to read more about all the
10197 possible arguments or try out the [ examples] ( examples/ ) .
10298
103- ** NOTE** : ` is_tokenized ` does not work for ` spacy-udpipe ` and ` disable_sbd ` only works for ` spacy ` . ` spacy-udpipe ` has
104- made a change to allow pretokenized text, but it depends on the input format and cannot be fixed at initialisation of
105- the parser. See release v0.3.0 of spacy-udpipe or [ this PR] ( https://github.com/TakeLab/spacy-udpipe/pull/19 ) . Using
106- ` is_tokenized ` for ` spacy-stanza ` also affects sentence segmentation, effectively * only* splitting on new
107- lines. With ` spacy ` , ` is_tokenized ` disables sentence splitting completely.
99+ ** NOTE** : ` is_tokenized ` does not work for ` spacy-udpipe ` . Using ` is_tokenized ` for ` spacy-stanza ` also affects sentence
100+ segmentation, effectively * only* splitting on new lines. With ` spacy ` , ` is_tokenized ` disables sentence splitting completely.
108101
109102``` python
110103def init_parser (
@@ -221,8 +214,8 @@ for sent in doc.sents:
221214Upon installation, a command-line script is added under tha alias ` parse-as-conll ` . You can use it to parse a
222215string or file into CoNLL format given a number of options.
223216
224- ``` bash
225- > parse-as-conll -h
217+ ``` shell
218+ parse-as-conll -h
226219usage: parse-as-conll [-h] [-f INPUT_FILE] [-a INPUT_ENCODING] [-b INPUT_STR] [-o OUTPUT_FILE]
227220 [-c OUTPUT_ENCODING] [-s] [-t] [-d] [-e] [-j N_PROCESS] [-v]
228221 [--ignore_pipe_errors] [--no_split_on_newline]
@@ -295,8 +288,8 @@ optional arguments:
295288
296289For example, parsing a single line, multi-sentence string:
297290
298- ```bash
299- > parse-as-conll en_core_web_sm spacy --input_str "I like cookies. What about you?" --include_headers
291+ ```shell
292+ parse-as-conll en_core_web_sm spacy --input_str "I like cookies. What about you?" --include_headers
300293
301294# sent_id = 1
302295# text = I like cookies.
@@ -315,8 +308,8 @@ For example, parsing a single line, multi-sentence string:
315308
316309For example, parsing a large input file and writing output to a given output file, using four processes:
317310
318- ```bash
319- > parse-as-conll en_core_web_sm spacy --input_file large-input.txt --output_file large-conll-output.txt --include_headers --disable_sbd -j 4
311+ ```shell
312+ parse-as-conll en_core_web_sm spacy --input_file large-input.txt --output_file large-conll-output.txt --include_headers --disable_sbd -j 4
320313```
321314
322315
0 commit comments