-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump the pip group across 1 directory with 3 updates (#3070)
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Yifan Mai <yifan@cs.stanford.edu>
- Loading branch information
1 parent
4fbe7d4
commit bec3727
Showing
7 changed files
with
82 additions
and
25 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
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import nltk | ||
from importlib.metadata import version | ||
|
||
|
||
def install_nltk_resources(): | ||
"""Install resources for nltk tokenizers, which is required for bleu and rouge scores.""" | ||
# Install "punkt_tab" for nltk>=3.9.1 or "punkt" for nltk<=3.8.1 | ||
# | ||
# "punkt" is not longer supported for newer versions of nltk due to a security issue | ||
# and has been replaced by "punkt_tab". For more information, see: | ||
# | ||
# - https://github.com/stanford-crfm/helm/issues/2926 | ||
# - https://github.com/nltk/nltk/issues/3293 | ||
# - https://github.com/nltk/nltk/issues/3266 | ||
# - https://nvd.nist.gov/vuln/detail/CVE-2024-39705 | ||
# | ||
# TODO: Remove support for nltk<=3.8.1 and only install "punkt_tab" | ||
nltk_major_version, nltk_minor_version = [int(v) for v in version("nltk").split(".")[0:2]] | ||
if nltk_major_version < 3: | ||
raise Exception("ntlk version <3 is not supported") | ||
if nltk_minor_version >= 9: | ||
try: | ||
nltk.data.find("tokenizers/punkt_tab") | ||
except LookupError: | ||
nltk.download("punkt_tab") | ||
else: | ||
try: | ||
nltk.data.find("tokenizers/punkt") | ||
except LookupError: | ||
nltk.download("punkt") |
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