mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 09:56:28 +03:00
don't require json-files to have syntactic annotation
This commit is contained in:
parent
12024b0b0a
commit
4d7f393fae
|
@ -151,9 +151,9 @@ def read_json_file(loc, docs_filter=None):
|
||||||
for i, token in enumerate(sent['tokens']):
|
for i, token in enumerate(sent['tokens']):
|
||||||
words.append(token['orth'])
|
words.append(token['orth'])
|
||||||
ids.append(i)
|
ids.append(i)
|
||||||
tags.append(token['tag'])
|
tags.append(token.get('tag','-'))
|
||||||
heads.append(token['head'] + i)
|
heads.append(token.get('head',0) + i)
|
||||||
labels.append(token['dep'])
|
labels.append(token.get('dep','ROOT'))
|
||||||
# Ensure ROOT label is case-insensitive
|
# Ensure ROOT label is case-insensitive
|
||||||
if labels[-1].lower() == 'root':
|
if labels[-1].lower() == 'root':
|
||||||
labels[-1] = 'ROOT'
|
labels[-1] = 'ROOT'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user