mirror of
https://github.com/qurator-spk/page2tsv.git
synced 2025-07-12 11:39:53 +02:00
enable NED only usage of find-entities
This commit is contained in:
parent
975487a233
commit
c12bea2cb0
1 changed files with 17 additions and 5 deletions
12
cli.py
12
cli.py
|
@ -329,6 +329,18 @@ def find_entities(tsv_file, tsv_out_file, ner_rest_endpoint, ned_rest_endpoint,
|
||||||
|
|
||||||
tsv, ner_result = ner(tsv, ner_rest_endpoint)
|
tsv, ner_result = ner(tsv, ner_rest_endpoint)
|
||||||
|
|
||||||
|
elif os.path.exists(tsv_file):
|
||||||
|
|
||||||
|
print('Using NER information that is already contained in file: {}'.format(tsv_file))
|
||||||
|
|
||||||
|
tmp = tsv.copy()
|
||||||
|
tmp['sen'] = (tmp['No.'] == 0).cumsum()
|
||||||
|
|
||||||
|
ner_result = [[{'word': row.TOKEN, 'prediction': row['NE-TAG']} for _, row in sen.iterrows]
|
||||||
|
for _, sen in tmp.groupby('sen')]
|
||||||
|
else:
|
||||||
|
raise RuntimeError("Either NER rest endpoint or NER-TAG information within tsv_file required.")
|
||||||
|
|
||||||
if ned_rest_endpoint is not None:
|
if ned_rest_endpoint is not None:
|
||||||
|
|
||||||
tsv, ned_result = ned(tsv, ner_result, ned_rest_endpoint, json_file=ned_json_file, threshold=ned_threshold)
|
tsv, ned_result = ned(tsv, ner_result, ned_rest_endpoint, json_file=ned_json_file, threshold=ned_threshold)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue