31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
import json
|
|
|
|
with open('./data/models_info.json', 'r', encoding='utf-8') as file:
|
|
models = json.load(file)
|
|
|
|
ner_models = []
|
|
for mdl in models:
|
|
if mdl['model_name'].__contains__('ner') or mdl['model_name'].__contains__('Ner') or mdl['model_name'].__contains__('Ner'):
|
|
ner_models.append(mdl)
|
|
# [mdl['model_name']]= {
|
|
# "task": mdl['task'],
|
|
# "last_modified": mdl['last_modified'],
|
|
# "downloads": int(mdl['downloads']),
|
|
# "likes": mdl['likes'],
|
|
# "language": mdl['language']
|
|
# }
|
|
sorted_ner_models = sorted(ner_models, key=lambda x: x["downloads"], reverse=True)
|
|
|
|
with open('./data/models_ner_info.json', 'w', encoding='utf-8') as file:
|
|
jsondata = json.dumps(sorted_ner_models, ensure_ascii=False, indent=2)
|
|
file.write(jsondata)
|
|
|
|
ner_models_text = ''
|
|
for mdl in sorted_ner_models:
|
|
ner_models_text += ''.join(f"{mdl['downloads']} -- {mdl['model_name']}\n")
|
|
|
|
with open('./data/models_ner_info.txt', 'w', encoding='utf-8') as file:
|
|
file.write(ner_models_text)
|
|
|
|
print(len(ner_models))
|