This repository has been archived by the owner on Dec 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add list of pretrained models to README (#246)
* add list of pretrained models to README * fix * address @dirkgr comments
- Loading branch information
Showing
4 changed files
with
114 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
"archive_file": null, | ||
"training_config": null, | ||
"overrides": null, | ||
"install_instructions": "pip install allennlp==1.0.0 allennlp-models==1.0.0", | ||
"install_instructions": "pip install allennlp==2.2.0 allennlp-models==2.2.0" | ||
}, | ||
"model_details": { | ||
"description": null, | ||
|
@@ -21,7 +21,7 @@ | |
"paper": null, | ||
"citation": null, | ||
"license": null, | ||
"contact": "[email protected]", | ||
"contact": "[email protected]" | ||
}, | ||
"intended_use": { | ||
"primary_uses": null, | ||
|
@@ -57,4 +57,4 @@ | |
"model_ethical_considerations": { | ||
"ethical_considerations": null | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
""" | ||
Run this script to update the list of pre-trained models in the README based on the current model cards. | ||
""" | ||
|
||
from typing import List | ||
import json | ||
import glob | ||
|
||
|
||
AUTO_GENERATED_SECTION_START = "<!-- This section is automatically generated" | ||
AUTO_GENERATED_SECTION_END = "<!-- End automatically generated section -->" | ||
|
||
|
||
def main(): | ||
with open("README.md") as readme_file: | ||
readme_lines = readme_file.readlines() | ||
|
||
section_start_idx = next( | ||
(i for i, l in enumerate(readme_lines) if l.startswith(AUTO_GENERATED_SECTION_START)) | ||
) | ||
section_end_idx = next( | ||
(i for i, l in enumerate(readme_lines) if l.startswith(AUTO_GENERATED_SECTION_END)) | ||
) | ||
|
||
model_list: List[str] = ["\n"] | ||
for model_card_path in sorted(glob.glob("allennlp_models/modelcards/*.json")): | ||
if model_card_path.endswith("modelcard-template.json"): | ||
continue | ||
with open(model_card_path) as model_card_file: | ||
model_card = json.load(model_card_file) | ||
model_id = model_card["id"] | ||
description = model_card["model_details"]["short_description"] | ||
model_list.append( | ||
f"- [`{model_id}`](https://github.com/allenai/allennlp-models/tree/main/" | ||
f"{model_card_path}) - {description}\n" | ||
) | ||
model_list.append("\n") | ||
|
||
readme_lines = ( | ||
readme_lines[: section_start_idx + 1] + model_list + readme_lines[section_end_idx:] | ||
) | ||
|
||
with open("README.md", "w") as readme_file: | ||
readme_file.writelines(readme_lines) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |