mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 09:26:27 +03:00
Add conversion rule for .conll
This commit is contained in:
parent
692bd2a186
commit
55dab77de8
|
@ -12,7 +12,8 @@ from ..util import prints
|
||||||
# from /converters.
|
# from /converters.
|
||||||
|
|
||||||
CONVERTERS = {
|
CONVERTERS = {
|
||||||
'.conllu': conllu2json
|
'.conllu': conllu2json,
|
||||||
|
'.conll': conllu2json
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ def conllu2json(input_path, output_path, n_sents=10, use_morphology=False):
|
||||||
sentences = []
|
sentences = []
|
||||||
|
|
||||||
output_filename = input_path.parts[-1].replace(".conllu", ".json")
|
output_filename = input_path.parts[-1].replace(".conllu", ".json")
|
||||||
|
output_filename = input_path.parts[-1].replace(".conll", ".json")
|
||||||
output_file = output_path / output_filename
|
output_file = output_path / output_filename
|
||||||
with output_file.open('w', encoding='utf-8') as f:
|
with output_file.open('w', encoding='utf-8') as f:
|
||||||
f.write(json_dumps(docs))
|
f.write(json_dumps(docs))
|
||||||
|
@ -46,8 +47,8 @@ def read_conllx(input_path, use_morphology=False, n=0):
|
||||||
tokens = []
|
tokens = []
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
|
||||||
id_, word, lemma, pos, tag, morph, head, dep, _1, \
|
parts = line.split('\t')
|
||||||
_2 = line.split('\t')
|
id_, word, lemma, pos, tag, morph, head, dep, _1, _2 = parts
|
||||||
if '-' in id_ or '.' in id_:
|
if '-' in id_ or '.' in id_:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user